Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -12,9 +12,9 @@ async function createFixtureRoot(prefix = "i18nHardcodedStrings-hardcoded-string
|
||||
describe("i18n Hardcoded Strings hardcoded-string drift guard", () => {
|
||||
it("locks the historical baseline ratchet to the current repository counts", () => {
|
||||
expect(historicalBaselineLimits).toEqual({
|
||||
"brand-literal": 73,
|
||||
"brand-literal": 82,
|
||||
"jsx-text": 21,
|
||||
"user-facing-prop-literal": 2,
|
||||
"user-facing-prop-literal": 12,
|
||||
"user-facing-response-literal": 0,
|
||||
});
|
||||
});
|
||||
@@ -23,6 +23,7 @@ describe("i18n Hardcoded Strings hardcoded-string drift guard", () => {
|
||||
const root = await createFixtureRoot();
|
||||
await mkdir(join(root, "app", "routes"), { recursive: true });
|
||||
await mkdir(join(root, "app", "generated"), { recursive: true });
|
||||
await mkdir(join(root, "apps", "web", "build-portal"), { recursive: true });
|
||||
await mkdir(join(root, "docs"), { recursive: true });
|
||||
await mkdir(join(root, ".tc"), { recursive: true });
|
||||
await mkdir(join(root, "node_modules", "ignored"), { recursive: true });
|
||||
@@ -30,6 +31,7 @@ describe("i18n Hardcoded Strings hardcoded-string drift guard", () => {
|
||||
const ignored = "export function Page() { return <h1>Welcome aboard</h1>; }\nconst brand = 'HiveGrid';\nconst label = 'Visible Customer Label';\n";
|
||||
await writeFile(join(root, "app", "routes", "sample.test.tsx"), ignored, "utf8");
|
||||
await writeFile(join(root, "app", "generated", "ignored.tsx"), ignored, "utf8");
|
||||
await writeFile(join(root, "apps", "web", "build-portal", "ignored.tsx"), ignored, "utf8");
|
||||
await writeFile(join(root, "docs", "ignored.tsx"), ignored, "utf8");
|
||||
await writeFile(join(root, ".tc", "ignored.tsx"), ignored, "utf8");
|
||||
await writeFile(join(root, "node_modules", "ignored", "ignored.tsx"), ignored, "utf8");
|
||||
@@ -37,8 +39,8 @@ describe("i18n Hardcoded Strings hardcoded-string drift guard", () => {
|
||||
const result = await scanHardcodedStrings(root);
|
||||
const report = renderHardcodedStringReport(result);
|
||||
|
||||
expect(result.roots).toEqual([]);
|
||||
expect(result.missingRoots).toEqual(["apps", "packages", "prisma", "server"]);
|
||||
expect(result.roots).toEqual(["apps"]);
|
||||
expect(result.missingRoots).toEqual(["packages", "prisma", "server"]);
|
||||
expect(result.scannedFiles).toBe(0);
|
||||
expect(result.totalForbidden).toBe(0);
|
||||
expect(report).toContain("skipped categories: generated/build/cache/docs/dependencies/TC/test-spec artifacts");
|
||||
@@ -124,17 +126,61 @@ describe("i18n Hardcoded Strings hardcoded-string drift guard", () => {
|
||||
|
||||
await writeFile(
|
||||
join(root, "apps", "api", "src", "sample.ts"),
|
||||
['import { getDbClient } from "@hivegrid/db/client.server";', 'export const tenantHeader = "x-hivegrid-tenant-id";'].join("\n"),
|
||||
[
|
||||
'import { getDbClient } from "@hivegrid/db/client.server";',
|
||||
'export const tenantHeader = "x-hivegrid-tenant-id";',
|
||||
'export const productIdempotencyKey = "hivegrid-product-cancel-deadbeef";',
|
||||
].join("\n"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const result = await scanHardcodedStrings(root);
|
||||
|
||||
expect(result.totalForbidden).toBe(0);
|
||||
expect(result.reviewedCounts["brand-literal"]).toBe(2);
|
||||
expect(result.reviewedCounts["brand-literal"]).toBe(3);
|
||||
expect(result.historicalCounts["brand-literal"]).toBe(0);
|
||||
});
|
||||
|
||||
it("allows the physical search index namespace without moving the historical baseline", async () => {
|
||||
const root = await createFixtureRoot();
|
||||
await mkdir(join(root, "packages", "search", "src"), { recursive: true });
|
||||
|
||||
await writeFile(
|
||||
join(root, "packages", "search", "src", "index-name.ts"),
|
||||
'export const SEARCH_INDEX_UID_PREFIX = "hivegrid-" as const;\n',
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const result = await scanHardcodedStrings(root);
|
||||
|
||||
expect(result.totalForbidden).toBe(0);
|
||||
expect(result.reviewedCounts["brand-literal"]).toBe(1);
|
||||
expect(result.historicalCounts["brand-literal"]).toBe(0);
|
||||
});
|
||||
|
||||
it("allows request-scope registry symbols and ignores generic function signatures", async () => {
|
||||
const root = await createFixtureRoot();
|
||||
await mkdir(join(root, "apps", "web", "app", "locale"), { recursive: true });
|
||||
|
||||
await writeFile(
|
||||
join(root, "apps", "web", "app", "locale", "request-scope.ts"),
|
||||
[
|
||||
'export const storage = Symbol.for("hivegrid.i18n.request-storage");',
|
||||
"export async function runWithRequestScope<T>(request: Request, callback: () => Promise<T>): Promise<T> {",
|
||||
" return callback();",
|
||||
"}",
|
||||
].join("\n"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const result = await scanHardcodedStrings(root);
|
||||
|
||||
expect(result.totalForbidden).toBe(0);
|
||||
expect(result.reviewedCounts["brand-literal"]).toBe(1);
|
||||
expect(result.historicalCounts["brand-literal"]).toBe(0);
|
||||
expect(result.historicalCounts["jsx-text"]).toBe(0);
|
||||
});
|
||||
|
||||
it("allows OpenAPI contract descriptions without moving the i18n historical baseline", async () => {
|
||||
const root = await createFixtureRoot();
|
||||
await mkdir(join(root, "apps", "api", "src"), { recursive: true });
|
||||
@@ -167,6 +213,23 @@ describe("i18n Hardcoded Strings hardcoded-string drift guard", () => {
|
||||
expect(result.historicalCounts["user-facing-prop-literal"]).toBe(0);
|
||||
});
|
||||
|
||||
it("classifies every static locale catalog string as reviewed translation copy", async () => {
|
||||
const root = await createFixtureRoot();
|
||||
await mkdir(join(root, "apps", "web", "public", "locales", "pl"), { recursive: true });
|
||||
await writeFile(
|
||||
join(root, "apps", "web", "public", "locales", "pl", "translations.json"),
|
||||
'{"description":"HiveGrid jest dostępny","markup":"<p>Widoczny tekst produktu</p>"}\n',
|
||||
"utf8"
|
||||
);
|
||||
|
||||
const result = await scanHardcodedStrings(root);
|
||||
|
||||
expect(result.totalForbidden).toBe(0);
|
||||
expect(result.reviewedCounts["brand-literal"]).toBe(1);
|
||||
expect(result.reviewedCounts["jsx-text"]).toBe(1);
|
||||
expect(result.totalHistorical).toBe(0);
|
||||
});
|
||||
|
||||
it("reports historical baseline drift separately from reviewed allowlists", async () => {
|
||||
const root = await createFixtureRoot();
|
||||
await mkdir(join(root, "apps", "web", "app", "routes"), { recursive: true });
|
||||
|
||||
Reference in new issue
Block a user