fix(i18n): localize generated labels without changing saved content
This commit is contained in:
@@ -3,7 +3,7 @@ import "@testing-library/jest-dom";
|
||||
import { act, fireEvent, render as rtlRender, screen, waitFor, within } from "@testing-library/react";
|
||||
|
||||
import {
|
||||
ApplicationCoverLetterSection, ApplicationCvSection, ApplicationPackageDraftsSection, SubmittedPackagesSection,
|
||||
ApplicationCoverLetterSection, ApplicationCvSection, ApplicationPackageDraftsSection, ApplicationTailoringSection, SubmittedPackagesSection,
|
||||
} from "./components/ApplicationAssets";
|
||||
import { api } from "./api";
|
||||
import { I18nProvider } from "./i18n/I18nProvider";
|
||||
@@ -104,6 +104,23 @@ function deferred<T>() {
|
||||
return { promise, resolve, reject };
|
||||
}
|
||||
|
||||
test("[P7-11 tailoring] generated metadata and known history enums follow locale while evidence, unknown metadata and dirty prose stay verbatim", async () => {
|
||||
routeGet({ tailoring: { ...tailoring, suggestions: [...tailoring.suggestions, { kind: "custom", title: "My custom title", detail: "My custom detail", items: ["My verified evidence"] }] }, coverLetter: { ...coverLetter, versions: [...coverLetter.versions, { version: 0, source: "custom-source", aiAction: "custom-action", length: 5, createdAtUtc: "2026-07-19T09:00:00Z", isCurrent: false }] } });
|
||||
render(<><ApplicationTailoringSection jobId={7} /><ApplicationCoverLetterSection jobId={7} /></>);
|
||||
await screen.findByText("Skills to highlight");
|
||||
const letter = await screen.findByRole("textbox", { name: "Cover letter" });
|
||||
fireEvent.change(letter, { target: { value: "My unsaved English letter" } });
|
||||
const reads = mockedApi.get.mock.calls.length;
|
||||
changeLanguage("nb");
|
||||
expect(screen.getByText(copy("assetsTailoringHighlightTitle"))).toBeInTheDocument();
|
||||
expect(screen.getByText(copy("assetsTailoringHighlightDetail"))).toBeInTheDocument();
|
||||
expect(screen.getByText(`${copy("historySourceAi")} · ${copy("coverActionImprove")}`)).toBeInTheDocument();
|
||||
expect(screen.getByText("custom-source · custom-action")).toBeInTheDocument();
|
||||
for (const text of ["My custom title", "My custom detail", "My verified evidence", "C#", "SQL"]) expect(screen.getByText(text)).toBeInTheDocument();
|
||||
expect(screen.getByRole("textbox", { name: copy("jobDetailsCoverLetter") })).toHaveValue("My unsaved English letter");
|
||||
expect(mockedApi.get).toHaveBeenCalledTimes(reads); expect(mockedApi.put).not.toHaveBeenCalled(); expect(mockedApi.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("document package history is read-only and separates captured notes from answers", async () => {
|
||||
const summary = { id: 91, version: 1, cvVariantId: 3, cvVariantName: "Original CV", cvVariantVersion: 2, cvThemeId: "nordic", hasCv: false, hasCoverLetter: true, createdAtUtc: "2026-07-19T10:00:00Z", attachments: [] };
|
||||
mockedApi.get.mockImplementation((url: string) => Promise.resolve({ data: url.endsWith('/91') ? {
|
||||
@@ -197,7 +214,7 @@ test("cover letter loads the current text and its history", async () => {
|
||||
|
||||
expect(await screen.findByDisplayValue("Dear team")).toBeInTheDocument();
|
||||
expect(screen.getByText("v2")).toBeInTheDocument();
|
||||
expect(screen.getByText("ai · improve")).toBeInTheDocument();
|
||||
expect(screen.getByText("AI suggestion · Improve")).toBeInTheDocument();
|
||||
expect(screen.getByText("Current")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user