Skip to content

Commit

Permalink
Revert "Merge branch 'main' into feat/add-jest-annotation"
Browse files Browse the repository at this point in the history
This reverts commit 8b5fe42, reversing
changes made to 75b4108.
  • Loading branch information
apurv-wednesday committed May 9, 2024
1 parent 8b5fe42 commit ec27059
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 140 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,15 @@ jobs:

- name: Build Project
run: yarn build

# commenting for now to make CI green , will try this
# - name: run Lighthouse CI
# run: |
# yarn global add @lhci/[email protected]
# lhci autorun --collect.staticDistDir

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

# commenting for now to make CI green , will try this
# - uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test and generate coverage report
uses: artiomtr/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
package-manager: yarn
custom-title: Jest Coverage Report
40 changes: 0 additions & 40 deletions .github/workflows/jest-coverage.yml

This file was deleted.

10 changes: 10 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ const createJestConfig = nextJest({ dir: "./" });
const jestConfig: Config = {
preset: "ts-jest",
testEnvironment: "jsdom",
// uncomment later after adding tests
// coverageThreshold: {
// global: {
// statements: 90,
// branches: 90,
// functions: 90,
// lines: 90,
// },
// },
coverageReporters: ["json-summary", "text", "lcov"],
collectCoverageFrom: ["src/**/**/*.{js,jsx,ts,tsx}"],
reporters: [
"default",
Expand Down
3 changes: 2 additions & 1 deletion src/common/T/tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
exports[`<T /> should render and match the snapshot 1`] = `
.emotion-0 {
margin: 0;
font-family: fontFamily;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 400;
font-size: 1rem;
line-height: 1.5;
letter-spacing: 0.00938em;
}
<body>
Expand Down
1 change: 1 addition & 0 deletions src/common/styled/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const CustomCard = styled(Card)<{ maxwidth?: React.CSSProperties["maxWidt
padding: 1rem;
max-width: ${props => props.maxwidth}px;
color: ${props => props.color};
${props => props.color && `color: ${props.color}`};
}
`;

Expand Down
50 changes: 18 additions & 32 deletions src/containers/Repos/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container, CustomCard, If, T } from "@common";
import { Box, Divider, OutlinedInput, Pagination } from "@mui/material";
import { Box, Divider, Link, OutlinedInput, Pagination } from "@mui/material";
import { ErrorState, RepoList } from "@features/repos/components";
import { IRepoError } from "@features/repos/types";
import React, { memo, useEffect, useState } from "react";
Expand All @@ -8,82 +8,68 @@ import { useFetchRecommendationQuery } from "@features/repos/api/getRecommendati
import { useRouter } from "next/router";
import { Trans } from "@lingui/macro";
import { skipToken } from "@reduxjs/toolkit/query";
import styled from "@emotion/styled";
import Link from "next/link";

interface RepoContainerProps {
padding?: number;
maxwidth?: number;
}

const StyledSpan = styled.span`
color: darkblue;
`;

const StyledLink = styled(Link)`
text-decoration: none;
`;
const Repos: React.FC<RepoContainerProps> = ({ maxwidth }) => {
const router = useRouter();
const [repoName, setRepoName] = useState<string>("");
const [repoName, setRepoName] = useState<string>("react");
const [page, setPage] = useState<number>(1);

const { data, error, isLoading, isFetching } = useFetchRecommendationQuery(
isEmpty(repoName)
? skipToken
: {
repoName,
page,
},
repoName,
page: Number(page),
},
{ skip: router.isFallback }
);

const handlePageChange = (_: React.ChangeEvent<unknown>, pageNumber: number) => {
setPage(pageNumber);
updateUrlParams(repoName, pageNumber);
router.push(`/?search=${repoName}&page=${pageNumber}`, undefined, {
shallow: true,
scroll: true,
});
};

const handleRepoSearch = debounce((repoName: string) => {
setRepoName(repoName);
setPage(1);
updateUrlParams(repoName, 1); // Update URL params immediately
}, 500);
const updateUrlParams = (repoName: string, pageNumber: number) => {
router.push(`/?search=${repoName}&page=${pageNumber}`, undefined, {
shallow: true,
scroll: true,
});
};

useEffect(() => {
if (router.isReady) {
const searchParam = router.query?.search as string;
setRepoName(searchParam || "");
setPage(Number(router.query?.page) || 1);
setRepoName(router.query?.search as string);
setPage(router.query?.page as unknown as number);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [router.isReady]);

useEffect(() => {
if (!isEmpty(repoName)) {
updateUrlParams(repoName, page);
router.push(`/?search=${repoName}&page=${page}`);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data]);

return (
<Container padding={20} maxwidth={500}>
<Box>
<T>
<T variant="h5">
<Trans>Recommendation</Trans>
</T>
</Box>
<Box justifyContent="space-between">
<StyledLink href="https://www.iamawesome.com/">
<Link href="https://www.iamawesome.com/">
<T>
<Trans>
<StyledSpan>You Are Awesome</StyledSpan>
</Trans>
<Trans>You Are Awesome</Trans>
</T>
</StyledLink>
</Link>
</Box>
<Divider />
<CustomCard maxwidth={maxwidth}>
Expand Down
4 changes: 2 additions & 2 deletions src/features/repos/components/ErrorState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import get from "lodash/get";
import { T, CustomCard } from "@common";
import { IResponse } from "@features/repos/api/getRecommendations";
import { Trans, t } from "@lingui/macro";
import theme from "@app/themes";

interface ErrorStateProps {
loading: boolean;
Expand All @@ -24,8 +23,9 @@ const ErrorState: React.FC<ErrorStateProps> = ({ reposData, reposError, loading
} else if (!get(reposData, "totalCount", 0)) {
repoError = t`Search Default`;
}

return !loading && repoError ? (
<CustomCard color={reposError ? `${theme.palette.error.main}` : `${theme.palette.customColor.main[500]}`} data-testid="error-state">
<CustomCard color={reposError ? "red" : "grey"} data-testid="error-state">
<T variant="subtitle2">
<Trans>Repository List</Trans>
</T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,33 @@ exports[`<ErrorState /> should render and match the snapshot 1`] = `
margin: 20px 0;
padding: 1rem;
max-width: px;
color: #f44336;
color: grey;
color: grey;
}
.emotion-1 {
margin: 0;
font-family: fontFamily;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 500;
font-size: 0.875rem;
line-height: 1.57;
letter-spacing: 0.00714em;
}
.emotion-2 {
margin: 0;
font-family: fontFamily;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 400;
font-size: 1rem;
line-height: 1.5;
letter-spacing: 0.00938em;
}
<body>
<div>
<div
class="MuiPaper-root MuiPaper-outlined MuiPaper-rounded MuiCard-root emotion-0"
color="#f44336"
color="grey"
data-testid="error-state"
>
<h6
Expand All @@ -51,7 +54,7 @@ exports[`<ErrorState /> should render and match the snapshot 1`] = `
class="MuiTypography-root MuiTypography-body1 emotion-2"
data-testid="t"
>
Internal Service Error
Search Default
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("<ErrorState />", () => {
intl: {},
loading: false,
reposData: undefined,
reposError: "Internal Service Error",
reposError: undefined,
};

it("should render and match the snapshot", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ exports[`<RepoList /> should render and match the snapshot 1`] = `
.emotion-2 {
margin: 0;
font-family: fontFamily;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 400;
font-size: 1rem;
line-height: 1.5;
letter-spacing: 0.00938em;
}
.emotion-3 {
margin: 0;
font-family: fontFamily;
font-family: "Roboto","Helvetica","Arial",sans-serif;
font-weight: 400;
font-size: 1rem;
line-height: 1.5;
letter-spacing: 0.00938em;
margin-bottom: 8px;
}
Expand Down
8 changes: 2 additions & 6 deletions src/themes/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import styles from "./styles";
import { theme, CustomPalette, font, palette } from "./mui";
import { theme, font, palette } from "./mui";

export { styles, font, palette };

const customTheme = theme as Omit<typeof theme, "palette"> & {
palette: typeof theme.palette & CustomPalette
}

export default customTheme;
export default theme;
3 changes: 1 addition & 2 deletions src/themes/mui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTheme } from "@mui/material/styles";
import { palette, CustomPalette } from "./palette";
import { palette } from "./palette";
import { typography, font } from "./typography";
import { breakpoints } from "./breakpoints";

Expand All @@ -10,4 +10,3 @@ const theme = createTheme({
});

export { font, theme, palette };
export type {CustomPalette}
11 changes: 1 addition & 10 deletions src/themes/mui/palette.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import { PaletteOptions } from "@mui/material/styles";
import { blue, purple, green, red, amber } from "@mui/material/colors";
import { Color } from "@mui/material";

export type CustomPalette = {
customColor: {
main: Color | string;
}
}
/**
* @desc Refer documentation for clarity
* @link https://mui.com/material-ui/customization/palette/
*/
export const palette: PaletteOptions & CustomPalette = {
export const palette: PaletteOptions = {
primary: blue,
secondary: purple,
success: green,
error: red,
warning: amber,
customColor: {
main: "#141414",
}
};
2 changes: 1 addition & 1 deletion src/translations/en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ec27059

Please sign in to comment.