Files
OmniRoute/tests/unit/traffic-inspector-beginner-header.test.ts
ignamiranda 92f58603f9 Beginner UX: purpose-first Traffic Inspector header (#11283)
Validated on a 3-PR combined board: traffic-inspector-beginner-header suite green within the board's 30/30, typecheck:core + dashboard-typecheck clean, gates within baseline. Purpose-first orientation header for Traffic Inspector, existing inspection UI untouched. Thank you @ignamiranda!
2026-08-23 19:08:27 -03:00

45 lines
1.6 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const pagePath = path.join(
repoRoot,
"src/app/(dashboard)/dashboard/tools/traffic-inspector/page.tsx"
);
const clientPath = path.join(
repoRoot,
"src/app/(dashboard)/dashboard/tools/traffic-inspector/TrafficInspectorPageClient.tsx"
);
const enPath = path.join(repoRoot, "src/i18n/messages/en.json");
test("Traffic Inspector page passes translated title, subtitle, and purpose", () => {
const pageSource = fs.readFileSync(pagePath, "utf8");
assert.match(pageSource, /title=\{t\("trafficInspector"\)\}/);
assert.match(pageSource, /subtitle=\{t\("trafficInspectorSubtitle"\)\}/);
assert.match(pageSource, /purpose=\{t\("trafficInspectorPurpose"\)\}/);
});
test("Traffic Inspector client renders purpose-first header when props are provided", () => {
const clientSource = fs.readFileSync(clientPath, "utf8");
assert.match(clientSource, /title\s*&&/);
assert.match(clientSource, /subtitle\s*&&/);
assert.match(clientSource, /purpose\s*&&/);
});
test("Traffic Inspector beginner i18n keys exist in en.json", () => {
const en = JSON.parse(fs.readFileSync(enPath, "utf8"));
assert.equal(en.sidebar.trafficInspector, "Traffic Inspector");
assert.equal(
en.sidebar.trafficInspectorSubtitle,
"Inspect request and response traffic from your apps"
);
assert.equal(
typeof en.sidebar.trafficInspectorPurpose,
"string"
);
assert.ok(en.sidebar.trafficInspectorPurpose.length > 20);
});