From 2eb28f41c322a86a7592d5401b1060be061b6d8f Mon Sep 17 00:00:00 2001 From: nntrivi2001 Date: Tue, 8 Sep 2026 10:52:49 +0700 Subject: [PATCH] fix(ui): title the workspace tab "Workspace", not the raw i18n key DocumentTitle mapped /workspace to nav:run, a key that does not exist, so i18next rendered the key itself and the browser tab read "run". Point it at nav:workspace, which both locales already ship, and add a test asserting each top-level route resolves to a translated label. --- client/src/components/DocumentTitle.tsx | 2 +- .../__tests__/DocumentTitle.test.tsx | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 client/src/components/__tests__/DocumentTitle.test.tsx diff --git a/client/src/components/DocumentTitle.tsx b/client/src/components/DocumentTitle.tsx index dccf3135..642a3e5c 100644 --- a/client/src/components/DocumentTitle.tsx +++ b/client/src/components/DocumentTitle.tsx @@ -27,7 +27,7 @@ export function DocumentTitle() { } else if (path.startsWith("/workflows")) { title = t("workflows"); } else if (path.startsWith("/workspace")) { - title = t("run"); + title = t("workspace"); } else if (path.startsWith("/settings")) { title = t("settings"); } else if (path !== "/") { diff --git a/client/src/components/__tests__/DocumentTitle.test.tsx b/client/src/components/__tests__/DocumentTitle.test.tsx new file mode 100644 index 00000000..f74fcb42 --- /dev/null +++ b/client/src/components/__tests__/DocumentTitle.test.tsx @@ -0,0 +1,39 @@ +/** + * @file DocumentTitle.test.tsx + * @description Guards the route→browser-tab-title map against missing i18n keys: + * a key that does not exist renders as the raw key (the "run" bug), so each route + * is asserted against its translated label. + * @author Nguyễn Ngọc Trí Vĩ + */ + +import { describe, it, expect, beforeAll } from "vitest"; +import { render } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; +import i18n from "i18next"; +import { DocumentTitle } from "../DocumentTitle"; + +const titleFor = (path: string) => { + render( + + + + ); + return document.title; +}; + +describe("DocumentTitle", () => { + beforeAll(async () => { + await i18n.changeLanguage("en"); + }); + + it("titles the workspace route with its nav label, not the raw key", () => { + expect(titleFor("/workspace")).toMatch(/^Workspace · /); + }); + + it("titles the other top-level routes", () => { + expect(titleFor("/")).toMatch(/^Dashboard · /); + expect(titleFor("/sessions")).toMatch(/^Sessions · /); + expect(titleFor("/workflows")).toMatch(/^Workflows · /); + expect(titleFor("/settings")).toMatch(/^Settings · /); + }); +});