Commit 16edfe7
committed
test(web): extract shared test helpers for the three page tests
Adds apps/web/__tests__/helpers/test-utils.ts exporting reusable
factories and a small UI helper:
- mockCreatorProfile / defaultCreatorProfile
- mockPlaylist / defaultPlaylist / mockMyPlaylistsList (envelope) /
mockPlaylistEnvelope (envelope)
- defaultFanProfile / defaultMeUser / mockMeResponse
- defaultAuth (preserves explicit null via in-checks)
- openCreateForm (UI helper)
Rewrites consume from helpers:
- creator-profile-page.test.tsx (12 tests, unchanged from previous commit)
- playlists-page.test.tsx (12 tests)
- edit-profile-page.test.tsx (10 tests)
Bug fixes that fell out of the rewrite:
- playlists-page mock module was exporting getMyPlaylists, but the
page imports listMyPlaylists — rename to listMyPlaylists resolves
"Failed to load playlists" on every data-load test.
- mockCreatePlaylist now returns mockPlaylistEnvelope(...) to match
the { data: PlaylistResponse } shape createPlaylist produces.
- Edit-profile Loading test typed Promise<void> resolving undefined,
which made the page access state.data.user on undefined. Now
Promise<MeResponse> resolved with mockMeResponse().
- Edit-profile validation test changed to use a 1-char displayName
("X") that actually fails updateMeSchema.min(2) and asserts the
error AFTER clicking submit (form only validates on submit).
- Edit-profile empty-fields test disambiguates the Genre label with
an exact match so it no longer matches "Genre Preferences".
- Playlists load-error test drops name option from findByRole since
<p role="alert"> computed accessible names are inconsistent.
- Removes an unused eslint-disable directive on DEFAULT_GENRE_PREFS.
Result: 50/50 tests pass across 6 files. Lint clean. Build clean.1 parent d4509a7 commit 16edfe7
4 files changed
Lines changed: 430 additions & 403 deletions
File tree
- apps/web/__tests__
- helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 5 | + | |
32 | 6 | | |
33 | 7 | | |
34 | 8 | | |
| |||
0 commit comments