Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 010049b3c7 | |||
| 2552d85d5c |
@@ -0,0 +1,33 @@
|
||||
# Local language choice on the anonymous landing page
|
||||
|
||||
18 November 2026. Baseline A3 `0765b15133da62b86fcc9a8bc29eb8d39c42d1a9`; isolated branch `codex/landing-local-language`. This is a two-line consumer fix, not a public-site redesign, new locale, commercial claim or launch acceptance.
|
||||
|
||||
## Behavior and boundary
|
||||
|
||||
The landing page first reads `/auth/me`: an authenticated result redirects to `/dashboard`; the anonymous/failure branch shows the public page. Its language toggle previously called the account-persisting `setLanguage`, attempting `/auth/preferences/language` despite being a public entry. The existing [landing baseline review](visual-correction/LANDING_BASELINE_REVIEW.md) observed 24 rejected preference requests across 12 controlled journeys. `LandingPage.tsx` has the same original Git blob `8d7bdb3d70954186af78be32d4cf422fdce584d2` at that historical baseline and the current A3 baseline, so the finding was not inferred from missing manual review.
|
||||
|
||||
Only `LandingPage` now passes the existing `setLocalLanguage` to `StackLanguageToggle`. EN/NB content, HTML language and browser-local choice still update and survive a fresh provider mount. The shared toggle, `I18nProvider`, authenticated account writer, failure/retry behavior, server-preference hydration, login/deep-link intent and auth redirect are unchanged. Account preference PUTs remain available to authenticated callers; no runtime auth heuristic, new option or second preference store is added. No new strings, visual layout, provider/model, API/schema/dependency or document-renderer change.
|
||||
|
||||
## Red/green verification
|
||||
|
||||
The existing landing-language case was extended to cover both EN→NB and NB→EN, localStorage/HTML/content, remount and zero preference PUTs. A separate authenticated-redirect control verifies the public page is not presented after a successful session read.
|
||||
|
||||
- Original runtime source with the new tests: **FAILED two cases / passed two controls**. Both failures were the zero-PUT assertion: exactly one rejected account-writer attempt would have occurred (`nb-NO` or `en`). Content/local language assertions had already passed. This is fresh deterministic JSDOM failure proof, separate from the older browser baseline.
|
||||
- Fixed final affected run: **13 cases / three suites PASSED**, zero failures/skips. Suites: `landing-page.test.tsx`, unchanged `i18n-provider.test.tsx`, unchanged `LandingPage.authRedirect.test.tsx`. Existing tests retain persisted account saves, localized retries, hydration without writeback and deep-link forwarding. Intermediate results overlap and are not added to 13.
|
||||
- PASSED: full non-incremental TypeScript (`--noEmit --incremental false`), scoped ESLint for the two changed files, and source diff whitespace check, exit 0 each. No source or rule warnings were suppressed.
|
||||
|
||||
Commands ran from `job-tracker-ui` with the existing qualified modules accessed through this worktree's own read-only junction to `next-security-patch/job-tracker-ui/node_modules`. No installation, lockfile or shared module mutation. Jest cache and TEMP/TMP remained under this E-drive worktree. Core final test command:
|
||||
|
||||
```text
|
||||
rtk proxy node node_modules/jest/bin/jest.js --runInBand --runTestsByPath src/landing-page.test.tsx src/i18n-provider.test.tsx src/LandingPage.authRedirect.test.tsx --cacheDirectory=<owned E-drive cache> --json --outputFile=../docs/ui-modernisation/evidence/landing-local-language/green-jest.json
|
||||
```
|
||||
|
||||
The raw Jest JSON/logs and exact source bindings are in [SOURCE_RECEIPTS.json](evidence/landing-local-language/SOURCE_RECEIPTS.json). Source hashes normalize CRLF to LF; native artifact hashes use exact bytes. PowerShell's stderr wrapper appears as `NativeCommandError` in captured logs, including the successful run; the child exit code and structured Jest outcome determine the result. The original failure messages remain intact.
|
||||
|
||||
## Limits and rollback
|
||||
|
||||
These are mocked API/JSDOM contract checks. No fresh browser, real preference API, cross-device account operation, public HTML/SEO, human/native-language/device/AT, security or whole-launch qualification is claimed. Root owns subsequent public-entry browser qualification. Existing launch design/claims and other roadmap gates remain open. No orchestrator, push, main merge or deployment.
|
||||
|
||||
Rollback restores the two LandingPage setter references and associated regression tests; no data migration or stored preference rollback is required.
|
||||
|
||||
Root recovery verification: independently verified all12 source/native receipt bindings and the structured13-case passing result, repeated nonincremental TypeScript and scoped ESLint (exit0), and completed `graphify update . --no-cluster` (19,888 nodes/49,292 edges, AST only). Missing SQL extractor and symbol-free file warnings remain. The worker usage interruption did not lose these changes. No browser result is implied by this checkpoint.
|
||||
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"baseline": "0765b15133da62b86fcc9a8bc29eb8d39c42d1a9",
|
||||
"redRuntimeSource": "0765b15133da62b86fcc9a8bc29eb8d39c42d1a9",
|
||||
"redOriginalLandingBlob": "8d7bdb3d70954186af78be32d4cf422fdce584d2",
|
||||
"hashPolicy": "UTF8 source normalized LF; native reports/logs exact raw bytes",
|
||||
"node": "v24.19.0",
|
||||
"sources": [
|
||||
{
|
||||
"file": "job-tracker-ui/src/views/LandingPage.tsx",
|
||||
"sha256Lf": "7669d0a13f2bfcd7b8398fa2105c0f3a5dc5a5130174a61e0d2b42b062da7ce7"
|
||||
},
|
||||
{
|
||||
"file": "job-tracker-ui/src/landing-page.test.tsx",
|
||||
"sha256Lf": "ef69cffc7c2d05df942e501a9f82e6d5677e36962c1ade4cf8fddfc01f06ea14"
|
||||
},
|
||||
{
|
||||
"file": "job-tracker-ui/src/i18n/I18nProvider.tsx",
|
||||
"sha256Lf": "d669c3682f3e53e36f8d0ebb8be72706996185b9e0f8025c62579c3a3470c7aa"
|
||||
},
|
||||
{
|
||||
"file": "job-tracker-ui/src/i18n-provider.test.tsx",
|
||||
"sha256Lf": "520b8559ebd0c206649008c98705c24bd8caac7e00a642984a75b11f7d851fbe"
|
||||
},
|
||||
{
|
||||
"file": "job-tracker-ui/src/LandingPage.authRedirect.test.tsx",
|
||||
"sha256Lf": "3aac7d0b9fa8606765cf657d0d850d448c6bec8ef8e4fa39eebd3c25bb326bf6"
|
||||
},
|
||||
{
|
||||
"file": "job-tracker-ui/jest.config.cjs",
|
||||
"sha256Lf": "de323cd3aa8693b11a028b2c026682f05ab988d182ed860861a051d66e53c286"
|
||||
}
|
||||
],
|
||||
"reports": [
|
||||
{
|
||||
"file": "red-jest.json",
|
||||
"bytes": 4929,
|
||||
"sha256": "d5822546a5bcb980202b7df9e95ee9a02a83ed34e1b00cdd319a5d4cef1047b0"
|
||||
},
|
||||
{
|
||||
"file": "red-jest.log",
|
||||
"bytes": 4156,
|
||||
"sha256": "bec064e62bab12b323c63d8db72c237427d9fb1ff26d09e5feb02f6f1f8762d4"
|
||||
},
|
||||
{
|
||||
"file": "green-jest.json",
|
||||
"bytes": 6423,
|
||||
"sha256": "6c55ed6ea016b6894deaa840a5a408b5902e16e6ddd5c76a5c4015281922700f"
|
||||
},
|
||||
{
|
||||
"file": "green-jest.log",
|
||||
"bytes": 1322,
|
||||
"sha256": "ff585aa79ebb81cf8dd04157a71c15cd00a918cda758127d72dd569e20d1f181"
|
||||
},
|
||||
{
|
||||
"file": "typecheck.log",
|
||||
"bytes": 0,
|
||||
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
},
|
||||
{
|
||||
"file": "lint.log",
|
||||
"bytes": 0,
|
||||
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
}
|
||||
],
|
||||
"red": {
|
||||
"passed": 2,
|
||||
"failed": 2,
|
||||
"total": 4
|
||||
},
|
||||
"green": {
|
||||
"passed": 13,
|
||||
"failed": 0,
|
||||
"pending": 0,
|
||||
"suites": 3
|
||||
},
|
||||
"scope": "Mocked JSDOM public language, authenticated preference, redirect and deep-link contracts; no native browser/API/provider/launch acceptance",
|
||||
"checks": {
|
||||
"typecheck": {
|
||||
"command": "node node_modules/typescript/bin/tsc --noEmit --incremental false",
|
||||
"exitCode": 0
|
||||
},
|
||||
"lint": {
|
||||
"command": "node node_modules/eslint/bin/eslint.js src/views/LandingPage.tsx src/landing-page.test.tsx",
|
||||
"exitCode": 0
|
||||
},
|
||||
"diff": {
|
||||
"command": "rtk git diff --check",
|
||||
"exitCode": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -0,0 +1 @@
|
||||
{"numFailedTestSuites":1,"numFailedTests":2,"numPassedTestSuites":0,"numPassedTests":2,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":4,"openHandles":[],"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1794961647677,"success":false,"testResults":[{"assertionResults":[{"ancestorTitles":[],"duration":250,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"shows exactly Free and Pro without invented commercial terms","invocations":1,"location":null,"numPassingAsserts":6,"retryReasons":[],"startAt":1794961651256,"status":"passed","title":"shows exactly Free and Pro without invented commercial terms"},{"ancestorTitles":[],"duration":111,"failing":false,"failureDetails":[{"matcherResult":{"message":"expect(jest.fn()).not.toHaveBeenCalled()\n\nExpected number of calls: 0\nReceived number of calls: 1\n\n1: \"/auth/preferences/language\", {\"language\": \"nb-NO\"}","pass":true}}],"failureMessages":["Error: expect(jest.fn()).not.toHaveBeenCalled()\n\nExpected number of calls: 0\nReceived number of calls: 1\n\n1: \"/auth/preferences/language\", {\"language\": \"nb-NO\"}\n at toHaveBeenCalled (E:\\Storage\\Projects\\Active\\temp docs\\jobjakt-local-build\\landing-local-language\\job-tracker-ui\\src\\landing-page.test.tsx:54:23)"],"fullName":"public landing language en → Norsk bokmål survives remount without an account preference write","invocations":1,"location":null,"numPassingAsserts":3,"retryReasons":[],"startAt":1794961651507,"status":"failed","title":"public landing language en → Norsk bokmål survives remount without an account preference write"},{"ancestorTitles":[],"duration":117,"failing":false,"failureDetails":[{"matcherResult":{"message":"expect(jest.fn()).not.toHaveBeenCalled()\n\nExpected number of calls: 0\nReceived number of calls: 1\n\n1: \"/auth/preferences/language\", {\"language\": \"en\"}","pass":true}}],"failureMessages":["Error: expect(jest.fn()).not.toHaveBeenCalled()\n\nExpected number of calls: 0\nReceived number of calls: 1\n\n1: \"/auth/preferences/language\", {\"language\": \"en\"}\n at toHaveBeenCalled (E:\\Storage\\Projects\\Active\\temp docs\\jobjakt-local-build\\landing-local-language\\job-tracker-ui\\src\\landing-page.test.tsx:54:23)"],"fullName":"public landing language nb → English survives remount without an account preference write","invocations":1,"location":null,"numPassingAsserts":3,"retryReasons":[],"startAt":1794961651623,"status":"failed","title":"public landing language nb → English survives remount without an account preference write"},{"ancestorTitles":[],"duration":76,"failing":false,"failureDetails":[],"failureMessages":[],"fullName":"an authenticated landing visitor still redirects without changing account language","invocations":1,"location":null,"numPassingAsserts":3,"retryReasons":[],"startAt":1794961651741,"status":"passed","title":"an authenticated landing visitor still redirects without changing account language"}],"endTime":1794961651832,"message":" ● public landing language en → Norsk bokmål survives remount without an account preference write\n\n expect(jest.fn()).not.toHaveBeenCalled()\n\n Expected number of calls: 0\n Received number of calls: 1\n\n 1: \"/auth/preferences/language\", {\"language\": \"nb-NO\"}\n\n 52 | expect(localStorage.getItem(\"uiLanguage\")).toBe(local);\n 53 | expect(document.documentElement.lang).toBe(htmlLanguage);\n > 54 | expect(api.put).not.toHaveBeenCalled();\n | ^\n 55 |\n 56 | view.unmount();\n 57 | render(<MemoryRouter><I18nProvider><LandingPage /></I18nProvider></MemoryRouter>);\n\n at toHaveBeenCalled (src/landing-page.test.tsx:54:23)\n\n ● public landing language nb → English survives remount without an account preference write\n\n expect(jest.fn()).not.toHaveBeenCalled()\n\n Expected number of calls: 0\n Received number of calls: 1\n\n 1: \"/auth/preferences/language\", {\"language\": \"en\"}\n\n 52 | expect(localStorage.getItem(\"uiLanguage\")).toBe(local);\n 53 | expect(document.documentElement.lang).toBe(htmlLanguage);\n > 54 | expect(api.put).not.toHaveBeenCalled();\n | ^\n 55 |\n 56 | view.unmount();\n 57 | render(<MemoryRouter><I18nProvider><LandingPage /></I18nProvider></MemoryRouter>);\n\n at toHaveBeenCalled (src/landing-page.test.tsx:54:23)\n","name":"E:\\Storage\\Projects\\Active\\temp docs\\jobjakt-local-build\\landing-local-language\\job-tracker-ui\\src\\landing-page.test.tsx","startTime":1794961648624,"status":"failed","summary":""}],"wasInterrupted":false}
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
|
||||
import { api } from "./api";
|
||||
@@ -40,10 +40,32 @@ test("shows exactly Free and Pro without invented commercial terms", async () =>
|
||||
expect(mockNavigate).toHaveBeenCalledWith("/login", { state: { from: "/settings" } });
|
||||
});
|
||||
|
||||
test("switches the public landing page to Norwegian Bokmål", async () => {
|
||||
test.each([
|
||||
["en", "Norsk bokmål", "nb", "nb-NO", "To tydelige alternativer"],
|
||||
["nb", "English", "en", "en", "Two clear plans"],
|
||||
])("public landing language %s → %s survives remount without an account preference write", async (initial, button, local, htmlLanguage, heading) => {
|
||||
localStorage.setItem("uiLanguage", initial);
|
||||
const view = render(<MemoryRouter><I18nProvider><LandingPage /></I18nProvider></MemoryRouter>);
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: button }));
|
||||
expect(await screen.findByRole("heading", { name: heading })).toBeInTheDocument();
|
||||
expect(localStorage.getItem("uiLanguage")).toBe(local);
|
||||
expect(document.documentElement.lang).toBe(htmlLanguage);
|
||||
expect(api.put).not.toHaveBeenCalled();
|
||||
|
||||
view.unmount();
|
||||
render(<MemoryRouter><I18nProvider><LandingPage /></I18nProvider></MemoryRouter>);
|
||||
expect(await screen.findByRole("heading", { name: heading })).toBeInTheDocument();
|
||||
expect(api.get).toHaveBeenCalledTimes(2);
|
||||
expect(api.get).toHaveBeenLastCalledWith("/auth/me");
|
||||
expect(api.put).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("an authenticated landing visitor still redirects without changing account language", async () => {
|
||||
(api.get as jest.Mock).mockResolvedValueOnce({ data: { id: "synthetic-owner" } });
|
||||
render(<MemoryRouter><I18nProvider><LandingPage /></I18nProvider></MemoryRouter>);
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Norsk bokmål" }));
|
||||
expect(await screen.findByRole("heading", { name: "To tydelige alternativer" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Opprett en Free-konto" })).toBeInTheDocument();
|
||||
await waitFor(() => expect(mockNavigate).toHaveBeenCalledWith("/dashboard", { replace: true }));
|
||||
expect(screen.queryByRole("heading", { name: "Two clear plans" })).not.toBeInTheDocument();
|
||||
expect(api.put).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ const STEPS: { n: number; title: TranslationKey; body: TranslationKey }[] = [
|
||||
|
||||
export default function LandingPage() {
|
||||
const navigate = useNavigate();
|
||||
const { language, setLanguage, t } = useI18n();
|
||||
const { language, setLocalLanguage, t } = useI18n();
|
||||
const location = useLocation() as { state?: { from?: string } };
|
||||
const [checking, setChecking] = useState(true);
|
||||
|
||||
@@ -99,7 +99,7 @@ export default function LandingPage() {
|
||||
<Typography sx={{ color: "#fff", fontWeight: 800, fontSize: 20 }}>Jobbjakt</Typography>
|
||||
</Stack>
|
||||
<Stack direction="row" alignItems="center" spacing={1}>
|
||||
<StackLanguageToggle language={language} setLanguage={setLanguage} onDark />
|
||||
<StackLanguageToggle language={language} setLanguage={setLocalLanguage} onDark />
|
||||
<GradientButton onClick={goToLogin} sx={{ color: "#0b1020", fontWeight: 700 }}>
|
||||
{t("landingSignIn")}
|
||||
</GradientButton>
|
||||
|
||||
Reference in New Issue
Block a user