test(e2e): add automated end-to-end tests #142
Merged
+1,088
−103
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.
Summary
Adds automated end-to-end tests, which the assignment asks for ("a form of automated end-to-end testing, in practice a longer sequence of interactions, and testing of the API"). Until now the repository had component tests (Vitest) and API tests in
backend/, but nothing that drives the whole application in a real browser.This pull request is built on #135 (the filters and the sort of the Elements page) and targets
dev. The tests exercise what #135 adds (the filters, the sort, the vault bands, the page titles andApparatus.difficultyValues), so the commits of #135 are in this branch too: until #135 is merged, the diff of this pull request also shows them. The end-to-end changes are the last 5 commits (git log origin/dev..lists them) and the files ine2e/,playwright.config.ts,tsconfig.e2e.json,package.json,package-lock.json,.gitignoreand the docs. Merge #135 first; this pull request then shows only the end-to-end tests.What is in it
@playwright/test) with the official axe-core integration.npm run e2eruns the tests, andnpm run e2e:reportopens the report with a screenshot and a trace of what failed. The tests are ine2e/and end in.e2e.ts, so Vitest does not pick them up.E2E_BASE_URL=http://it2810-XX.idi.ntnu.no/project2nothing is started and the same tests check the virtual machine, including the Apache proxy of/project2/graphql. Ports, browser and API address are environment variables (see the README).e2e/elements-flow.e2e.ts: one long flow: search, filter by apparatus, "Load more", sort, filter by group, open an element, go back, "Clear filters". It checks the address, the results, the title and the focus at each step.e2e/vault.e2e.ts: the vault difficulty bands (the two bands together are the two bands apart) and sorting vault by its D-score in both directions.e2e/atypical.e2e.ts: atypical use: an address with filters that do not exist, a group of another apparatus, a search without a result, the 80-character limit, a structure that fails to load (the request is made to fail), the disabled group filter, and keyboard-only use.e2e/accessibility.e2e.ts: axe-core (WCAG 2.0, 2.1 and 2.2 A and AA) on the page filtered and sorted, with a filter or sort menu open, with the reason for a disabled filter shown, vault, no result, dark mode and a phone, plus reflow at 320 px and the size of the touch targets. A violation fails the test.e2e/api.e2e.ts: the API over HTTP: search is case insensitive, filtering and sorting over the whole result, cursor pages without skipping or repeating, vault filtered on the D-score,Apparatus.difficultyValues, theBAD_USER_INPUTcases,GRAPHQL_VALIDATION_FAILEDandUNAUTHENTICATED. The detailed API tests stay inbackend/.tsconfig.e2e.jsonis part oftsc -b, so the tests are type-checked. The README has a new section "End-to-end tests" (what each file tests, how to run, the settings, and the choices and limits), anddocs/AI_USAGE.mddescribes how AI was used.Choices
devDependenciesand are not in the bundle.Testing
npx playwright install chromium, the way the README says) and with Edge (E2E_CHANNEL=msedge).aria-disabled, the title removed): a test failed each time.expectSearchpolls the address, and the vault test compares totals).tsc -b(which now includese2e/; a deliberate type error was caught),eslint .,npm run buildand the 442 Vitest tests pass, and Vitest lists no file ine2e/.E2E_BASE_URL=http://it2810-XX.idi.ntnu.no/project2 npm run e2ethere once the backend is updated (the page needsApparatus.difficultyValuesfrom feat: connect the filters and the sort on the Elements page #135).Closes #139
🤖 Generated with Claude Code