-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7068471
commit d2af933
Showing
8 changed files
with
347 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react"; | ||
import { Alert, Box } from "@mui/material"; | ||
|
||
const ErrorMessage: React.FC<{ showError: boolean }> = ({ showError }) => { | ||
if (!showError) return null; | ||
|
||
return ( | ||
<Box sx={{ margin: 2 }}> | ||
<Alert severity="error"> | ||
<strong>No coverage data found!</strong> | ||
<br /> | ||
Please ensure that you have generated a <code>coverage.json</code> file | ||
using Jest with the <code>json-summary</code> reporter. The expected | ||
JSON structure should resemble the following: | ||
<pre> | ||
{JSON.stringify( | ||
{ | ||
"your-repository-name": { | ||
lines: { total: 100, covered: 50, skipped: 0, pct: 50 }, | ||
statements: { total: 200, covered: 100, skipped: 0, pct: 50 }, | ||
functions: { total: 20, covered: 10, skipped: 0, pct: 50 }, | ||
branches: { total: 30, covered: 15, skipped: 0, pct: 50 }, | ||
}, | ||
// Additional repositories can follow the same structure | ||
}, | ||
null, | ||
2 | ||
)} | ||
</pre> | ||
To generate this file, add the following configuration to your Jest | ||
setup: | ||
<pre>{`"jest": { | ||
"collectCoverage": true, | ||
"coverageReporters": ["json-summary"] | ||
}`}</pre> | ||
</Alert> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default ErrorMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from "react"; | ||
import { | ||
compressToEncodedURIComponent, | ||
decompressFromEncodedURIComponent, | ||
} from "lz-string"; | ||
import { useSearchParams } from "react-router-dom"; | ||
|
||
export const useFilterParams = () => { | ||
const [searchParams, setSearchParams] = useSearchParams(); | ||
const [filter, setFilter] = React.useState<string>(""); | ||
const [includeLabels, setIncludeLabels] = React.useState<string[]>([]); | ||
const [excludeLabels, setExcludeLabels] = React.useState<string[]>([]); | ||
|
||
React.useEffect(() => { | ||
const incParam = searchParams.get("inc") ?? ""; | ||
const excParam = searchParams.get("exc") ?? ""; | ||
const filterParam = searchParams.get("filter") ?? ""; | ||
|
||
if (incParam) { | ||
setIncludeLabels(decompressFromEncodedURIComponent(incParam).split(",")); | ||
} | ||
if (excParam) { | ||
setExcludeLabels(decompressFromEncodedURIComponent(excParam).split(",")); | ||
} | ||
if (filterParam) { | ||
setFilter(decompressFromEncodedURIComponent(filterParam)); | ||
} | ||
}, [searchParams]); | ||
|
||
const updateSearchParams = React.useCallback( | ||
(value: string | string[], type: "inc" | "exc" | "filter") => { | ||
const newSearchParams = new URLSearchParams(searchParams); | ||
|
||
if (Array.isArray(value) && value.length === 0) { | ||
newSearchParams.delete(type); | ||
} else if (value) { | ||
const compressedValue = Array.isArray(value) | ||
? compressToEncodedURIComponent(value.join(",")) | ||
: compressToEncodedURIComponent(value); | ||
newSearchParams.set(type, compressedValue); | ||
} | ||
|
||
setSearchParams(newSearchParams); | ||
}, | ||
[searchParams, setSearchParams] | ||
); | ||
|
||
return { | ||
filter, | ||
setFilter: (value: string) => updateSearchParams(value, "filter"), | ||
includeLabels, | ||
setIncludeLabels: (labels: string[]) => updateSearchParams(labels, "inc"), | ||
excludeLabels, | ||
setExcludeLabels: (labels: string[]) => updateSearchParams(labels, "exc"), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.