Skip to content

Commit

Permalink
Merge branch 'main' into w3cgh-872-fix-bot-run-tests-status-list
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Feb 21, 2024
2 parents 8fc0a42 + 7ff07b0 commit bcf83eb
Show file tree
Hide file tree
Showing 71 changed files with 7,591 additions and 1,097 deletions.
1 change: 1 addition & 0 deletions .github/workflows/runtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_1}
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_2}
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_3}
yarn workspace server db-import-tests:test -c ${IMPORT_ARIA_AT_TESTS_COMMIT_4}
yarn workspace server db-populate-sample-data:test
- name: test
run: yarn test
Expand Down
8 changes: 0 additions & 8 deletions client/components/ATAlert/ATAlert.css

This file was deleted.

17 changes: 0 additions & 17 deletions client/components/ATAlert/index.jsx

This file was deleted.

69 changes: 60 additions & 9 deletions client/components/AddTestToQueueWithConfirmation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import './AddTestToQueueWithConfirmation.css';
import {
SCHEDULE_COLLECTION_JOB_MUTATION,
TEST_PLAN_RUN_REPORTS_INITIATED_BY_AUTOMATION
EXISTING_TEST_PLAN_REPORTS
} from './queries';

function AddTestToQueueWithConfirmation({
Expand All @@ -23,11 +23,12 @@ function AddTestToQueueWithConfirmation({
buttonText = 'Add to Test Queue',
triggerUpdate = () => {}
}) {
const [errorMessage, setErrorMessage] = useState(false);
const [showConfirmation, setShowConfirmation] = useState(false);
const [addTestPlanReport] = useMutation(ADD_TEST_QUEUE_MUTATION);
const [scheduleCollection] = useMutation(SCHEDULE_COLLECTION_JOB_MUTATION);
const { data: testPlanReportsInitiatedByAutomation } = useQuery(
TEST_PLAN_RUN_REPORTS_INITIATED_BY_AUTOMATION,
const { data: existingTestPlanReportsData } = useQuery(
EXISTING_TEST_PLAN_REPORTS,
{
variables: {
testPlanVersionId: testPlanVersion?.id
Expand All @@ -37,6 +38,17 @@ function AddTestToQueueWithConfirmation({
}
);

const existingTestPlanReports =
existingTestPlanReportsData?.testPlanVersion.testPlanReports;

const conflictingReportExists = existingTestPlanReports?.some(report => {
return (
report.at.id === at?.id &&
report.browser.id === browser?.id &&
report.isFinal
);
});

const { triggerLoad, loadingMessage } = useTriggerLoad();
const buttonRef = useRef();

Expand All @@ -47,12 +59,12 @@ function AddTestToQueueWithConfirmation({

const alreadyHasBotInTestPlanReport = useMemo(
() =>
testPlanReportsInitiatedByAutomation?.testPlanVersion.testPlanReports.some(
existingTestPlanReports?.some(
tpr =>
tpr.markedFinalAt === null &&
tpr.draftTestPlanRuns.some(run => run.initiatedByAutomation)
),
[testPlanReportsInitiatedByAutomation?.testPlanVersion.testPlanReports]
[existingTestPlanReports]
);

const feedbackModalTitle =
Expand Down Expand Up @@ -110,7 +122,7 @@ function AddTestToQueueWithConfirmation({
}
return (
<BasicModal
dialogClassName={'add-test-to-queue-confirmation'}
dialogClassName="add-test-to-queue-confirmation"
show={showConfirmation}
title={feedbackModalTitle}
content={feedbackModalContent}
Expand All @@ -129,6 +141,40 @@ function AddTestToQueueWithConfirmation({
);
};

const renderErrorDialog = () => {
return (
<BasicModal
show={errorMessage}
title="Conflicting Report Found"
content={
'The report could not be created because an existing ' +
'report was found on the reports page with the same AT, ' +
'browser and test plan version. Would you like to return ' +
'the existing report back to the test queue?'
}
closeLabel="Cancel"
staticBackdrop={true}
actions={[
{
label: 'Proceed',
onClick: async () => {
setErrorMessage(false);
if (hasAutomationSupport) {
setShowConfirmation(true);
} else {
await addTestToQueue();
}
}
}
]}
useOnHide
handleClose={async () => {
setErrorMessage(false);
}}
/>
);
};

const addTestToQueue = async () => {
let tpr;
await triggerLoad(async () => {
Expand Down Expand Up @@ -166,17 +212,22 @@ function AddTestToQueueWithConfirmation({
disabled={disabled}
variant="secondary"
onClick={async () => {
if (hasAutomationSupport) {
setShowConfirmation(true);
if (conflictingReportExists) {
setErrorMessage(true);
} else {
await addTestToQueue();
if (hasAutomationSupport) {
setShowConfirmation(true);
} else {
await addTestToQueue();
}
}
}}
className="w-auto"
data-testid="add-button"
>
{buttonText}
</Button>
{renderErrorDialog()}
{renderConfirmation()}
</LoadingStatus>
);
Expand Down
11 changes: 9 additions & 2 deletions client/components/AddTestToQueueWithConfirmation/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ export const SCHEDULE_COLLECTION_JOB_MUTATION = gql`
}
`;

export const TEST_PLAN_RUN_REPORTS_INITIATED_BY_AUTOMATION = gql`
query DraftTestPlanRunsTestPlanReports($testPlanVersionId: ID!) {
export const EXISTING_TEST_PLAN_REPORTS = gql`
query ExistingTestPlanReports($testPlanVersionId: ID!) {
testPlanVersion(id: $testPlanVersionId) {
id
testPlanReports {
id
markedFinalAt
isFinal
draftTestPlanRuns {
initiatedByAutomation
}
at {
id
}
browser {
id
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { Button } from 'react-bootstrap';
import { unescape } from 'lodash';
import { parseListContent } from '../../TestRenderer/utils';
import {
parseListContent,
parseSettingsContent
} from '../../TestRenderer/utils';
import {
userCloseWindow,
userOpenWindow
Expand Down Expand Up @@ -120,8 +123,10 @@ const InstructionsRenderer = ({

let allInstructions;
const isV2 = testFormatVersion === 2;
let settingsContent = [];

if (isV2) {
// There is at least one defined 'setting' for the list of AT commands
const commandSettingSpecified = renderableContent.commands.some(
({ settings }) => settings && settings !== 'defaultMode'
);
Expand All @@ -144,6 +149,10 @@ const InstructionsRenderer = ({
setupScriptDescription + '.',
testInstructions + ' ' + settingsInstructions
].map(e => unescape(e));
settingsContent = parseSettingsContent(
renderableContent.instructions.mode,
renderableContent.target.at.raw.settings
);
} else {
allInstructions = [
...pageContent.instructions.instructions.instructions,
Expand All @@ -168,8 +177,11 @@ const InstructionsRenderer = ({
return (
<>
<NumberedList>{allInstructionsContent}</NumberedList>
<Heading>Assertions</Heading>
<Heading>{pageContent.instructions.assertions.header}</Heading>
{pageContent.instructions.assertions.description}
<NumberedList>{assertionsContent}</NumberedList>
{settingsContent.length ? settingsContent : null}

<Button
disabled={!pageContent.instructions.openTestPage.enabled}
onClick={pageContent.instructions.openTestPage.click}
Expand Down
25 changes: 7 additions & 18 deletions client/components/DataManagement/DataManagementRow/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,6 @@ const DataManagementRow = ({
}
};

// TODO: Remove this testFormatVersion check when #745 is implemented
const getLinkHref = version =>
version.metadata?.testFormatVersion === 2
? null
: `/test-review/${version.id}`;

switch (phase) {
case 'RD': {
// If the latest version of the plan is in the draft, candidate, or recommended
Expand Down Expand Up @@ -555,14 +549,12 @@ const DataManagementRow = ({
// "active"
insertActivePhaseForTestPlan(latestVersion);

// TODO: Remove this testFormatVersion check when #745 is implemented
const linkHref = getLinkHref(latestVersion);
return (
<PhaseCell role="list" aria-setsize={isAdmin ? 2 : 1}>
<VersionString
role="listitem"
iconColor="#2BA51C"
linkHref={linkHref}
linkHref={`/test-review/${latestVersion.id}`}
>
{latestVersion.versionString}
</VersionString>
Expand Down Expand Up @@ -685,15 +677,13 @@ const DataManagementRow = ({
// Phase is "active"
insertActivePhaseForTestPlan(latestVersion);

// TODO: Remove this testFormatVersion check when #745 is implemented
const linkHref = getLinkHref(latestVersion);
return (
<PhaseCell role="list" aria-setsize={isAdmin ? 3 : 2}>
<VersionString
role="listitem"
iconColor="#2BA51C"
linkRef={draftVersionStringRef}
linkHref={linkHref}
linkHref={`/test-review/${latestVersion.id}`}
>
{latestVersion.versionString}
</VersionString>
Expand Down Expand Up @@ -728,6 +718,7 @@ const DataManagementRow = ({
)}
<span role="listitem">
<TestPlanReportStatusDialogWithButton
ats={ats}
testPlanVersionId={latestVersion.id}
/>
</span>
Expand Down Expand Up @@ -887,15 +878,13 @@ const DataManagementRow = ({
// Phase is "active"
insertActivePhaseForTestPlan(latestVersion);

// TODO: Remove this testFormatVersion check when #745 is implemented
const linkHref = getLinkHref(latestVersion);
return (
<PhaseCell role="list" aria-setsize={isAdmin ? 5 : 4}>
<VersionString
role="listitem"
iconColor="#2BA51C"
linkRef={candidateVersionStringRef}
linkHref={linkHref}
linkHref={`/test-review/${latestVersion.id}`}
>
{latestVersion.versionString}
</VersionString>
Expand Down Expand Up @@ -933,6 +922,7 @@ const DataManagementRow = ({
)}
<span role="listitem">
<TestPlanReportStatusDialogWithButton
ats={ats}
testPlanVersionId={latestVersion.id}
/>
</span>
Expand Down Expand Up @@ -1009,20 +999,19 @@ const DataManagementRow = ({
// Phase is "active"
insertActivePhaseForTestPlan(latestVersion);

// TODO: Remove this testFormatVersion check when #745 is implemented
const linkHref = getLinkHref(latestVersion);
return (
<PhaseCell role="list">
<VersionString
role="listitem"
iconColor="#2BA51C"
linkRef={recommendedVersionStringRef}
linkHref={linkHref}
linkHref={`/test-review/${latestVersion.id}`}
>
{latestVersion.versionString}
</VersionString>
<span role="listitem">
<TestPlanReportStatusDialogWithButton
ats={ats}
testPlanVersionId={latestVersion.id}
/>
</span>
Expand Down
Loading

0 comments on commit bcf83eb

Please sign in to comment.