diff --git a/client/components/CandidateReview/CandidateTestPlanRun/InstructionsRenderer.jsx b/client/components/CandidateReview/CandidateTestPlanRun/InstructionsRenderer.jsx index abf723901..59973f29a 100644 --- a/client/components/CandidateReview/CandidateTestPlanRun/InstructionsRenderer.jsx +++ b/client/components/CandidateReview/CandidateTestPlanRun/InstructionsRenderer.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import styled from '@emotion/styled'; -import { Button } from 'react-bootstrap'; +import { Button, Table } from 'react-bootstrap'; import { unescape } from 'lodash'; import { parseListContent, @@ -19,6 +19,7 @@ import { TestWindow } from '../../../resources/aria-at-test-window.mjs'; import { evaluateAtNameKey } from '../../../utils/aria.js'; import commandsJson from '../../../resources/commands.json'; import supportJson from '../../../resources/support.json'; +import { convertAssertionPriority } from 'shared'; const NumberedList = styled.ol` counter-reset: numbered-list; @@ -169,19 +170,145 @@ const InstructionsRenderer = ({ commandsContent ); - const assertions = [...pageContent.instructions.assertions.assertions]; - const assertionsContent = parseListContent(assertions); - const Heading = `h${headingLevel}`; return ( <> {allInstructionsContent} - {pageContent.instructions.assertions.header} - {pageContent.instructions.assertions.description} - {assertionsContent} {settingsContent.length ? settingsContent : null} + {renderableContent.commands.map( + ({ id, settings, assertionExceptions = [] }, i) => { + const settingsScreenText = isV2 + ? renderableContent.target.at.raw.settings[settings] + ?.screenText ?? '' + : null; + + let mustCount = 0; + let shouldCount = 0; + let mayCount = 0; + + let assertions = [...renderableContent.assertions]; + + assertionExceptions.forEach(exception => { + const assertionIndex = assertions.findIndex( + assertion => { + return ( + assertion.assertionId === + exception.assertionId + ); + } + ); + if (exception.priority === 0) { + assertions.splice(assertionIndex, 1); + } else { + assertions[assertionIndex].priority = + exception.priority; + } + }); + + assertions.forEach(({ priority }) => { + const priorityString = + convertAssertionPriority(priority); + if (priorityString === 'MUST') mustCount += 1; + if (priorityString === 'SHOULD') shouldCount += 1; + if (priorityString === 'MAY') mayCount += 1; + }); + + const settingsScreenTextFormatted = settingsScreenText + ? ` (${settingsScreenText})` + : ''; + + const scenarioTitle = + `${renderableContent.commands[i].keystroke}` + + `${settingsScreenTextFormatted}: ${mustCount} MUST, ` + + `${shouldCount} SHOULD, ${mayCount} MAY Assertions`; + + if (isV2) { + return ( + + + {scenarioTitle} + + + + + + + + + + + {assertions.map( + ({ + assertionPhrase, + assertionStatement, + priority, + assertionId + }) => ( + + + + + + ) + )} + +
PriorityAssertion PhraseAssertion Statement
+ {convertAssertionPriority( + priority + )} + {assertionPhrase} + {assertionStatement} +
+
+ ); + } else { + return ( + + {scenarioTitle} + + + + + + + + + {assertions.map( + ({ expectation, priority }) => ( + + + + + ) + )} + +
PriorityAssertion Statement
+ {convertAssertionPriority( + priority + )} + {expectation}
+
+ ); + } + } + )} +