Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+89
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
const routesDir = path.join(repoRoot, "apps/web/app/routes/app.$tenant");
|
||||
|
||||
function read(relative: string): string {
|
||||
return fs.readFileSync(path.join(routesDir, relative), "utf8");
|
||||
}
|
||||
|
||||
function localeCrm(locale: string): Record<string, unknown> {
|
||||
const json = JSON.parse(fs.readFileSync(path.join(repoRoot, `apps/web/public/locales/${locale}/translations.json`), "utf8"));
|
||||
return json.crm as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function hasKey(root: Record<string, unknown>, dotted: string): boolean {
|
||||
// `dotted` is a `crm.…` key; resolve the part after the `crm.` prefix.
|
||||
const segments = dotted.replace(/^crm\./, "").split(".");
|
||||
let node: unknown = root;
|
||||
for (const segment of segments) {
|
||||
if (!node || typeof node !== "object") return false;
|
||||
node = (node as Record<string, unknown>)[segment];
|
||||
}
|
||||
return typeof node === "string";
|
||||
}
|
||||
|
||||
describe("CRM contact routes (R-P6 slice 4)", () => {
|
||||
it("build the list/detail view-models server-side via the shared loaders", () => {
|
||||
const list = read("contacts._index.tsx");
|
||||
expect(list).toContain("export const loader");
|
||||
expect(list).toContain("export const action");
|
||||
expect(list).toContain("loadKontaktListData");
|
||||
expect(list).toContain("handleKontaktListAction");
|
||||
expect(list).not.toContain("useFetcher");
|
||||
|
||||
const companies = read("contacts.companies._index.tsx");
|
||||
expect(companies).toContain('variant: "companies"');
|
||||
|
||||
const detail = read("contacts.$id.tsx");
|
||||
expect(detail).toContain("loadKontaktDetailData");
|
||||
expect(detail).toContain("handleKontaktDetailAction");
|
||||
|
||||
const newRoute = read("contacts.new.tsx");
|
||||
expect(newRoute).toContain('intent === "checkDuplicates"');
|
||||
expect(newRoute).toContain("findDuplicateKontakte");
|
||||
|
||||
const exportRoute = read("contacts.export.tsx");
|
||||
expect(exportRoute).toContain("buildKontaktCsv");
|
||||
expect(exportRoute).toContain("text/csv");
|
||||
});
|
||||
|
||||
it("gates admin routes on crm.admin and the lists on crm.read_own", () => {
|
||||
expect(read("contacts._index.tsx") + read("contacts.$id.tsx")).toContain("crm.read_own");
|
||||
for (const file of ["contacts.admin.custom-fields.tsx", "contacts.admin.tags.tsx", "contacts.admin.duplicates.tsx"]) {
|
||||
expect(read(file)).toContain('requireCrmPermission(ctx, "crm.admin")');
|
||||
}
|
||||
});
|
||||
|
||||
it("has de + en translations for the keys the routes reference", () => {
|
||||
const keys = [
|
||||
"crm.contacts.title",
|
||||
"crm.companies.title",
|
||||
"crm.new.title",
|
||||
"crm.locked.headline",
|
||||
"crm.empty.contacts.headline",
|
||||
"crm.kontaktTyp.privatperson",
|
||||
"crm.kontaktStatus.kunde",
|
||||
"crm.orgMerkmal.gmbh",
|
||||
"crm.kontaktArt.hauptkontakt",
|
||||
"crm.datentyp.waehrung",
|
||||
"crm.activity.contact_created",
|
||||
"crm.duplicate.reason.email",
|
||||
"crm.duplicate.matchType.hard",
|
||||
"crm.error.nameRequired",
|
||||
"crm.error.tagNameExists",
|
||||
"crm.detail.section.activity",
|
||||
"crm.admin.customFields.title",
|
||||
"crm.admin.tags.usage",
|
||||
"crm.pagination.page",
|
||||
];
|
||||
const de = localeCrm("de");
|
||||
const en = localeCrm("en");
|
||||
for (const key of keys) {
|
||||
expect(hasKey(de, key), `de missing ${key}`).toBe(true);
|
||||
expect(hasKey(en, key), `en missing ${key}`).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user