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

Support v2 Test Format in import script and page changes #840

Merged
merged 59 commits into from
Dec 5, 2023

Conversation

howard-e
Copy link
Contributor

@howard-e howard-e commented Nov 13, 2023

This PR updates the import-tests script to account for TestPlanVersions which follow the v2 Test Format which exist in aria-at.

This PR also updates several pages to account for a V2 Test Format TestPlanVersion moving through the app.

How To Run:

yarn sequelize:test db:migrate
yarn db-import-tests:dev;
yarn run dev-debug;

Reviewers, note that changes inside client/resources are not expected to be reviewed in this PR but they are required files, copied over from w3c/aria-at. These changes specifically are included in w3c/aria-at#997 and can be reviewed there.

Dependent PRs to be merged

@howard-e howard-e changed the title WIP: Support v2 Test Format Import WIP: Support v2 Test Format Import and page changes Nov 16, 2023
assertionsCount: requiredAssertionsCount,
assertionsPassedCount: requiredAssertionsPassedCount,
assertionsFailedCount: requiredAssertionsFailedCount
} = calculateAssertionPriorityCounts(result, 'REQUIRED');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reviewers: A follow up task to replace instances of REQUIRED and OPTIONAL could follow this PR landing for consistency. I'd rather not inflate this PR further.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this decision. The stopgap solution is clean and will be easy to update later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, thanks for highlighting that intention. I agree that we need to update the system to make sure it's using the latest terminology, but I understand why doing it separately is better.

@@ -92,8 +98,30 @@ const saveTestResultCommon = async ({

await updateTestPlanRun(testPlanRun.id, { testResults: newTestResults });

// TODO: Avoid blocking loads in test runs with a larger amount of tests
// and/or test results
if (isSubmit) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this block to address an easily reproducible process breakage where the metrics of a TestPlanReport could fail to be tracked.

Scenario:

  1. Tester is assigned to a Test Run on Test Queue
  2. They go through the tests for the assigned run in their Test Run page, submitting results along the way
  3. Returns to the Test Queue page
  4. Reselects their assigned Test Run
  5. Selects "Edit Results"
  6. Makes a change to the test assertion that's collected or unexpected behaviors
  7. Selects "Submit Results" (they never navigated to another test in the Test Run)

The expectation is that the metrics would be recalculated in the instance of a "Success case" going to a "Failure case". But this doesn't happen. It seems the metrics were only being recorded on test transition within the test run. This change makes sure it is also done when those results are submitted.

@@ -12,14 +12,18 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

CREATE OR REPLACE FUNCTION get_test_plan_version_id(testPlanVersionTitle text) RETURNS integer
CREATE OR REPLACE FUNCTION get_test_plan_version_id(testPlanVersionTitle text, testFormatNumber text) RETURNS integer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To eventually make this .sql sufficiently test for v2 test cases

@howard-e howard-e marked this pull request as ready for review November 16, 2023 22:37
@howard-e
Copy link
Contributor Author

howard-e commented Nov 16, 2023

I'm unable to reproduce these test failures locally. Will check out why this is. The fix would also apply to #843 and #845.

@howard-e howard-e changed the title WIP: Support v2 Test Format Import and page changes Support v2 Test Format in import script and page changes Nov 16, 2023
Copy link
Contributor

@stalgiag stalgiag left a comment

Choose a reason for hiding this comment

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

LGTM! I left a couple of small, optional changes and points of discussion in-line.

Thanks for this work!

assertionsCount: requiredAssertionsCount,
assertionsPassedCount: requiredAssertionsPassedCount,
assertionsFailedCount: requiredAssertionsFailedCount
} = calculateAssertionPriorityCounts(result, 'REQUIRED');
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this decision. The stopgap solution is clean and will be easy to update later.

config/test.env Show resolved Hide resolved
server/resolvers/TestPlanVersion/testsResolver.js Outdated Show resolved Hide resolved
server/scripts/import-tests/index.js Show resolved Hide resolved
server/scripts/import-tests/index.js Outdated Show resolved Hide resolved
server/scripts/import-tests/index.js Outdated Show resolved Hide resolved
server/tests/integration/testPlanRun.test.js Show resolved Hide resolved
server/util/getMetrics.js Show resolved Hide resolved
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.

After spending quite a lot of time wondering what adding support for the V2 format would look like (and failing to figure out a clear direction I might add) it's quite interesting to see the move you found to get this done. I do have comments of course but first I should say how relieved and appreciative I am that you were able to figure out a way to accomplish this task, which certainly confounded me.

assertionsCount: requiredAssertionsCount,
assertionsPassedCount: requiredAssertionsPassedCount,
assertionsFailedCount: requiredAssertionsFailedCount
} = calculateAssertionPriorityCounts(result, 'REQUIRED');
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, thanks for highlighting that intention. I agree that we need to update the system to make sure it's using the latest terminology, but I understand why doing it separately is better.

server/scripts/import-tests/index.js Outdated Show resolved Hide resolved
JSON.stringify(flattenObject(commandsV2Parsed), null, 4)
);
} catch (error) {
console.error("commands.json for v2 test format doesn't exist");
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this might not always be the appropriate error to show for all the potential error states in the try block. Maybe we can keep this message, rewording it slightly to be like "commands.json for v2 test format may not exist" but also throw the error to make sure it's shown to developers in the case the JSON.parse fails due to invalid JSON or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can keep this message, rewording it slightly to be like "commands.json for v2 test format may not exist"

Agreed

throw the error to make sure it's shown to developers

That means this block would also crash out when there's a manually imported commit before that v2 test format specific file existed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 74a6f1a

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, thanks for addressing that part of it! I'm cool with not throwing the error. But how about, instead, adding a second console.error with the actual error?

@@ -15,6 +15,10 @@ const {
getTestPlans,
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry in advance for such a hand-wavy comment, but I would say, especially in comparison to other files in this PR, the cleanliness of this file seems to have been quite negatively impacted by adding support for v2. In other places you've done a pretty clean structure like this:

let variable
if (testFormatVersion === 1) {
  variable = "something"
} else {
  variable = "something else"
}

However in this file it seems like the complexity is spread evenly around the file. I suppose that shouldn't be surprising given the fact that this file is the most exposed to the test format differences, but I wonder if utilizing blocks like the above might be possible.

This also resonates with Staglia's comment elsewhere that it feels like a third test format version would require extensive changes to this file. Maybe we're talking about something similar.

Hopefully that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a specific section to point out? The majority of the v1 vs v2 complexity is now included in func:createTestsForFormat following Stalgia's comment.

Some of the existing functions were renamed and to extend support of what they were originally doing. But I can add additional clarifying comments which attributes have been added.

The reason that binary logic can't happen further up is because of when the v2 evaluation for an example's folder has to happen.

atIds: [
ats.find(at => at.name === collected.target.at.name).id
],
renderableContent: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the point of renderableContent was to faithfully preserve the collected.json file content. It seems like computing all this renderableContent is producing a confusing situation where it's no longer predictable what content that field contains. I made a comment in one of your other PRs that I thought it made sense to add a testFormatVersion field to the renderableContent and then allowing the differences in the test format to be faithfully expressed within that section. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a comment in one of your other PRs that I thought it made sense to add a testFormatVersion field to the renderableContent and then allowing the differences in the test format to be faithfully expressed within that section. What do you think?

To me, that then puts work on a resolver (or some other server op) to evaluate some change in the renderableContent based on that testFormatVersion. I'm not against it, but I am a bit lost, on why add to each test.renderableContent rather than referencing the parent TestPlanVersion.metadata.

renderableContent was to faithfully preserve the collected.json file content

A big thing about this change was also maintaining the already existing structure of renderableContent to avoid unnecessary hiccups and maintaining that control. But the majority of renderableContent is the same as the collected file, and could have been collected or { ...collected, extras } really. Outside of excluding target.ats which the new collected.json would have, and also making changes to assertions to use tokenized assertionStatements where needed, it is exactly the same.

I can make a change to reflect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renderableContent was to faithfully preserve the collected.json file content

A big thing about this change was also maintaining the already existing structure of renderableContent to avoid unnecessary hiccups and maintaining that control. But the majority of renderableContent is the same as the collected file, and could have been collected or { ...collected, extras } really. Outside of excluding target.ats which the new collected.json would have, and also making changes to assertions to use tokenized assertionStatements where needed, it is exactly the same.

I can make a change to reflect that.

Addressed in ced6354. I limited what's being redefined into v2's renderableContent and also created a RenderableContent typedef to better understand the content structure for future maintenance

});
});
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify what these fields will contain? I wasn't able to gather it just reading the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's described by v2 test format#settings. And that "seeder" comes from each at.settings under ats.

@@ -0,0 +1,123 @@
const commands = require('../../resources/commands.json');
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to rename commands to commandsV1? Otherwise it might give the impression that V1 is more authoritative or "normal" than V2 is, when V2 is actually the new standard going forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I can make that change!

Copy link
Contributor Author

@howard-e howard-e Nov 27, 2023

Choose a reason for hiding this comment

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

So after looking into this, it does inflate the PR a bit beyond it's purpose. Like my comment in #840 (comment), I'd rather to make this change in a follow up PR.

server/graphql-schema.js Show resolved Hide resolved
// MODE.READING,
// MODE.INTERACTION,
// MODE.MODELESS
// ),
defaultValue: MODE.MODELESS,
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought I saw references somewhere that implied VoiceOver's quick nav was akin to a mode switcher, like I think I saw some "mode instructions" for VoiceOver that say to turn quick nav off ... but it sounds like we're still treating VoiceOver as modeless? I was wondering if you could bring me up to speed on what we decided about that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought I saw references somewhere that implied VoiceOver's quick nav was akin to a mode switcher

I'm not too sure on that statement.

I was wondering if you could bring me up to speed on what we decided about that?

VO can have a 'quick nav on' mode, 'quick nav off' mode and any AT could technically support a modeless state (but right now, only VO's v2 tests show any examples of that).

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.

Fantastic work getting this implemented Howard! Intense changes but great stuff.

howard-e and others added 7 commits November 29, 2023 12:25
Update Test Runner for V2 Test Format
Update Reports for V2 Test Format
# Conflicts:
#	client/components/CandidateReview/CandidateTestPlanRun/InstructionsRenderer.jsx
Passed/failed for assertion results in TestRenderer and migrate to pass/fail for report comparison algorithms
@howard-e howard-e merged commit 6962cef into main Dec 5, 2023
2 checks passed
@howard-e howard-e deleted the support-v2-test-format branch December 5, 2023 20:36
stalgiag added a commit that referenced this pull request Dec 14, 2023
commit fbf8eef
Author: Stalgia Grigg <[email protected]>
Date:   Thu Dec 14 14:46:48 2023 -0800

    Clean up leftover import

commit 15c594a
Merge: 9c99b4f 56205a3
Author: Stalgia Grigg <[email protected]>
Date:   Thu Dec 14 14:29:54 2023 -0800

    Merge branch 'main' into automation-mvp-merged

commit 9c99b4f
Author: Stalgia Grigg <[email protected]>
Date:   Thu Dec 14 14:20:15 2023 -0800

    Remove aria-at git commit cut off date

commit 56205a3
Author: Howard Edwards <[email protected]>
Date:   Thu Dec 14 11:44:34 2023 -0500

    Update tests (mock data and FilterButtons.test.jsx) and formatting of frontend components (#867)

commit d63609d
Author: Stalgia Grigg <[email protected]>
Date:   Wed Dec 13 16:16:26 2023 -0800

    Fixes after merge

commit 8ff6e6b
Merge: 2e62661 8215cb9
Author: Stalgia Grigg <[email protected]>
Date:   Wed Dec 13 15:03:10 2023 -0800

    Merge branch 'main' into automation-mvp-rebase-attempt

commit 8215cb9
Author: Stalgia Grigg <[email protected]>
Date:   Tue Dec 12 07:59:44 2023 -0800

    Trap backwards navigation from initial focus on header in focus-trapped modals (#851)

    * Add unit test for reverse navigation from initial focused header, FocusTrapper

    * Update unit tests for FocusTrapper, handle backwards navigation from initially focused header

    * Handle focus leaving non-focusable header element backwards in FocusTrapper

commit 918acdd
Author: Alexander Flenniken <[email protected]>
Date:   Mon Dec 11 17:20:55 2023 -0500

    Allow candidate test plans to advance with override (#832)

    * Allow candidate test plans to advance

    * Implement PR feedback

commit 135e61b
Author: Alexander Flenniken <[email protected]>
Date:   Mon Dec 11 16:59:00 2023 -0500

    Polish test review v2 page (#861)

    * Polish test review v2 page

    * Remove unused variable

commit 234a339
Author: Alexander Flenniken <[email protected]>
Date:   Thu Dec 7 14:57:42 2023 -0500

    Update CONTRIBUTING.md (#859)

commit 460b29c
Author: alflennik <[email protected]>
Date:   Thu Dec 7 13:26:17 2023 -0500

    Update contributing.md

commit 457caea
Author: Howard Edwards <[email protected]>
Date:   Tue Dec 5 16:04:23 2023 -0500

    Check for v2 testFormatVersion where applicable and hide link (#855)

commit 6962cef
Author: Howard Edwards <[email protected]>
Date:   Tue Dec 5 15:36:41 2023 -0500

    Support v2 Test Format in import script and page changes (#840)

    * Update client/resources

    * Update import script to support v2 test format import

    * Update import script to include flattened commandsV2.json and add uniquely generated scenario and assertion IDs

    * Updating client and server files to support V2 test format

    * Remove console.log and add TODO

    * Include tokenized assertionStatement in TestPlanVersion.tests[x].assertions

    * Add retrieveCommands utility

    * Update candidate review and datamanagement page

    * Update Reports/queries to also include mayOptionalAssertionResults

    * Add support for AtMode and and referencing appropriate screen text in testsResolver

    * Remove console log

    * Fix edge case issue when saving test result and add priority standardizing utility

    * Add assertions checks for may assertions

    * Update getMetrics utils

    * Update test-import to account for single {at}-focused .collected file

    * Address file error

    * Fix tests

    * Update import branch

    * Fix edge case crash when viewing CandidateTestPlanRun

    * Update tests and prepare support for testing v2 format test plan versions

    * Update tests

    * Update workflow

    * Clarifying comment

    * Update runtest.yml to exclude v2 test format import

    * Update server/resolvers/TestPlanVersion/testsResolver.js

    Remove unnecessary `at.settings` check

    Co-authored-by: Stalgia Grigg <[email protected]>

    * Clearer differences between v1 and v2 test format tests being imported

    * Include typedef for RenderableContent

    * Update thrown error message when missing commands.json (v2)

    * Additional check for flattenObject

    * Fix bug found after rebase and update jsdoc on 'retrieveAttributes'

    * Updating Test Run page to support #743

    * Update Test Run page instructions for v2 test format

    * Add react-html-parser; update InstructionsRenderer

    * Use testPlanVersion.metadata.testFormatVersion

    * Stop defaulting testFormatVersion to 1

    * Stop using NumberedList

    * Update client/components/TestRenderer/utils.js

    Co-authored-by: Stalgia Grigg <[email protected]>

    * Define instructions variables

    * Prepend tests with 'Test {number}' on reports page

    * Address CG comments

    * Address PR feedback

    * Consistency

    * Passed/failed for assertion results in TestRenderer

    * Update test plan report conflict calculation to support pass/fail assertion results

    * Correct assertion legend, margin right for checkbox

    * Update inline snapshot for test queue

    * Remove failedReason

    * Update server/resolvers/TestResultOperations/saveTestResultCommon.js

    Co-authored-by: Howard Edwards <[email protected]>

    * Fix linting issue in saveTestResultCommon

    * Undo change to checkAssertionResult

    * Consistency

    * Do radio group and supporting docs

    * Revert "Do radio group and supporting docs"

    This reverts commit 579f545.

    * Revert aria-at import branch

    ---------

    Co-authored-by: Paul Clue <[email protected]>
    Co-authored-by: Stalgia Grigg <[email protected]>

commit 703b01f
Author: jugglinmike <[email protected]>
Date:   Tue Dec 5 12:25:21 2023 -0500

    Do not render zeros in place of omitted content (#852)

    By relying on the "truthiness" of Number values to short-circuit boolean
    expressions, some rendering logic produced the text "0" instead of
    omitting any markup at all.

    Replace the expressions whose value could be coerced to booleans with
    expressions which directly evaluate to "fallback" values that do not
    produce markup (i.e. `false` or an empty array).

commit 7783342
Author: Stalgia Grigg <[email protected]>
Date:   Mon Dec 4 15:34:10 2023 -0800

    Revert "Handle focus leaving non-focusable header element backwards in FocusTrapper"

    This reverts commit 57012cb.

commit 57012cb
Author: Stalgia Grigg <[email protected]>
Date:   Mon Dec 4 14:05:57 2023 -0800

    Handle focus leaving non-focusable header element backwards in FocusTrapper

commit 477abcb
Author: Howard Edwards <[email protected]>
Date:   Wed Nov 29 10:10:10 2023 -0500

    Remove additional css meant for now removed 'skipped' view (#848)

commit dba7f40
Author: Alexander Flenniken <[email protected]>
Date:   Tue Nov 28 14:37:24 2023 -0500

    Implement Test Review in React (#846)

    * Implement client-side version of test-review

    * PR polish

    * Add additional specification features

    * Additional minor polish

    * PR feedback

commit b98852b
Author: Paul Clue <[email protected]>
Date:   Wed Nov 22 15:48:57 2023 -0500

    No longer mark test plan reports with skipped tests as final (#833)

    * Hide mark as final button

    * No mark as final for skipped tests in graphql

    * Remove skipped tests from the UI

    * Add migration for unfinished tests

    * Simplify necessary files

    * Fix failing tests

    * Add code review fixes

    * Remove no-longer-necessary style class

    * Remove reference

commit c29bea9
Merge: c101ecc c1bf56a
Author: Stalgia Grigg <[email protected]>
Date:   Tue Nov 21 09:41:04 2023 -0800

    Merge pull request #844 from w3c/fix-at-selection-dropdown

    Fix Data management page crash when Adding Test Plans to the Test Queue and Opening Assistive Technology select to pick any option

commit c101ecc
Merge: 878fe80 50cd6c8
Author: Stalgia Grigg <[email protected]>
Date:   Tue Nov 21 09:40:43 2023 -0800

    Merge pull request #837 from w3c/accessible-name-test-plan-report-status-dialog

    Fix aria-labeledby for BasicModal/BasicThemedModal

commit 878fe80
Author: Paul Clue <[email protected]>
Date:   Mon Nov 20 15:08:58 2023 -0500

    Fix empty version strings on Data Management and Test Queue pages (#839)

    * Add versionString to mutation

    * Remove comments

    * Fix similar issue happening on the Test Queue page when assigning and removing testers and also removing test results

    ---------

    Co-authored-by: Howard Edwards <[email protected]>

commit a5f0e80
Author: Alexander Flenniken <[email protected]>
Date:   Mon Nov 20 15:01:45 2023 -0500

    Implement target date modal improvements (#835)

    * Implement target date modal improvements

    * Add esc support to target date modal

commit c1bf56a
Author: Stalgia Grigg <[email protected]>
Date:   Thu Nov 16 11:29:56 2023 -0800

    Update DataManagement test mock

commit 9319e37
Author: Stalgia Grigg <[email protected]>
Date:   Thu Nov 16 11:16:37 2023 -0800

    Remove browsers from query and state in TestQueue and DataManagement in favor of at.browsers

commit 7dd31e1
Author: Stalgia Grigg <[email protected]>
Date:   Thu Nov 16 11:07:46 2023 -0800

    Fix bug that causes crash on DataManagement page ManageTestQueue AT dropdown

commit 50cd6c8
Author: Stalgia Grigg <[email protected]>
Date:   Wed Nov 8 16:01:23 2023 -0800

    Unit test for aria-labeledby on BasicModal

commit c1e7f0f
Author: Stalgia Grigg <[email protected]>
Date:   Wed Nov 8 15:42:55 2023 -0800

    Fix aria-labeledby in both BasicModal and BasicThemedModal
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