feat: e2e testing#86
Merged
Merged
Conversation
Add the test harness this repo previously lacked: Vitest 4 (with v8 coverage, jsdom) for unit and integration tests, Playwright for e2e smokes, and a serve dev dependency used to host the static export during e2e runs. Wire up the test, test:watch, test:coverage, test:e2e and serve:out npm scripts, and ignore the Playwright report and result dirs.
Split the WAV/MP3/PCM encoders out of audio_render.tsx into a dependency-free audio_encoders module so they can be unit tested without pulling in Tone or the offline render path, removing the need to widen audio_render's public surface for tests. Introduce one canonical Chord type in src/state/chord.ts and consume it from the store and the export pipeline, replacing the shape that was duplicated inline.
Cover the logic-heavy, pure parts of the app: transposition map invariants, chordsToNoteEvents, the WAV/MP3 encoders, MIDI import and export round-trips, and the store editing actions (add, delete, replace, clear, deep-equal skip, undo and redo). Tone is stubbed where a module loads it eagerly, and shared chord builders live under src/test.
Boot the app and assert the landing page links into the editor, the toolbar renders, and exporting a .chseq file triggers a download. Kept small and resilient: overlays are seeded off via localStorage, and in CI the suite runs against the real static export rather than the dev server.
Add a Tests workflow that runs the Vitest unit tests and the Playwright smokes on push to main and on pull requests. A composite action holds the shared Node 22, npm 11 pin and npm ci setup so the two jobs do not drift, and the e2e job builds the static export, caches the Playwright browser, and builds before installing the browser so failures surface sooner.
CodeQL flagged the workflow for not limiting GITHUB_TOKEN scope. The jobs only check out the repo and run tests, so contents: read is sufficient.
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.
Add a test suite (Vitest + Playwright) and run it in CI
The app had no automated tests. This adds Vitest for the pure logic, Playwright smokes for the core flow, and a CI workflow that runs both on every PR.
What's in it:
vitest,jsdom,@playwright/test,serve, and the matching npm scripts.audio_encoders.ts(so they're testable without mocking Tone) and adds a canonicalChordtype shared by the store, export path, and fixtures.next devlocally and the real static export in CI.Testsworkflow with separateunitande2ejobs sharing a composite setup action; the e2e job builds the export first, caches the browser, and uploads the report.All green locally:
tsc,eslint, Vitest (30/30), Playwright (3/3),npm run build,npm auditclean.