fix(home): keep finished series off the Continue-reading shelf
A "Continue reading" shelf listing series the reader already finished (read to the last page, nothing new) is odd. Expose the last-read chapter's page_count on the read-progress list, and filter the shelf to drop entries that are caught up (on the last page of the latest chapter with no new chapters). Mid-chapter and has-new-chapters entries stay; the full history view is unaffected. Finished detection is a pure, unit-tested helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,7 @@ test('shows the continue-reading shelf with a new-chapter badge when signed in',
|
||||
manga_cover_image_path: null,
|
||||
chapter_id: 'c1',
|
||||
chapter_number: 3,
|
||||
chapter_page_count: 20,
|
||||
page: 4,
|
||||
updated_at: '2026-01-01T00:00:00Z',
|
||||
new_chapters_count: 2
|
||||
@@ -65,6 +66,40 @@ test('shows the continue-reading shelf with a new-chapter badge when signed in',
|
||||
await expect(page.getByTestId('continue-new-badge-m1')).toContainText('2');
|
||||
});
|
||||
|
||||
test('keeps finished series off the shelf but shows in-progress ones', async ({ page }) => {
|
||||
await mockCommon(page);
|
||||
await page.route('**/api/v1/auth/me', (route) =>
|
||||
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ user: { id: 'u1', username: 'reader', is_admin: false } }) })
|
||||
);
|
||||
await page.route('**/api/v1/me/read-progress*', (route) =>
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
items: [
|
||||
// Finished: last page of the latest chapter, nothing new.
|
||||
{
|
||||
manga_id: 'done', manga_title: 'Finished', manga_cover_image_path: null,
|
||||
chapter_id: 'dc', chapter_number: 5, chapter_page_count: 10, page: 10,
|
||||
updated_at: '2026-01-02T00:00:00Z', new_chapters_count: 0
|
||||
},
|
||||
// In progress: mid-chapter.
|
||||
{
|
||||
manga_id: 'wip', manga_title: 'Ongoing', manga_cover_image_path: null,
|
||||
chapter_id: 'wc', chapter_number: 2, chapter_page_count: 10, page: 3,
|
||||
updated_at: '2026-01-01T00:00:00Z', new_chapters_count: 0
|
||||
}
|
||||
],
|
||||
page: { limit: 50, offset: 0, total: 2 }
|
||||
})
|
||||
})
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await expect(page.getByTestId('continue-card-wip')).toBeVisible();
|
||||
await expect(page.getByTestId('continue-card-done')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('hides the continue-reading shelf for anonymous visitors', async ({ page }) => {
|
||||
await mockCommon(page);
|
||||
await page.route('**/api/v1/auth/me', (route) =>
|
||||
|
||||
Reference in New Issue
Block a user