Skip to content

Commit

Permalink
feat: Display AT Version for finalized reports when TestPlanVersion i…
Browse files Browse the repository at this point in the history
…s RECOMMENDED (#1052)

* 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

* Support primary test plan to be selected

* Fix test

* Add resolver for finding firstRequiredAtVersion for a RECOMMENDED TestPlanVersion, given an atId

* Add dialog when marking report as final for an admin to select from probably primary test run options

* prioritised -> prioritized typo (british -> american english)

* Update tests

* Track recommended AT version

* Avoid displaying primary test plan run confirmation when just 1 run option

* Fix graphql call when including "firstRequiredAtVersion" under "testPlanVersions"

* Update description of firstRequiredAtVersion

* Add atVersion frontend

* Make sure automation dialog always shows when valid

* Rename resolver

* Make sure existing reports have a minimum at version

* Formatting

* Fix graphql calls when doing testPlanReports > recommendedAtVersion

* feat: Add resolver for tracking first required AT Version (#1051) Address #792

* Add resolver for finding firstRequiredAtVersion for a RECOMMENDED TestPlanVersion, given an atId

* Update tests

* Fix graphql call when including "firstRequiredAtVersion" under "testPlanVersions"

* Update description of firstRequiredAtVersion

* Rename resolver

* Use exactAtVersionId if available for recommendedAtVersion

* Update comment

---------

Co-authored-by: alflennik <[email protected]>
  • Loading branch information
howard-e and alflennik authored May 8, 2024
1 parent 3e38be7 commit 19900a4
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 23 deletions.
14 changes: 7 additions & 7 deletions client/components/CandidateReview/TestPlans/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ const TestPlans = ({ testPlanVersions }) => {
to={`/candidate-test-plan/${testPlanVersion.id}/${atId}`}
>
{getTestPlanVersionTitle(
testPlanVersion
testPlanVersion,
{
includeVersionString: true
}
)}{' '}
{
testPlanVersion.versionString
}{' '}
({testsCount} Test
{testsCount === 0 ||
testsCount > 1
Expand Down Expand Up @@ -755,9 +755,9 @@ const TestPlans = ({ testPlanVersions }) => {
<tr key={testPlanVersion.id}>
<td>
{getTestPlanVersionTitle(
testPlanVersion
)}{' '}
{testPlanVersion.versionString}
testPlanVersion,
{ includeVersionString: true }
)}
</td>
<CenteredTd>
{jawsDataExists
Expand Down
5 changes: 3 additions & 2 deletions client/components/Reports/SummarizeTestPlanReport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ const SummarizeTestPlanReport = ({ testPlanVersion, testPlanReports }) => {
);
if (!testPlanReport) return <Navigate to="/404" />;

const { at, browser } = testPlanReport;
const { at, browser, recommendedAtVersion } = testPlanReport;

// Construct testPlanTarget
const testPlanTarget = {
id: `${at.id}${browser.id}`,
at,
browser
browser,
atVersion: recommendedAtVersion
};

return (
Expand Down
5 changes: 3 additions & 2 deletions client/components/Reports/SummarizeTestPlanVersion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ const SummarizeTestPlanVersion = ({ testPlanVersion, testPlanReports }) => {
if (testPlanReport.status === 'DRAFT') return null;
const overallMetrics = getMetrics({ testPlanReport });

const { at, browser } = testPlanReport;
const { at, browser, recommendedAtVersion } = testPlanReport;

// Construct testPlanTarget
const testPlanTarget = {
id: `${at.id}${browser.id}`,
at,
browser
browser,
atVersion: recommendedAtVersion
};

return (
Expand Down
19 changes: 11 additions & 8 deletions client/components/Reports/getTitles.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const getTestPlanVersionTitle = testPlanVersion => {
return testPlanVersion.title || `"${testPlanVersion.testPlan.directory}"`;
const getTestPlanVersionTitle = (
testPlanVersion,
{ includeVersionString = false } = {}
) => {
let title = testPlanVersion.title || testPlanVersion.testPlan?.directory;
if (includeVersionString && testPlanVersion.versionString)
title = `${title} ${testPlanVersion.versionString}`;
return title;
};

// const getTestPlanTargetTitle = ({ browser, browserVersion, at, atVersion }) => {
// return `${at.name} ${atVersion} and ${browser.name} ${browserVersion}`;
// };

const getTestPlanTargetTitle = ({ browser, at }) => {
return `${at.name} and ${browser.name}`;
const getTestPlanTargetTitle = ({ at, browser, atVersion }) => {
if (!atVersion) return `${at.name} and ${browser.name}`;
return `${at.name} ${atVersion.name} and ${browser.name}`;
};

export { getTestPlanTargetTitle, getTestPlanVersionTitle };
4 changes: 4 additions & 0 deletions client/components/Reports/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export const REPORT_PAGE_QUERY = gql`
id
name
}
recommendedAtVersion {
id
name
}
runnableTests {
id
title
Expand Down
9 changes: 9 additions & 0 deletions server/graphql-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,15 @@ const graphqlSchema = gql`
Indicated by TestPlanReport.markedFinalAt existence, after a report has been "marked as final".
"""
isFinal: Boolean!
"""
The AtVersion to display for a TestPlanReport only when the
TestPlanVersion is RECOMMENDED.
If this TestPlanReport was created with an "exactAtVersionId" being set,
it will use the matching AtVersion, otherwise it will use the
TestPlanVersion.earliestAtVersion as a default.
"""
recommendedAtVersion: AtVersion
}
"""
Expand Down
8 changes: 8 additions & 0 deletions server/models/services/AtService.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ const removeAtVersionById = async ({ id, truncate = false, transaction }) => {
});
};

/**
* Returns all the unique AT Versions used when collecting results from testers
* for a Test Plan Report
* @param {number} testPlanReportId - id of the test plan report
* @param {object} options
* @param {*} options.transaction - Sequelize transaction
* @returns {Promise<*>}
*/
const getUniqueAtVersionsForReport = async (
testPlanReportId,
{ transaction }
Expand Down
2 changes: 2 additions & 0 deletions server/resolvers/TestPlanReport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const atVersions = require('./atVersionsResolver');
const at = require('./atResolver');
const browser = require('./browserResolver');
const latestAtVersionReleasedAt = require('./latestAtVersionReleasedAtResolver');
const recommendedAtVersion = require('./recommendedAtVersionResolver');
const isFinal = require('./isFinalResolver');
const exactAtVersion = require('./exactAtVersionResolver');
const minimumAtVersion = require('./minimumAtVersionResolver');
Expand All @@ -27,5 +28,6 @@ module.exports = {
minimumAtVersion,
browser,
latestAtVersionReleasedAt,
recommendedAtVersion,
isFinal
};
45 changes: 45 additions & 0 deletions server/resolvers/TestPlanReport/recommendedAtVersionResolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { getAtVersionById } = require('../../models/services/AtService');
const {
getTestPlanVersionById
} = require('../../models/services/TestPlanVersionService');
const earliestAtVersionResolver = require('../TestPlanVersion/earliestAtVersionResolver');

const recommendedAtVersionResolver = async (testPlanReport, _, context) => {
const { transaction } = context;

let testPlanVersion;
if (testPlanReport.testPlanVersion) {
testPlanVersion = testPlanReport.testPlanVersion;
} else {
testPlanVersion = await getTestPlanVersionById({
id: testPlanReport.testPlanVersionId,
testPlanVersionAttributes: ['id', 'phase'],
testPlanReportAttributes: [],
testPlanRunAttributes: [],
atAttributes: [],
browserAttributes: [],
userAttributes: [],
transaction
});
}
const phase = testPlanVersion.phase;

if (!testPlanReport.markedFinalAt || phase !== 'RECOMMENDED') return null;

// If report was created with exact version being required, display that
if (testPlanReport.exactAtVersionId) {
return getAtVersionById({
id: testPlanReport.exactAtVersionId,
transaction
});
}

// Otherwise return the earliest At version used to record results
return earliestAtVersionResolver(
testPlanVersion,
{ atId: testPlanReport.atId },
context
);
};

module.exports = recommendedAtVersionResolver;
4 changes: 4 additions & 0 deletions server/resolvers/helpers/deriveAttributesFromCustomField.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const deriveAttributesFromCustomField = (fieldName, customFields) => {
if (fields.includes('testPlanVersion'))
derived.push('testPlanVersionId');
if (fields.includes('isFinal')) derived.push('markedFinalAt');
if (fields.includes('recommendedAtVersion')) {
derived.push('testPlanVersionId');
derived.push('markedFinalAt');
}
break;
}
case 'draftTestPlanRuns': {
Expand Down
14 changes: 10 additions & 4 deletions server/tests/integration/graphql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ describe('graphql', () => {
recommendedTestPlanVersion: testPlanVersion(id: 69) {
__typename
id
testPlanReports {
__typename
id
recommendedAtVersion {
__typename
id
name
releasedAt
}
}
earliestAtVersion(atId: 1) {
id
name
Expand Down Expand Up @@ -1006,7 +1016,3 @@ const getMutationInputs = async () => {
browserVersionId: browserVersion.id
};
};

/* Add the phrase to the assertion query. It will not work unless phrase is returned.
Find a test plan version that does have a phrase (V2).
*/

0 comments on commit 19900a4

Please sign in to comment.