Skip to content

Commit

Permalink
Merge pull request #847 from w3c/pass-fail-test-run
Browse files Browse the repository at this point in the history
Passed/failed for assertion results in TestRenderer and migrate to pass/fail for report comparison algorithms
  • Loading branch information
howard-e authored Nov 29, 2023
2 parents 2264ac5 + e9f4388 commit 495543d
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 624 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export const CANDIDATE_REPORTS_QUERY = gql`
text
}
passed
failedReason
}
requiredAssertionResults: assertionResults(
priority: REQUIRED
Expand All @@ -123,7 +122,6 @@ export const CANDIDATE_REPORTS_QUERY = gql`
text
}
passed
failedReason
}
optionalAssertionResults: assertionResults(
priority: OPTIONAL
Expand All @@ -132,14 +130,12 @@ export const CANDIDATE_REPORTS_QUERY = gql`
text
}
passed
failedReason
}
mayAssertionResults: assertionResults(priority: MAY) {
assertion {
text
}
passed
failedReason
}
unexpectedBehaviors {
id
Expand Down
1 change: 0 additions & 1 deletion client/components/Reports/SummarizeTestPlanReport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ SummarizeTestPlanReport.propTypes = {
PropTypes.shape({
id: PropTypes.string.isRequired,
passed: PropTypes.bool.isRequired,
failedReason: PropTypes.string,
assertion: PropTypes.shape({
text: PropTypes.string.isRequired
}).isRequired
Expand Down
4 changes: 0 additions & 4 deletions client/components/Reports/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const REPORT_PAGE_QUERY = gql`
text
}
passed
failedReason
}
requiredAssertionResults: assertionResults(
priority: REQUIRED
Expand All @@ -89,7 +88,6 @@ export const REPORT_PAGE_QUERY = gql`
text
}
passed
failedReason
}
optionalAssertionResults: assertionResults(
priority: OPTIONAL
Expand All @@ -98,14 +96,12 @@ export const REPORT_PAGE_QUERY = gql`
text
}
passed
failedReason
}
mayAssertionResults: assertionResults(priority: MAY) {
assertion {
text
}
passed
failedReason
}
unexpectedBehaviors {
id
Expand Down
15 changes: 4 additions & 11 deletions client/components/ReviewConflicts/ReviewConflicts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ const ReviewConflicts = ({
const results = conflictingResults.map(result => {
const { testPlanRun, scenarioResult, assertionResult } = result;
let assertionResultFormatted;
if (assertionResult.passed) {
assertionResultFormatted = 'passing';
} else {
const reasonFormatted =
assertionResult.failedReason === 'INCORRECT_OUTPUT'
? 'incorrect output'
: 'no output';
assertionResultFormatted = `failing with ${reasonFormatted}`;
}
assertionResultFormatted = assertionResult.passed
? 'passing'
: 'failing';
return (
<li key={testPlanRun.id}>
Tester {testPlanRun.tester.username} recorded output &quot;
Expand Down Expand Up @@ -167,8 +161,7 @@ ReviewConflicts.propTypes = {
).isRequired
}),
assertionResult: PropTypes.shape({
passed: PropTypes.bool.isRequired,
failedReason: PropTypes.string
passed: PropTypes.bool.isRequired
})
})
).isRequired
Expand Down
4 changes: 1 addition & 3 deletions client/components/TestPlanUpdater/TestPlanUpdaterModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ const TestPlanUpdaterModal = ({
];
return {
id: assertionResultSkeleton.id,
passed: assertionResult.passed,
failedReason:
assertionResult.failedReason
passed: assertionResult.passed
};
}
),
Expand Down
1 change: 0 additions & 1 deletion client/components/TestPlanUpdater/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const VERSION_QUERY = gql`
output
assertionResults {
passed
failedReason
}
unexpectedBehaviors {
id
Expand Down
55 changes: 55 additions & 0 deletions client/components/TestRenderer/AssertionsFieldset/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { Fieldset } from '..';
import styled from '@emotion/styled';
import supportJson from '../../../resources/support.json';

const Label = styled.label`
display: block;
input {
margin-right: 0.25rem;
}
`;

const AssertionsFieldset = ({ assertions, commandIndex, assertionsHeader }) => {
// Handle case where build process didn't include assertionResponseQuestion
const normalizedHeader = useMemo(() => {
return assertionsHeader?.descriptionHeader?.replace(
'undefined',
supportJson.testPlanStrings.assertionResponseQuestion
);
}, [assertionsHeader]);

return (
<Fieldset>
<legend id={`command-${commandIndex}-assertions-heading`}>
{normalizedHeader}
</legend>
{assertions.map((assertion, assertionIndex) => {
const { description, passed, click } = assertion;

return (
<Label key={`AssertionKey_${assertionIndex}`}>
<input
type="checkbox"
id={`pass-${commandIndex}-${assertionIndex}`}
name={`assertion-${commandIndex}-${assertionIndex}`}
defaultChecked={passed}
onClick={click}
/>
{description[0]}
</Label>
);
})}
</Fieldset>
);
};

AssertionsFieldset.propTypes = {
assertions: PropTypes.array.isRequired,
commandIndex: PropTypes.number.isRequired,
assertionsHeader: PropTypes.object.isRequired
};

export default AssertionsFieldset;
Loading

0 comments on commit 495543d

Please sign in to comment.