fix(i18n): finish career activity copy

This commit is contained in:
cesnimda
2026-08-29 21:57:40 +02:00
parent a704c75440
commit 457f0601c0
13 changed files with 272 additions and 91 deletions
+20 -3
View File
@@ -3,6 +3,7 @@ import "@testing-library/jest-dom";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { api } from "./api";
import { I18nProvider } from "./i18n/I18nProvider";
import OperationsPage from "./views/OperationsPage";
jest.mock("./api", () => ({
@@ -17,6 +18,10 @@ jest.mock("./api", () => ({
const mockedApi = api as jest.Mocked<typeof api>;
function renderPage() {
return render(<I18nProvider><OperationsPage /></I18nProvider>);
}
const operation = {
id: "11111111-1111-1111-1111-111111111111",
taskType: "strategy_snapshot",
@@ -40,6 +45,7 @@ const notification = {
beforeEach(() => {
jest.clearAllMocks();
window.localStorage.clear();
mockedApi.get.mockImplementation((url: string) => Promise.resolve({
data: url.startsWith("/operations") ? [operation] : [notification],
} as any));
@@ -48,7 +54,7 @@ beforeEach(() => {
});
test("shows persistent operation and notification states with accessible actions", async () => {
render(<OperationsPage />);
renderPage();
expect(await screen.findByText("strategy_snapshot")).toBeInTheDocument();
expect(screen.getByText("Analysing role")).toBeInTheDocument();
@@ -71,12 +77,23 @@ test("shows persistent operation and notification states with accessible actions
test("shows honest empty and failure states", async () => {
mockedApi.get.mockResolvedValueOnce({ data: [] } as any).mockResolvedValueOnce({ data: [] } as any);
const { unmount } = render(<OperationsPage />);
const { unmount } = renderPage();
expect(await screen.findByText("No notifications.")).toBeInTheDocument();
expect(screen.getByText("No background operations yet.")).toBeInTheDocument();
unmount();
mockedApi.get.mockRejectedValue(new Error("offline"));
render(<OperationsPage />);
renderPage();
expect(await screen.findByRole("alert")).toHaveTextContent("Operations could not be loaded.");
});
test("localizes operation controls and empty states in Norwegian Bokmål", async () => {
window.localStorage.setItem("uiLanguage", "nb");
mockedApi.get.mockResolvedValue({ data: [] } as any);
renderPage();
expect(await screen.findByText("Ingen varsler.")).toBeInTheDocument();
expect(screen.getByText("Ingen bakgrunnsoperasjoner ennå.")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Oppdater" })).toBeInTheDocument();
});