Files
siftlode/frontend/src/components/watchStrings.dom.test.ts
T
peter dba4758c59 fix(watch): a link whose video is being made again says so, in the page's language
The public watch route answers video_preparing for an asset that is pending or
downloading, and the page shows "being prepared — try again" with a Retry
instead of "this link is gone". watch.html ships one lang; the page now sets
documentElement.lang to the language its strings were picked in.
2026-10-06 03:19:32 +02:00

31 lines
1.0 KiB
TypeScript

// @vitest-environment jsdom
//
// The shared-link page ships one watch.html for every visitor, so the document's language is set
// from the language its strings were picked in — a screen reader picks its voice by it, and the
// browser offers to translate by it. A Hungarian visitor once got lang="en" over Hungarian text.
import { afterEach, describe, expect, it, vi } from "vitest";
afterEach(() => {
vi.unstubAllGlobals();
vi.resetModules();
});
async function pageIn(language: string) {
vi.stubGlobal("navigator", { ...navigator, language });
vi.resetModules();
return import("./watchStrings");
}
describe("the watch page's document language", () => {
it.each([
["hu-HU", "hu"],
["de-AT", "de"],
["en-GB", "en"],
["fr-FR", "en"], // no French strings: the page is in English, and says so
])("a %s browser reads a page marked %s", async (language, want) => {
const { lang } = await pageIn(language);
expect(lang).toBe(want);
expect(document.documentElement.lang).toBe(want);
});
});