Skip to content

Commit 382795e

Browse files
alflennikhoward-e
andauthored
Deduplicate TestPlanVersions (#621)
* Remove duplicate TestPlanVersions * Update tests for TestPlanVersion * Update migration to include regenerating testIds, scenarioIds and assertionsIds for TestRuns that are referencing tests from now deleted TestPlanVersions * Improve readability * Explicitly set sort order of ManageTestQueue "Test Plans dropdown" options * Prevent query being called without relevant data * More explicit time checks to align with previously accepted reporting values being pushed to the "top" * Alphabetically sort list of testers to be assigned and how they are displayed on TestQueueRow * Address PR feedback * Stop double hashing through hashTests * Add tests for hashTest(s) functionality * atId of the TestPlanReports needs to be explicitly checked when regenerating the various result ids because the source tests.scenarios are further broken apart by their respective ATs * Update TestPlanVersion comments and move mock data to individual json files * Update tests to track any changes to expected hashes --------- Co-authored-by: Howard Edwards <[email protected]>
1 parent c6886d5 commit 382795e

24 files changed

+2457
-79
lines changed

.vscode/launch.json

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"version": "1.0.0",
33
"configurations": [
4+
{
5+
"name": "Import tests",
6+
"program": "${workspaceFolder}/server/scripts/import-tests/index.js",
7+
"request": "launch",
8+
"envFile": "${workspaceFolder}/config/dev.env",
9+
"skipFiles": [
10+
"<node_internals>/**"
11+
],
12+
"type": "node"
13+
},
414
{
515
"type": "node",
616
"request": "launch",

client/components/CandidateTests/TestPlans/index.jsx

+21-8
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,27 @@ const TestPlans = ({
511511

512512
// Construct testPlanTarget
513513
const testPlanTarget = { id: `${at.id}${browser.id}`, at, browser };
514-
tabularReports[testPlanVersion.id][testPlanTarget.id] =
515-
testPlanReport;
516-
tabularReportsByDirectory[directory][testPlanVersion.id][
517-
testPlanTarget.id
518-
] = testPlanReport;
519-
tabularReportsByDirectory[directory][
520-
testPlanVersion.id
521-
].testPlanVersion = testPlanVersion;
514+
515+
if (!tabularReports[testPlanVersion.id][testPlanTarget.id])
516+
tabularReports[testPlanVersion.id][testPlanTarget.id] =
517+
testPlanReport;
518+
519+
if (
520+
!tabularReportsByDirectory[directory][testPlanVersion.id][
521+
testPlanTarget.id
522+
]
523+
)
524+
tabularReportsByDirectory[directory][testPlanVersion.id][
525+
testPlanTarget.id
526+
] = testPlanReport;
527+
528+
if (
529+
!tabularReportsByDirectory[directory][testPlanVersion.id]
530+
.testPlanVersion
531+
)
532+
tabularReportsByDirectory[directory][
533+
testPlanVersion.id
534+
].testPlanVersion = testPlanVersion;
522535
});
523536

524537
return (

client/components/ManageTestQueue/index.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ const ManageTestQueue = ({
172172
}
173173

174174
setAllTestPlanVersions(allTestPlanVersions);
175-
setFilteredTestPlanVersions(filteredTestPlanVersions);
175+
setFilteredTestPlanVersions(
176+
filteredTestPlanVersions.sort((a, b) =>
177+
a.title < b.title ? -1 : 1
178+
)
179+
);
176180
}, [testPlanVersions]);
177181

178182
useEffect(() => {

client/components/Reports/SummarizeTestPlanReports.jsx

+21-7
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,27 @@ const SummarizeTestPlanReports = ({ testPlanReports }) => {
8989

9090
// Construct testPlanTarget
9191
const testPlanTarget = { id: `${at.id}${browser.id}`, at, browser };
92-
tabularReports[testPlanVersion.id][testPlanTarget.id] = testPlanReport;
93-
tabularReportsByDirectory[directory][testPlanVersion.id][
94-
testPlanTarget.id
95-
] = testPlanReport;
96-
tabularReportsByDirectory[directory][
97-
testPlanVersion.id
98-
].testPlanVersion = testPlanVersion;
92+
93+
if (!tabularReports[testPlanVersion.id][testPlanTarget.id])
94+
tabularReports[testPlanVersion.id][testPlanTarget.id] =
95+
testPlanReport;
96+
97+
if (
98+
!tabularReportsByDirectory[directory][testPlanVersion.id][
99+
testPlanTarget.id
100+
]
101+
)
102+
tabularReportsByDirectory[directory][testPlanVersion.id][
103+
testPlanTarget.id
104+
] = testPlanReport;
105+
106+
if (
107+
!tabularReportsByDirectory[directory][testPlanVersion.id]
108+
.testPlanVersion
109+
)
110+
tabularReportsByDirectory[directory][
111+
testPlanVersion.id
112+
].testPlanVersion = testPlanVersion;
99113
});
100114

101115
const combineObject = originalObject => {

client/components/TestQueueRow/index.jsx

+31-24
Original file line numberDiff line numberDiff line change
@@ -616,31 +616,38 @@ const TestQueueRow = ({
616616
<div className={(isSignedIn && 'secondary-actions') || ''}>
617617
{draftTestPlanRuns.length !== 0 ? (
618618
<ul className="assignees">
619-
{draftTestPlanRuns.map(
620-
({ tester, testResultsLength = 0 }) => (
621-
<li key={nextId()}>
622-
<a
623-
href={
624-
`https://github.com/` +
625-
`${tester.username}`
626-
}
627-
target="_blank"
628-
rel="noopener noreferrer"
629-
// Allows ATs to read the number of
630-
// completed tests when tabbing to this
631-
// link
632-
aria-describedby={getRowId(
633-
tester
634-
)}
635-
>
636-
{tester.username}
637-
</a>
638-
<div id={getRowId(tester)}>
639-
{`${testResultsLength} of ${runnableTestsLength} tests complete`}
640-
</div>
641-
</li>
619+
{draftTestPlanRuns
620+
.slice() // because array was frozen
621+
.sort((a, b) =>
622+
a.tester.username < b.tester.username
623+
? -1
624+
: 1
642625
)
643-
)}
626+
.map(
627+
({ tester, testResultsLength = 0 }) => (
628+
<li key={nextId()}>
629+
<a
630+
href={
631+
`https://github.com/` +
632+
`${tester.username}`
633+
}
634+
target="_blank"
635+
rel="noopener noreferrer"
636+
// Allows ATs to read the number of
637+
// completed tests when tabbing to this
638+
// link
639+
aria-describedby={getRowId(
640+
tester
641+
)}
642+
>
643+
{tester.username}
644+
</a>
645+
<div id={getRowId(tester)}>
646+
{`${testResultsLength} of ${runnableTestsLength} tests complete`}
647+
</div>
648+
</li>
649+
)
650+
)}
644651
</ul>
645652
) : (
646653
<div className="no-assignees">

server/apps/embed.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ const getLatestReportsForPattern = ({ allTestPlanReports, pattern }) => {
161161
const latestReport = group
162162
.sort(
163163
(a, b) =>
164-
new Date(a.testPlanVersion.updatedAt) -
165-
new Date(b.testPlanVersion.updatedAt)
164+
new Date(a.latestAtVersionReleasedAt.releasedAt) -
165+
new Date(b.latestAtVersionReleasedAt.releasedAt)
166166
)
167167
.pop();
168168

server/migrations/20211116172219-commandSequences.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ const { TestPlanVersion } = require('../models');
33
const commandList = require('../resources/commands.json');
44

55
module.exports = {
6-
up: async () => {
6+
up: async queryInterface => {
7+
const [[{ count: testPlanVersionCount }]] =
8+
await queryInterface.sequelize.query(
9+
`SELECT COUNT(*) FROM "TestPlanVersion"`
10+
);
11+
if (!Number(testPlanVersionCount)) return;
12+
713
const testPlanVersions = await TestPlanVersion.findAll({
814
attributes: { exclude: ['testPlanId'] }
915
});

server/migrations/20211118143508-testRowNumber.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ const { omit } = require('lodash');
22
const { TestPlanVersion } = require('../models');
33

44
module.exports = {
5-
up: async () => {
5+
up: async queryInterface => {
6+
const [[{ count: testPlanVersionCount }]] =
7+
await queryInterface.sequelize.query(
8+
`SELECT COUNT(*) FROM "TestPlanVersion"`
9+
);
10+
if (!Number(testPlanVersionCount)) return;
11+
612
const testPlanVersions = await TestPlanVersion.findAll({
713
attributes: { exclude: ['testPlanId'] }
814
});

0 commit comments

Comments
 (0)