Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all instances of REQUIRED and OPTIONAL #938

Merged
merged 16 commits into from
Mar 20, 2024
Merged

Conversation

Paul-Clue
Copy link
Collaborator

@Paul-Clue Paul-Clue commented Feb 27, 2024

see issue #868

This PR removes all instances of REQUIRED and OPTIONAL. These changes already exist in presentational components. This PR updates the references of those priority names in the code itself to lessen any confusion in the future.


Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paul-Clue thanks for taking this first step to update the repository to be consistent with the new language!

I think the key thing that may be missing here though is that a database migration is needed to update the older TestPlanVersion.tests[].assertions[].priority which still use REQUIRED and OPTIONAL as well.

@@ -1455,7 +1455,7 @@ export class TestRunInputOutput {
output: command.atOutput.value,
assertionResults: command.assertions.map(assertion => ({
assertion: {
priority: assertion.priority === 1 ? 'REQUIRED' : 'OPTIONAL',
priority: assertion.priority === 1 ? 'MUST' : 'SHOULD',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes that happen to files inside client/resources/* should also have an equivalent PR making that change in w3c/aria-at (until we get to optimizing the import process to eliminate this need)

@@ -1642,7 +1642,7 @@ const UnexpectedBehaviorImpactMap = createEnumMap({
/**
* Command result derived from priority 1 and 2 assertions.
*
* Support is "FAILING" is priority 1 assertions fail. Support is "ALL REQUIRED"
* Support is "FAILING" is priority 1 assertions fail. Support is "ALL MUST"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this has to be changed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. If you do change it, make sure to look at server/util/getMetrics.js which still uses the term "All Required." Probably better to just leave it as-is.

@@ -1653,7 +1653,7 @@ const UnexpectedBehaviorImpactMap = createEnumMap({
const CommandSupportJSONMap = createEnumMap({
FULL: 'FULL',
FAILING: 'FAILING',
ALL_REQUIRED: 'ALL REQUIRED',
ALL_REQUIRED: 'ALL MUST',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this, but if it were to change, the enum name may as well be changed too

Copy link
Contributor

@alflennik alflennik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur with Howard that the main missing thing is the migration. Once that's done I'll run the changes and see if I can find any issues. As for the code, it looks good, not much to add to Howard's review.

@@ -8,14 +8,13 @@
* @returns {null|string}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO can be removed now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1642,7 +1642,7 @@ const UnexpectedBehaviorImpactMap = createEnumMap({
/**
* Command result derived from priority 1 and 2 assertions.
*
* Support is "FAILING" is priority 1 assertions fail. Support is "ALL REQUIRED"
* Support is "FAILING" is priority 1 assertions fail. Support is "ALL MUST"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. If you do change it, make sure to look at server/util/getMetrics.js which still uses the term "All Required." Probably better to just leave it as-is.

Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paul-Clue looks good! There's an issue I found with the migration when testing against the current prod data and have suggested an inline fix.

Also, you can remove REQUIRED and OPTIONAL for the AssertionPriority enum in graphql-schema.js

Comment on lines 69 to 78
EXISTS (
SELECT
1
FROM
jsonb_array_elements(tests) AS test,
jsonb_array_elements(test -> 'assertions') AS assertion
WHERE
assertion ->> 'priority' = 'REQUIRED'
OR assertion ->> 'priority' = 'OPTIONAL'
)`,
Copy link
Contributor

@howard-e howard-e Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EXISTS (
SELECT
1
FROM
jsonb_array_elements(tests) AS test,
jsonb_array_elements(test -> 'assertions') AS assertion
WHERE
assertion ->> 'priority' = 'REQUIRED'
OR assertion ->> 'priority' = 'OPTIONAL'
)`,
id = ?`,

The sequelize replacements option is expecting an id replacement which wasn't being used so I assume this must have been the thought. It's much safer to also make this update using the queried id involved in the loop. Using the previous condition could have unexpected behaviors.

*
* @param {number|string} priority
* @returns {null|string}
* @returns {null|string}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns {null|string}
* @returns {null|string}

@alflennik
Copy link
Contributor

@Paul-Clue looks like the tests are failing, any idea about that?

@@ -191,7 +191,7 @@ const getMetrics = ({
assertionsCount: requiredAssertionsCount,
assertionsPassedCount: requiredAssertionsPassedCount,
assertionsFailedCount: requiredAssertionsFailedCount
} = calculateAssertionPriorityCounts(result, 'REQUIRED');
} = calculateAssertionPriorityCounts(result, 'MUST');
Copy link
Contributor

@howard-e howard-e Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with this change, because

`${priority.toLowerCase()}AssertionResults` in scenarioResult;
uses the priority string in combination with what has been named through the client's various queries.js files, it will incorrectly display total values anywhere TestPlanResultsTable is getting used.

ie. queries.js provides requiredAssertionResults but this change to getMetrics is expecting mustAssertionResults.

The following screenshot also shows that for each command, there are 2+ assertions but the command's assertion level status only shows 2 passed, which would then also affect the total calculation for the entire test:
screenshot showing inaccurately calculated numbers

2 things I think could happen here:

  1. Revert the change to getMetrics until updating each of the named (required|optional)AssertionResults instances. But this may cause some confusion until then.
  2. Update the named instances of (required|optional)AssertionResults as appropriate which means renaming the value being exported from getMetrics and also adding a migration to update metrics across all the TestPlanReports

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @howard-e all of the changes have been made and a migration created.

Copy link
Contributor

@howard-e howard-e Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks for going the route of no. 2 as well. Definitely makes things cleaner for the future!

@@ -219,11 +219,11 @@ const getMetrics = ({
testPlanReport?.runnableTests?.length || countTests({ ...result });
const testsFailedCount = testsCount - testsPassedCount;

const requiredFormatted = `${requiredAssertionsPassedCount} of ${requiredAssertionsCount} passed`;
const requiredFormatted = `${mustAssertionsPassedCount} of ${mustAssertionsCount} passed`;
const optionalFormatted =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think requiredFormatted needs to be mustFormatted and optionalFormatted needs to be shouldFormatted, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok done!

@alflennik
Copy link
Contributor

@Paul-Clue fantastic work, I just have one comment. I verified everything else is working and once you address that I'll approve.

Copy link
Contributor

@alflennik alflennik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your considerable persistence chasing down all the details needed to get this task done! 😜

Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to go after fixing my latest inline comment

optionalAssertionResults: assertionResults(
priority: OPTIONAL
) {
mustAssertionResults: assertionResults(priority: SHOULD) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mustAssertionResults: assertionResults(priority: SHOULD) {
shouldAssertionResults: assertionResults(priority: SHOULD) {

Copy link
Collaborator Author

@Paul-Clue Paul-Clue Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Thanks @howard-e!

Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the continued changes to perfect and support this change @Paul-Clue!

@howard-e howard-e merged commit 21a1e1c into main Mar 20, 2024
2 checks passed
@howard-e howard-e deleted the replace-required-and-must branch March 20, 2024 16:49
@ccanash
Copy link
Contributor

ccanash commented Mar 21, 2024

See issue #926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants