test(settings): a late failure of the previous language keeps the history (#372)
Review 25424, point 1: the `if (!cancelled)` of ChangelogContent's .catch had no test (V1). Modelled on the late-answer test: the French file rejects after the English one was read, and the history still shows the English notes, not the empty message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4f060ba7d7
commit
2389d51b48
1 changed files with 25 additions and 0 deletions
|
|
@ -335,4 +335,29 @@ describe("ChangelogContent — language switch", () => {
|
||||||
expect(html).toContain("note-0171-en");
|
expect(html).toContain("note-0171-en");
|
||||||
expect(html).not.toMatch(/note-0171(?!-en)/);
|
expect(html).not.toMatch(/note-0171(?!-en)/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("never lets a late failure of the previous language empty the current history", async () => {
|
||||||
|
const pending: Array<{ url: string; resolve: (text: string) => void; reject: (error: Error) => void }> = [];
|
||||||
|
fetchMock.mockImplementation(
|
||||||
|
(url: string) =>
|
||||||
|
new Promise<FetchedFile>((resolveFetch, rejectFetch) => {
|
||||||
|
pending.push({ url, resolve: (text) => resolveFetch({ text: async () => text }), reject: rejectFetch });
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
render("0.17.1");
|
||||||
|
harness.commit(); // asks for the French file
|
||||||
|
ctx.language = "en";
|
||||||
|
render("0.17.1");
|
||||||
|
harness.commit(); // cancels the French one, asks for the English file
|
||||||
|
expect(pending.map((p) => p.url)).toEqual(["/CHANGELOG.fr.md", "/CHANGELOG.md"]);
|
||||||
|
|
||||||
|
pending[1].resolve(EN);
|
||||||
|
await settle();
|
||||||
|
pending[0].reject(new Error("the French file could not be read"));
|
||||||
|
await settle();
|
||||||
|
const html = renderToStaticMarkup(render("0.17.1"));
|
||||||
|
expect(html).toContain("note-0171-en");
|
||||||
|
expect(html).not.toContain("t(changelog.empty)");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue