Files
pleno-vue/tests/unit/system-search-route-contract.spec.js
T

29 lines
1.3 KiB
JavaScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const root = process.cwd();
const routerSource = readFileSync(join(root, "src/router.js"), "utf8");
const recordPageSource = readFileSync(join(root, "src/views/search/SystemSearchRecordPage.vue"), "utf8");
describe("system search generic record route contract", () => {
it("registers authenticated generic record route in router", () => {
expect(routerSource).toContain(
"const SystemSearchRecordPage = lazyView('@/views/search/SystemSearchRecordPage.vue');"
);
expect(routerSource).toContain("name: 'systemsearchrecord'");
expect(routerSource).toContain("path: '/search/system/record/:entityType/:entityId'");
expect(routerSource).toContain("component: SystemSearchRecordPage");
expect(routerSource).toContain("meta: { middleware: authMiddleware }");
});
});
describe("system search generic record page lookup contract", () => {
it("hydrates from state and falls back to /search/system lookup", () => {
expect(recordPageSource).toContain("systemSearchResult");
expect(recordPageSource).toContain("SessionUser.request('/search/system', 'POST', body)");
expect(recordPageSource).toContain("include_types: [entityType.value]");
expect(recordPageSource).toContain("allowGenericFallback: false");
});
});