From 58fb7188a9bf89945d9f88ee1b0c067e0cfb7817 Mon Sep 17 00:00:00 2001 From: Alexander Flenniken Date: Thu, 2 May 2024 16:50:42 -0400 Subject: [PATCH] feat: Add backend support for minimum and exact AT versions (#1055) * Add minimum or exact at version to reports * Quick tweak * Revert home copy change * Remove unused field from createTestPlanReport * Fix undefined var * Prevent API from creating duplicate reports * Add atVersion frontend * Make sure automation dialog always shows when valid * Make sure existing reports have a minimum at version * Simplify jsx string Co-authored-by: Howard Edwards --------- Co-authored-by: Howard Edwards --- .../AddTestToQueueWithConfirmation/index.jsx | 138 ++-- client/components/ManageTestQueue/index.jsx | 115 +++- .../components/TestPlanVersionsPage/index.jsx | 68 -- client/components/TestQueue/queries.js | 27 +- client/components/common/RadioBox/index.jsx | 88 +++ client/tests/AtVersions.test.js | 4 +- server/graphql-schema.js | 47 +- ...veTestPlanReportValuesToTestPlanVersion.js | 634 ------------------ ...20240312122457-testPlanReportAtVersions.js | 72 ++ server/models/TestPlanReport.js | 8 + .../models/services/TestPlanReportService.js | 26 +- .../TestPlanReportOperations/index.js | 4 +- ...teTestPlanReportTestPlanVersionResolver.js | 341 ---------- .../resolvers/createTestPlanReportResolver.js | 56 ++ .../findOrCreateTestPlanReportResolver.js | 77 --- .../resolvers/helpers/processCopiedReports.js | 6 +- server/resolvers/index.js | 4 +- .../tests/integration/dataManagement.test.js | 99 ++- server/tests/integration/graphql.test.js | 10 +- server/tests/integration/testPlanRun.test.js | 14 +- server/tests/integration/testQueue.test.js | 88 +-- .../services/TestPlanReportService.test.js | 45 -- 22 files changed, 522 insertions(+), 1449 deletions(-) create mode 100644 client/components/common/RadioBox/index.jsx delete mode 100644 server/migrations/20230608171911-moveTestPlanReportValuesToTestPlanVersion.js create mode 100644 server/migrations/20240312122457-testPlanReportAtVersions.js delete mode 100644 server/resolvers/TestPlanReportOperations/updateTestPlanReportTestPlanVersionResolver.js create mode 100644 server/resolvers/createTestPlanReportResolver.js delete mode 100644 server/resolvers/findOrCreateTestPlanReportResolver.js diff --git a/client/components/AddTestToQueueWithConfirmation/index.jsx b/client/components/AddTestToQueueWithConfirmation/index.jsx index 4add46dfc..56517f5c4 100644 --- a/client/components/AddTestToQueueWithConfirmation/index.jsx +++ b/client/components/AddTestToQueueWithConfirmation/index.jsx @@ -19,6 +19,8 @@ function AddTestToQueueWithConfirmation({ testPlanVersion, browser, at, + exactAtVersion, + minimumAtVersion, disabled = false, buttonText = 'Add to Test Queue', triggerUpdate = () => {} @@ -44,23 +46,11 @@ function AddTestToQueueWithConfirmation({ const existingTestPlanReports = existingTestPlanReportsData?.existingTestPlanVersion?.testPlanReports; - const conflictingReportExists = existingTestPlanReports?.some(report => { - return ( - report.at.id === at?.id && - report.browser.id === browser?.id && - report.isFinal - ); - }); - let latestOldVersion; let oldReportToCopyResultsFrom; - // Prioritize a conflicting report for the current version, otherwise - // check if any results data available from a previous result - if ( - !conflictingReportExists && - existingTestPlanReportsData?.oldTestPlanVersions?.length - ) { + // Check if any results data available from a previous result + if (existingTestPlanReportsData?.oldTestPlanVersions?.length) { latestOldVersion = existingTestPlanReportsData?.oldTestPlanVersions?.reduce((a, b) => new Date(a.updatedAt) > new Date(b.updatedAt) ? a : b @@ -135,7 +125,7 @@ function AddTestToQueueWithConfirmation({ await addTestToQueue( canUseOldResults ? { - copyResultsFromTestPlanReportId: + copyResultsFromTestPlanVersionId: latestOldVersion.id } : {} @@ -151,7 +141,7 @@ function AddTestToQueueWithConfirmation({ const testPlanReport = await addTestToQueue( canUseOldResults ? { - copyResultsFromTestPlanReportId: + copyResultsFromTestPlanVersionId: latestOldVersion.id } : {} @@ -184,76 +174,47 @@ function AddTestToQueueWithConfirmation({ }; const renderPreserveReportDataDialog = () => { - let title; - let content; - let actions = []; - - if (oldReportToCopyResultsFrom) { - title = 'Older Results Data Found'; - content = - 'Older results with the same AT, browser and test plan ' + - 'were found for the report being created. Would you like ' + - 'to copy the older results into the report or create a ' + - 'completely new report?'; - actions = [ - { - label: 'Create empty report', - onClick: async () => { - setShowPreserveReportDataMessage(false); - if (hasAutomationSupport) { - setShowConfirmation(true); - } else { - await addTestToQueue(); - } - } - }, - { - label: 'Copy older results', - onClick: async () => { - setShowPreserveReportDataMessage(false); - setCanUseOldResults(true); - - if (hasAutomationSupport) { - setShowConfirmation(true); - } else { - await addTestToQueue({ - copyResultsFromTestPlanReportId: - latestOldVersion.id - }); - } - } - } - ]; - } else { - 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?'; - actions = [ - { - label: 'Proceed', - onClick: async () => { - setShowPreserveReportDataMessage(false); - if (hasAutomationSupport) { - setShowConfirmation(true); - } else { - await addTestToQueue(); - } - } - } - ]; - } - return ( { + setShowPreserveReportDataMessage(false); + if (hasAutomationSupport) { + setShowConfirmation(true); + } else { + await addTestToQueue(); + } + } + }, + { + label: 'Copy older results', + onClick: async () => { + setShowPreserveReportDataMessage(false); + setCanUseOldResults(true); + + if (hasAutomationSupport) { + setShowConfirmation(true); + } else { + await addTestToQueue({ + copyResultsFromTestPlanVersionId: + latestOldVersion.id + }); + } + } + } + ]} useOnHide handleClose={async () => { setShowPreserveReportDataMessage(false); @@ -262,20 +223,23 @@ function AddTestToQueueWithConfirmation({ ); }; - const addTestToQueue = async ({ copyResultsFromTestPlanReportId } = {}) => { + const addTestToQueue = async ({ + copyResultsFromTestPlanVersionId + } = {}) => { let tpr; await triggerLoad(async () => { const res = await addTestPlanReport({ variables: { testPlanVersionId: testPlanVersion.id, atId: at.id, + minimumAtVersionId: minimumAtVersion?.id, + exactAtVersionId: exactAtVersion?.id, browserId: browser.id, - copyResultsFromTestPlanReportId + copyResultsFromTestPlanVersionId } }); const testPlanReport = - res?.data?.findOrCreateTestPlanReport?.populatedData - ?.testPlanReport ?? null; + res?.data?.createTestPlanReport?.testPlanReport ?? null; tpr = testPlanReport; }, 'Adding Test Plan to Test Queue'); setShowConfirmation(true); @@ -300,7 +264,7 @@ function AddTestToQueueWithConfirmation({ disabled={disabled} variant="secondary" onClick={async () => { - if (conflictingReportExists || oldReportToCopyResultsFrom) { + if (oldReportToCopyResultsFrom) { setShowPreserveReportDataMessage(true); } else { if (hasAutomationSupport) { @@ -325,6 +289,8 @@ AddTestToQueueWithConfirmation.propTypes = { testPlanVersion: PropTypes.object, browser: PropTypes.object, at: PropTypes.object, + exactAtVersion: PropTypes.object, + minimumAtVersion: PropTypes.object, buttonRef: PropTypes.object, onFocus: PropTypes.func, onBlur: PropTypes.func, diff --git a/client/components/ManageTestQueue/index.jsx b/client/components/ManageTestQueue/index.jsx index cd5aee9c2..77b4717ba 100644 --- a/client/components/ManageTestQueue/index.jsx +++ b/client/components/ManageTestQueue/index.jsx @@ -18,6 +18,7 @@ import { convertStringToDate } from '../../utils/formatter'; import { LoadingStatus, useTriggerLoad } from '../common/LoadingStatus'; import DisclosureComponent from '../common/DisclosureComponent'; import AddTestToQueueWithConfirmation from '../AddTestToQueueWithConfirmation'; +import RadioBox from '../common/RadioBox'; const DisclosureContainer = styled.div` // Following directives are related to the ManageTestQueue component @@ -28,11 +29,8 @@ const DisclosureContainer = styled.div` // Add Test Plan to Test Queue button > button { - display: flex; padding: 0.5rem 1rem; margin-top: 1rem; - margin-left: auto; - margin-right: 0; } .disclosure-row-manage-ats { @@ -78,9 +76,38 @@ const DisclosureContainer = styled.div` .disclosure-row-test-plans { display: grid; - grid-auto-flow: column; - grid-template-columns: 1fr 1fr 1fr 1fr; - grid-gap: 1rem; + grid-template-columns: 1fr; + row-gap: 0.5rem; + + & > :nth-of-type(2) { + display: none; + } + & > :nth-of-type(5) { + grid-column: span 2; + } + + @media (min-width: 768px) { + grid-template-columns: 2fr 2fr 1fr; + column-gap: 2rem; + + & > :nth-of-type(2) { + display: block; + } + } + } + + .form-group-at-version { + display: flex; + flex-wrap: wrap; + column-gap: 1rem; + row-gap: 0.75rem; + + select { + width: inherit; + @media (max-width: 767px) { + flex-grow: 1; + } + } } .disclosure-form-label { @@ -139,6 +166,10 @@ const ManageTestQueue = ({ const [selectedAtId, setSelectedAtId] = useState(''); const [selectedBrowserId, setSelectedBrowserId] = useState(''); + const [selectAtVersionExactOrMinimum, setSelectedAtVersionExactOrMinimum] = + useState('Exact Version'); + const [selectedReportAtVersionId, setSelectedReportAtVersionId] = + useState(null); const [addAtVersion] = useMutation(ADD_AT_VERSION_MUTATION); const [editAtVersion] = useMutation(EDIT_AT_VERSION_MUTATION); @@ -307,6 +338,7 @@ const ManageTestQueue = ({ const onAtChange = e => { const { value } = e.target; setSelectedAtId(value); + setSelectedReportAtVersionId(null); }; const onBrowserChange = e => { @@ -314,6 +346,11 @@ const ManageTestQueue = ({ setSelectedBrowserId(value); }; + const onReportAtVersionIdChange = e => { + const { value } = e.target; + setSelectedReportAtVersionId(value); + }; + const onTestPlanVersionChange = e => { const { value } = e.target; setSelectedTestPlanVersionId(value); @@ -466,6 +503,10 @@ const ManageTestQueue = ({ setShowThemedModal(true); }; + const exactOrMinimumAtVersion = ats + .find(item => item.id === selectedAtId) + ?.atVersions.find(item => item.id === selectedReportAtVersionId); + return ( - Select an Assistive Technology and manage its + Select an assistive technology and manage its versions in the ARIA-AT App
@@ -551,8 +592,8 @@ const ManageTestQueue = ({ key={`manage-test-queue-add-test-plans-section`} > - Select a Test Plan and version and an Assistive - Technology and Browser to add it to the Test Queue + Select a test plan, assistive technology and browser + to add a new test plan report to the test queue.
@@ -616,6 +657,7 @@ const ManageTestQueue = ({ )} +
{/* blank grid cell */}
Assistive Technology @@ -637,6 +679,47 @@ const ManageTestQueue = ({ ))} + + + Assistive Technology Version + +
+ + setSelectedAtVersionExactOrMinimum( + exactOrMinimum + ) + } + /> + + + {ats + .find(at => at.id === selectedAtId) + ?.atVersions.map(item => ( + + ))} + +
+
Browser @@ -644,6 +727,7 @@ const ManageTestQueue = ({