Repository navigation
Conversation
…sts` can see it (#5151) Move the assertions of the AnVIL tab, URL, sort and manifest export e2e tests into the test bodies, replace `test.fail()` with assertions, and share tab, table, heading and export card locators from `e2e/features/common/locators.ts`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The AnVIL-CMG end-to-end test refactor has no active review issues.
No open issues 🎉
What changed in this PR
Refactors AnVIL-CMG end-to-end tests so sonarjs/assertions-in-tests can detect assertions, addressing #5151 without changing the lint dependency.
Changes:
- Moves assertions into test bodies and generates tab-specific tests from shared configuration.
- Centralizes locators and improves sort-cell selection and export-checkbox waits.
- Removes obsolete helpers while preserving AnVIL-Catalog support.
| File | Description |
|---|---|
e2e/testReadme.md |
Documents test organization and sort checks. |
e2e/testFunctions.ts |
Removes migrated helpers and adopts shared locators. |
e2e/features/common/locators.ts |
Adds shared card, heading, tab, and cell locators. |
e2e/anvil/common/constants.tsx |
Adds the exact index manifest card title. |
e2e/anvil/anvil-urls.spec.ts |
Generates URL tests with direct assertions. |
e2e/anvil/anvil-tabs-buttons.spec.ts |
Generates navigation tests with direct assertions. |
e2e/anvil/anvil-sort.spec.ts |
Inlines sort assertions and corrects cell indexing. |
e2e/anvil/anvil-index-export-button.spec.ts |
Inlines manifest workflow and waits for checkboxes. |
e2e/anvil/anvil-filter-navigation.spec.ts |
Reuses the shared first-row cell locator. |
e2e/anvil/anvil-dataset.spec.ts |
Reuses shared card and heading locators. |
Review effort: Balanced
frano-m
marked this pull request as ready for review
December 3, 2026 05:35
frano-m
marked this pull request as draft
December 3, 2026 05:35
… in the dataset e2e (#5151) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5151
What changed
The AnVIL tab, URL, sort and file manifest e2e tests now follow the style of the cleaned-up specs, such as
anvil-pagination.spec.ts:test.describeper spec, with short lowercase test namesANVIL_TAB_LISTexpectin the test body, with small helpers at the bottom of the specShared locators now live in
e2e/features/common/locators.ts:getCard,getFirstRowCell,getHeadingWithTextandgetTab.testSortAzulandtestBulkDownloadFileManifestWorkflow, and the helpers only they used, are deleted frome2e/testFunctions.ts.testTab,testUrland the other functions the anvil-catalog specs call stay.Fixes and improvements
Lint and failure reporting
sonarjs/assertions-in-tests(sonarjs 4.2.3) now finds an assertion in all 16 tests. The issue counted 15, butanvil-sort.spec.tshas 5 tests. The old specs get 16 reports.test.fail(): the sort and manifest tests used to fail only throughtest.fail(), which reports nothing useful. They now fail with an assertion error that says what went wrong. For example, a column missing from the tab config failsexpect(unknownColumns).toEqual([])and names the column.Bugs the old tests hid
Files tab sort checked the wrong cell: after each sort, the test checked the first-row cell one column to the left. The column position skipped the unnamed first column, but the cell index did not. It now checks the sorted column's own cell.
Export form checkboxes were never ticked:
makeMinimalExportRequestread the checkboxes withlocator.all(), which doesn't wait. The Organism Type checkboxes render a moment later, so the step that ticks them ran on an empty list and never ran at all. The test now waits for the checkboxes before reading them, so it ticks them as intended.Export table checkboxes could be read too early: the same race applied to the table rows. If they rendered late, the test would throw a bare TypeError, so the test now waits for the first table row first.
Index manifest card matched by a prefix: the test found the card through a substring match on "Download TSV Manifest". That text is the dataset page's card title. The index export page's card is "Download TSV Manifest for All Selected Data Files", so there is now a constant for that title:
TITLE_TEXT_REQUEST_FILE_MANIFEST_SELECTED_DATA.Sort could pass without checking anything: the sort test read the column headers without waiting for the table, so an empty header list could have passed. It now waits for the table's first cell first.
Firefox flake in the dataset manifest test: "displays download file manifest" in
anvil-dataset.spec.tssometimes failed on Firefox, including onmain-based branches. The detail page rewrites its URL to add?list=datasetsafter it loads. A click that lands before that rewrite can be overwritten by it, so the test waited until it timed out.goToDatasetnow waits for the?list=datasetsURL, asanvil-filter-navigation.spec.tsalready does (findable-ui#1271).Vague selectors made precise
[role='tab']text. It matches on text, not accessible name, because the selected tab's tooltip replaces its accessible name with the tab description.MuiPaper-rootancestor plus the.MuiCardActionArea-rootclass.h3:has-text(...), which matches substrings.table-first-celltest ID. It wasrowgroup.nth(1).Less duplication
anvil-dataset.spec.tsnow uses the sharedgetCardandgetHeadingWithTextin place of its own copies.anvil-filter-navigation.spec.tsnow usesgetFirstRowCellin place of its own copy.testFunctions.ts: it now uses the sharedgetTabandgetFirstRowCell, and deletesgetTabByTextandgetFirstRowNthColumnCellLocator.Why
eslint-plugin-sonarjs4 addssonarjs/assertions-in-tests, and it can't see an assertion inside an imported helper or behindtest.fail(). Copies of these tests in repos on sonarjs 4 suppress the rule witheslint-disablecomments, and fixing the tests here lets those copies drop the suppressions. This change is also a step toward retiring the legacye2e/testFunctions.ts.Assumptions I made
testTab,testUrlandtestSortCatalog, which still callstest.fail(). They are left as they are: the anvil-catalog app is slated for deletion, and its catalog-style tests may move to the NCPI repo..bamformat. While I worked, that one manifest's first build failed in the browser with "Failed to fetch" for about 15 minutes, then cleared. Other first-time builds (.cram,.md5) poll and finish normally, with CORS headers on every response. I take it to be a temporary Azul failure, but that is unconfirmed without Azul logs. If it recurs, the test will fail at the "Download Manifest" step.How to verify
Check out the branch and run
npm ci. Then rungrep -n "test.fail" e2e/anvil/*.spec.ts: it prints nothing.Run
npm install --no-save eslint-plugin-sonarjs@4.2.3, thennpx eslint e2e/anvil --rule '{"sonarjs/assertions-in-tests": "error"}': it reports no errors. Runnpm cito restore version 3.Run
npm run test:anvil-cmg: all 132 tests pass. Runnpm run test:anvil-catalog: all 48 pass, which covers the editedtestFunctions.ts.Break one check on purpose and run that spec, for example:
getTabinanvil-urls.spec.ts, oranvil-tabs-buttons.spec.ts.It fails with an assertion error. Revert the change.
Definition of done:
e2e/anvil/usestest.fail()to report a failed check: step 1.sonarjs/assertions-in-tests4.2.3 reports none of the tests, and none has aneslint-disablecomment for it: step 2.Plan
e2e/features/common/locators.ts.anvil-urls.spec.ts, with a loop overANVIL_TAB_LISTand the assertions in the body.anvil-tabs-buttons.spec.ts, keeping the same five tab transitions.anvil-sort.spec.ts, with an assertion in place of theconsole.logandreturn false.anvil-index-export-button.spec.ts.testFunctions.tsno longer uses.e2e/testReadme.md.Deviations
.all(), the exact tab and selector matches, and the new index manifest title constant.anvil-dataset.spec.tsandanvil-filter-navigation.spec.tsswitched to the shared locators.e2e/anvil/common/constants.tsxgained the index manifest title constant.goToDatasetinanvil-dataset.spec.tswaits for the?list=datasetsURL, which fixes a Firefox flake that CI hit.testFunctions.tsuses the shared locators andimport type.🤖 Generated with Claude Code