Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve splitting of tests into groups #212

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions src/components/PageResultsNew/TestResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,37 @@ function SingleTestRow(props: SingleTestRowProps) {
);
}

/**
* Awaited tests are those whose results are missing, are queued or
* currently running AND haven't been waived.
* @returns `true` if the test is required for gating and can be
* considered missing/awaited, `false` or `undefined` otherwise.
*/
const isRequiredAwaited = ({ required, status, waiver }: CiTest) =>
required &&
(status === 'missing' || status === 'queued' || status === 'running') &&
!waiver;

/**
* Failed tests are those that have ended with either an error or
* a failure AND haven't been waived.
* @returns `true` if the test is required for gating and can be
* considered failing, `false` or `undefined` otherwise.
*/
const isRequiredFailed = ({ required, status, waiver }: CiTest) =>
required &&
(status === 'error' || status === 'failed' || status === 'unknown') &&
!waiver;

/**
* Passed tests are those that have either 'passed' or 'info' status OR
* have been waived (regardless of original status).
* @returns `true` if the test is required for gating and can be
* considered passing, `false` or `undefined` otherwise.
*/
const isRequiredPassed = ({ required, status, waiver }: CiTest) =>
required && (['info', 'passed'].includes(status) || !_.isNil(waiver));

export interface TestResultsTableProps {
artifact: Artifact;
onSelect?(key: string | undefined): void;
Expand All @@ -194,12 +225,8 @@ export function TestResultsTable(props: TestResultsTableProps) {
}

const failedRequiredRows = tests
.filter(
({ required, status }) =>
required && (status === 'error' || status === 'failed'),
)
.filter((test) => isRequiredFailed(test))
.map((test, index) => (
/* More inspo in the docs: https://www.patternfly.org/v4/components/tabs/react-demos/#tables-and-tabs */
<Tr
isHoverable
isRowSelected={selectedTest?.name === test.name}
Expand All @@ -218,13 +245,7 @@ export function TestResultsTable(props: TestResultsTableProps) {
));

const awaitedRequiredRows = tests
.filter(
({ required, status }) =>
required &&
(status === 'missing' ||
status === 'queued' ||
status === 'running'),
)
.filter((test) => isRequiredAwaited(test))
.map((test, index) => (
<Tr
isHoverable
Expand All @@ -244,10 +265,7 @@ export function TestResultsTable(props: TestResultsTableProps) {
));

const passedRequiredRows = tests
.filter(
({ required, status }) =>
required && ['info', 'passed'].includes(status),
)
.filter((test) => isRequiredPassed(test))
.map((test) => (
<Tr
isHoverable
Expand Down
Loading