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.
31 lines
1.0 KiB
TypeScript
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);
|
|
});
|
|
});
|