test(e2e): move game reset to fixture, extract play-word flow helper#2
Merged
Conversation
Address two findings from the UI/E2E test guidance audit: - Move the per-test game reset (goto, localStorage.clear, reload) out of the inline beforeEach and into an auto Playwright fixture (freshGame) via test.extend, so lifecycle setup is injected per test rather than re-implemented in the spec. - Extract the duplicated per-word play loop (used for "all fourtiles" and "all words") into a layered flow helper: playWord (single action) and playWords (flow), composed from the existing GameBoardPage primitives and synchronizing with web-first assertions only. The thin star and found-words page objects are left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Addresses two findings from the UI/E2E test guidance audit on
e2e/gameplay.spec.ts, applying the Playwright structure conventions (fixtures own lifecycle; helpers own actions; web-first assertions; layered helpers).Finding 1 — reset belongs in a fixture (addressed)
The
beforeEachclearedlocalStorageand reloaded to reset the game inline. That per-test reset is now an auto Playwright fixturefreshGameine2e/fixtures.ts(test.extend,{ auto: true }), injected per test. The spec'sbeforeEachnow only readswordsRemaining.Finding 2 — duplicated play loop (addressed)
The per-word play loop was duplicated across the "all fourtiles" and "all words" blocks. Extracted into layered flow helpers in
e2e/game-helpers.ts:playWord— a single user action (resolve tiles for a word, tap, submit, wait for the current-word display to clear), composed from the existingGameBoardPageprimitives (clickTiles,clickAdd).playWords— a flow that plays a list of words in order.Helpers only assert for synchronization (
expect(...).toHaveText(''), web-first, nowaitForTimeout); feature assertions stay in the specs. The 10s clear timeout used by the long "all words" run is passed through as an option.Intentionally not churned
The thin
FourtileStarsPanel/FoundWordsPanelpage objects were left as-is, per the audit note.Verification
pnpm type-check(vue-tsc): passpnpm lint(eslint + stylelint + oxlint + knip): pass; knip reports no unused exportspnpm test:unit(vitest): 6/6 passnpx playwright test --list: specs compile (39 tests)npx playwright test(full run, chromium + firefox + webkit): 39/39 pass🤖 Generated with Claude Code