test(e2e): realign mocks + assertions with the current API and OCR-era UI
The route-mocked E2E specs had drifted from the app they exercise, so
each rendered an empty/500 page and timed out on missing elements:
- Manga detail + reader loads now also fetch read-progress/{id} and
/similar; several specs never mocked them, so the load's Promise.all
rejected. Add the mocks and fill the manga fixtures out to a real
MangaDetail (status/alt_titles/authors/genres/tags/... ) so the
components stop throwing mid-render.
- back-nav + library: widen `read-progress*`/`page-tags` globs — `*`
doesn't cross `/`, so `/me/read-progress/{id}` fell through to the
proxy and 500'd; mock the library page-tags pair too.
- manga-list search: wait for the initial load to settle before
searching so the search fetch can't race the mount-time load.
- reader-chapter-select: assert the shared `chapterLabel` output.
- admin-analysis: the active OCR backend extracts text only, so the
detail modal shows OCR (no tags/NSFW) and metrics shows tiles +
trend charts (no by-model) — assert what the OCR-era UI renders.
- profile: assert the wrong-password 401 stays inline (guards the
fix in the preceding commit) and mock the guest bookmark/collection
fetches the /profile load maps to the sign-in prompt.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,24 @@ async function mockAnonymous(page: Page) {
|
||||
body: JSON.stringify({ error: { code: 'unauthenticated', message: 'unauthenticated' } })
|
||||
});
|
||||
});
|
||||
await page.route('**/api/v1/auth/me/preferences', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 401,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ error: { code: 'unauthenticated', message: 'unauthenticated' } })
|
||||
});
|
||||
});
|
||||
// The home page fetches genres on mount (filter UI). Mocking it keeps
|
||||
// `onMount` fast and deterministic — otherwise the unmocked call stalls
|
||||
// against the dead dev proxy, and the late-resolving initial load races
|
||||
// (and clobbers) a load kicked off by an early search interaction.
|
||||
await page.route('**/api/v1/genres*', async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify([])
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test('home page renders the Mangalord heading and search input', async ({ page }) => {
|
||||
@@ -86,11 +104,16 @@ test('search updates the manga list', async ({ page }) => {
|
||||
{
|
||||
id: 'b1',
|
||||
title: 'Berserk',
|
||||
author: 'Kentaro Miura',
|
||||
status: 'ongoing',
|
||||
alt_titles: [],
|
||||
description: null,
|
||||
cover_image_path: null,
|
||||
created_at: '2026-01-01T00:00:00Z',
|
||||
updated_at: '2026-01-01T00:00:00Z'
|
||||
updated_at: '2026-01-01T00:00:00Z',
|
||||
// MangaCard = Manga & { authors, genres }; the card
|
||||
// component maps over both, so they must be present.
|
||||
authors: [{ id: 'a1', name: 'Kentaro Miura' }],
|
||||
genres: []
|
||||
}
|
||||
]
|
||||
: [];
|
||||
@@ -102,6 +125,11 @@ test('search updates the manga list', async ({ page }) => {
|
||||
});
|
||||
|
||||
await page.goto('/');
|
||||
// Wait for the initial (empty) catalogue to settle before searching, so
|
||||
// the search's fetch can't race the mount-time load — mirrors how the
|
||||
// pagination test waits for the first render before interacting.
|
||||
await expect(page.getByTestId('empty')).toBeVisible();
|
||||
|
||||
await page.getByTestId('search-input').fill('berserk');
|
||||
await page.getByRole('button', { name: 'Search' }).click();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user