Files
OmniRoute/tests/unit/traffic-inspector-beginner-header.test.ts
Diego Rodrigues de Sa e Souza b4ec7807ab Release v3.8.50
Release v3.8.50 — see CHANGELOG.md for the full entry.
2026-08-26 14:25:01 -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);
});