Skip to content

Commit

Permalink
Merge pull request #1134 from w3c/releases
Browse files Browse the repository at this point in the history
Includes changes recently included in the [releases branch](https://github.com/w3c/aria-at-app/tree/releases) through #1133.

[Latest CHANGELOG.md update](https://github.com/w3c/aria-at-app/blob/releases/CHANGELOG.md#140-2024-06-24)
  • Loading branch information
howard-e authored Jun 24, 2024
2 parents ee8fd6a + a3e2b23 commit 7d933eb
Show file tree
Hide file tree
Showing 104 changed files with 10,279 additions and 4,555 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [1.4.0](https://github.com/w3c/aria-at-app/compare/v1.3.1...v1.4.0) (2024-06-24)


### Features

* Trends ([#1123](https://github.com/w3c/aria-at-app/issues/1123)) ([af8f492](https://github.com/w3c/aria-at-app/commit/af8f492b7d40ffadcedec88c47d06b166ec489fe)), closes [#791](https://github.com/w3c/aria-at-app/issues/791) [#792](https://github.com/w3c/aria-at-app/issues/792) [#1055](https://github.com/w3c/aria-at-app/issues/1055) [#1001](https://github.com/w3c/aria-at-app/issues/1001) [#1065](https://github.com/w3c/aria-at-app/issues/1065) [#1052](https://github.com/w3c/aria-at-app/issues/1052) [#1087](https://github.com/w3c/aria-at-app/issues/1087) [#1098](https://github.com/w3c/aria-at-app/issues/1098) [#1092](https://github.com/w3c/aria-at-app/issues/1092) [#1131](https://github.com/w3c/aria-at-app/issues/1131) [#1124](https://github.com/w3c/aria-at-app/issues/1124)


### Bug Fixes

* use correct test number sequence for raising github issues ([#1128](https://github.com/w3c/aria-at-app/issues/1128)) ([70270e3](https://github.com/w3c/aria-at-app/commit/70270e3d83bf1eca6ea8f74cef4fcba104b1e783))

### [1.3.1](https://github.com/w3c/aria-at-app/compare/v1.3.0...v1.3.1) (2024-06-12)


Expand Down
224 changes: 115 additions & 109 deletions client/components/AddTestToQueueWithConfirmation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ import {
SCHEDULE_COLLECTION_JOB_MUTATION,
EXISTING_TEST_PLAN_REPORTS
} from './queries';
import { TEST_QUEUE_PAGE_QUERY } from '../TestQueue2/queries';
import { TEST_PLAN_REPORT_STATUS_DIALOG_QUERY } from '../TestPlanReportStatusDialog/queries';
import { ME_QUERY } from '../App/queries';

function AddTestToQueueWithConfirmation({
testPlanVersion,
browser,
at,
exactAtVersion,
minimumAtVersion,
disabled = false,
buttonText = 'Add to Test Queue',
triggerUpdate = () => {}
Expand All @@ -27,8 +32,27 @@ function AddTestToQueueWithConfirmation({
useState(false);
const [showConfirmation, setShowConfirmation] = useState(false);
const [canUseOldResults, setCanUseOldResults] = useState(false);
const [addTestPlanReport] = useMutation(ADD_TEST_QUEUE_MUTATION);
const [scheduleCollection] = useMutation(SCHEDULE_COLLECTION_JOB_MUTATION);

const [addTestPlanReport] = useMutation(ADD_TEST_QUEUE_MUTATION, {
refetchQueries: [
ME_QUERY,
EXISTING_TEST_PLAN_REPORTS,
TEST_QUEUE_PAGE_QUERY,
TEST_PLAN_REPORT_STATUS_DIALOG_QUERY
],
awaitRefetchQueries: true
});

const [scheduleCollection] = useMutation(SCHEDULE_COLLECTION_JOB_MUTATION, {
refetchQueries: [
ME_QUERY,
EXISTING_TEST_PLAN_REPORTS,
TEST_QUEUE_PAGE_QUERY,
TEST_PLAN_REPORT_STATUS_DIALOG_QUERY
],
awaitRefetchQueries: true
});

const { data: existingTestPlanReportsData } = useQuery(
EXISTING_TEST_PLAN_REPORTS,
{
Expand All @@ -44,28 +68,26 @@ 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
) {
latestOldVersion =
existingTestPlanReportsData?.oldTestPlanVersions?.reduce((a, b) =>
new Date(a.updatedAt) > new Date(b.updatedAt) ? a : b
);
// Check if any results data available from a previous result using the
// same testFormatVersion
const oldTestPlanVersions =
existingTestPlanReportsData?.oldTestPlanVersions?.filter(
({ metadata }) => {
return (
metadata.testFormatVersion ===
existingTestPlanReportsData?.existingTestPlanVersion
?.metadata.testFormatVersion
);
}
) || [];

if (oldTestPlanVersions?.length) {
latestOldVersion = oldTestPlanVersions?.reduce((a, b) =>
new Date(a.updatedAt) > new Date(b.updatedAt) ? a : b
);
if (
new Date(latestOldVersion?.updatedAt) <
new Date(testPlanVersion?.updatedAt)
Expand Down Expand Up @@ -132,32 +154,40 @@ function AddTestToQueueWithConfirmation({
actions.push({
label: 'Add and run later',
onClick: async () => {
await addTestToQueue(
canUseOldResults
? {
copyResultsFromTestPlanReportId:
latestOldVersion.id
}
: {}
);
await closeWithUpdate();
}
});

if (!alreadyHasBotInTestPlanReport) {
actions.push({
label: 'Add and run with bot',
onClick: async () => {
const testPlanReport = await addTestToQueue(
try {
await addTestToQueue(
canUseOldResults
? {
copyResultsFromTestPlanReportId:
copyResultsFromTestPlanVersionId:
latestOldVersion.id
}
: {}
);
await scheduleCollectionJob(testPlanReport);
await closeWithUpdate();
} catch (e) {
console.error(e);
}
}
});

if (!alreadyHasBotInTestPlanReport) {
actions.push({
label: 'Add and run with bot',
onClick: async () => {
try {
const testPlanReport = await addTestToQueue(
canUseOldResults
? {
copyResultsFromTestPlanVersionId:
latestOldVersion.id
}
: {}
);
await scheduleCollectionJob(testPlanReport);
await closeWithUpdate();
} catch (e) {
console.error(e);
}
}
});
}
Expand All @@ -184,76 +214,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 (
<BasicModal
show={showPreserveReportDataMessage}
title={title}
content={content}
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?'
}
closeLabel="Cancel"
staticBackdrop={true}
actions={actions}
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({
copyResultsFromTestPlanVersionId:
latestOldVersion.id
});
}
}
}
]}
useOnHide
handleClose={async () => {
setShowPreserveReportDataMessage(false);
Expand All @@ -262,20 +263,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);
Expand All @@ -300,7 +304,7 @@ function AddTestToQueueWithConfirmation({
disabled={disabled}
variant="secondary"
onClick={async () => {
if (conflictingReportExists || oldReportToCopyResultsFrom) {
if (oldReportToCopyResultsFrom) {
setShowPreserveReportDataMessage(true);
} else {
if (hasAutomationSupport) {
Expand Down Expand Up @@ -333,6 +337,8 @@ AddTestToQueueWithConfirmation.propTypes = {
key: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
}),
exactAtVersion: PropTypes.object,
minimumAtVersion: PropTypes.object,
buttonRef: PropTypes.object,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
Expand Down
2 changes: 2 additions & 0 deletions client/components/AddTestToQueueWithConfirmation/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const EXISTING_TEST_PLAN_REPORTS = gql`
id
}
}
metadata
}
oldTestPlanVersions: testPlanVersions(
phases: [CANDIDATE, RECOMMENDED]
Expand All @@ -46,6 +47,7 @@ export const EXISTING_TEST_PLAN_REPORTS = gql`
id
}
}
metadata
}
}
`;
Loading

0 comments on commit 7d933eb

Please sign in to comment.