phase 7+: i18n primitive + login language picker + autocomplete-off
Adds a minimal Svelte 5 i18n primitive (`src/lib/i18n/`) backing the
login form, the layout blocker page, and the lobby placeholder.
SUPPORTED_LOCALES drives both the picker and the runtime lookup;
adding a language is a two-step change inside `src/lib/i18n/`.
Login form gains a globe-icon language dropdown (English / Русский
in their native names), defaulting to navigator.languages with `en`
as the fallback. Switching the locale re-renders the form in place;
on submit, the locale rides in the JSON body of `send-email-code`
because Safari/WebKit silently drops JS-set Accept-Language. Gateway
gains a body `locale` field that takes priority over the request
header for preferred-language resolution.
Email and code inputs disable browser autofill / suggestions
(`autocomplete=off` + `autocorrect=off` + `autocapitalize=off` +
`spellcheck=false`) so Keychain / address-book pickers and
remembered-value dropdowns no longer fire on focus.
Cross-cuts:
- backend & gateway openapi: clarify that body `locale` is honored.
- docs/FUNCTIONAL{,_ru}.md §1.2: document body-vs-header priority.
- gateway tests: body `locale` overrides Accept-Language; blank
body `locale` falls back to header.
- new ui/docs/i18n.md; cross-links from auth-flow.md and ui/README.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -143,7 +143,7 @@ test.describe("Phase 7 — auth flow", () => {
|
||||
await expect(page.getByTestId("device-session-id")).toHaveText(
|
||||
"dev-test-1",
|
||||
);
|
||||
await expect(page.getByTestId("account-display-name")).toHaveText("Pilot");
|
||||
await expect(page.getByTestId("account-greeting")).toContainText("Pilot");
|
||||
|
||||
mocks.pendingSubscribes.forEach((resolve) => resolve());
|
||||
});
|
||||
@@ -153,7 +153,7 @@ test.describe("Phase 7 — auth flow", () => {
|
||||
}) => {
|
||||
const mocks = await mockGatewayHappyPath(page, "Pilot");
|
||||
await completeLogin(page);
|
||||
await expect(page.getByTestId("account-display-name")).toBeVisible();
|
||||
await expect(page.getByTestId("account-greeting")).toBeVisible();
|
||||
|
||||
await page.reload();
|
||||
await expect(page).toHaveURL(/\/lobby$/);
|
||||
@@ -169,7 +169,7 @@ test.describe("Phase 7 — auth flow", () => {
|
||||
}) => {
|
||||
const mocks = await mockGatewayHappyPath(page, "Pilot");
|
||||
await completeLogin(page);
|
||||
await expect(page.getByTestId("account-display-name")).toBeVisible();
|
||||
await expect(page.getByTestId("account-greeting")).toBeVisible();
|
||||
|
||||
// Fire all pending SubscribeEvents requests with an empty 200
|
||||
// response. Connect-Web's server-streaming reader sees no frames
|
||||
@@ -182,6 +182,48 @@ test.describe("Phase 7 — auth flow", () => {
|
||||
expect(Date.now() - releaseAt).toBeLessThan(1500);
|
||||
});
|
||||
|
||||
test("language picker switches the form text and forwards the locale", async ({
|
||||
page,
|
||||
}) => {
|
||||
const sendRequests: Array<{ body: Record<string, unknown> }> = [];
|
||||
await page.route(
|
||||
"**/api/v1/public/auth/send-email-code",
|
||||
async (route) => {
|
||||
const raw = route.request().postData() ?? "";
|
||||
sendRequests.push({
|
||||
body: JSON.parse(raw) as Record<string, unknown>,
|
||||
});
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ challenge_id: "ch-test-2" }),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
await page.goto("/login");
|
||||
await expect(page.getByTestId("login-email-submit")).toHaveText(
|
||||
"send code",
|
||||
);
|
||||
|
||||
await page
|
||||
.getByTestId("login-language-select")
|
||||
.selectOption("ru");
|
||||
await expect(page.getByTestId("login-email-submit")).toHaveText(
|
||||
"отправить код",
|
||||
);
|
||||
|
||||
await page.getByTestId("login-email-input").fill("pilot@example.com");
|
||||
await page.getByTestId("login-email-submit").click();
|
||||
await expect(page.getByTestId("login-code-input")).toBeVisible();
|
||||
|
||||
expect(sendRequests).toHaveLength(1);
|
||||
expect(sendRequests[0]!.body).toEqual({
|
||||
email: "pilot@example.com",
|
||||
locale: "ru",
|
||||
});
|
||||
});
|
||||
|
||||
test("browser without WebCrypto Ed25519 shows the not-supported blocker", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user