fix(web): show Resume Reading on the manga CTA when the target volume is in progress (#280)
The series hero CTA only inspected chapter.read, so a volume with saved partial progress (e.g. 18%) still rendered "Start Reading" — the button contradicted the progress indicator on the same page. The resume target with progress > 0 now renders "Resume Reading"; untouched series keep "Start Reading" and mid-series targets keep "Continue". Fixes #188 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
co-authored by
Claude Fable 5
parent
604bbf1a0f
commit
ce06dc8ca5
@@ -164,6 +164,32 @@ describe("MangaContent", () => {
|
||||
expect(cta).toHaveAttribute("href", "/reader/ebook/v02?libraryId=7" + seriesBackTo);
|
||||
});
|
||||
|
||||
// Regression test for issue #188: partial progress on the resume target
|
||||
// must surface as "Resume Reading", not "Start Reading".
|
||||
it("shows a Resume Reading hero CTA when the target volume is partially read", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<MangaContent
|
||||
item={mangaItem([
|
||||
{
|
||||
content_id: "v01",
|
||||
title: "Railgun v01",
|
||||
chapter_index: 1,
|
||||
volume: "v01",
|
||||
progress: 0.18,
|
||||
},
|
||||
{ content_id: "v02", title: "Railgun v02", chapter_index: 2, volume: "v02" },
|
||||
])}
|
||||
libraryId={7}
|
||||
/>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
const cta = screen.getByRole("link", { name: /Resume Reading/i });
|
||||
expect(cta).toHaveTextContent("Volume 1");
|
||||
expect(cta).toHaveAttribute("href", "/reader/ebook/v01?libraryId=7" + seriesBackTo);
|
||||
});
|
||||
|
||||
it("offers a Read Again CTA from the start once every chapter is read", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
|
||||
@@ -271,8 +271,12 @@ export default function MangaContent({
|
||||
const anyRead = chapterRows.some((chapter) => chapter.read === true);
|
||||
const resume = useMemo(() => firstUnreadChapter(entries), [entries]);
|
||||
const fallbackStart = entries.length > 0 ? flattenFirst(entries) : null;
|
||||
const resumeInProgress = (resume?.chapter.progress ?? 0) > 0;
|
||||
const cta = resume
|
||||
? { ...resume, verb: anyRead ? "Continue" : "Start Reading" }
|
||||
? {
|
||||
...resume,
|
||||
verb: resumeInProgress ? "Resume Reading" : anyRead ? "Continue" : "Start Reading",
|
||||
}
|
||||
: fallbackStart
|
||||
? { ...fallbackStart, verb: "Read Again" }
|
||||
: null;
|
||||
|
||||
Reference in New Issue
Block a user