Files
Cloud-Tour-to-Libo/admin-web/tests/navigationSurface.test.ts
T

91 lines
3.5 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
const appSource = readFileSync(new URL("../src/App.tsx", import.meta.url), "utf8");
const dataCenterSource = readFileSync(
new URL("../src/panels/data-platform/DataCenterPanel.tsx", import.meta.url),
"utf8",
);
test("the schema viewer remains available as the only modeling page", () => {
assert.match(appSource, /key: "\/modeling\/schema", label: "本体 Schema"/);
assert.match(appSource, /path="\/admin\/modeling\/schema"/);
assert.doesNotMatch(appSource, /\/modeling\/(vocabulary|health)/);
});
test("retired management sections are absent from navigation and routes", () => {
for (const section of ["acquisition", "review", "publish", "workbench"]) {
assert.doesNotMatch(appSource, new RegExp(`/admin/${section}`));
assert.doesNotMatch(appSource, new RegExp(`key: "/${section}`));
}
for (const label of ["数据采集", "审核入藏", "图谱发布", "治理工作台"]) {
assert.doesNotMatch(appSource, new RegExp(label));
}
});
test("retired plaza pages are absent while the core plaza remains", () => {
for (const page of ["manual-ingest", "audit", "usage", "alerts"]) {
assert.doesNotMatch(appSource, new RegExp(`/admin/plaza/${page}`));
assert.doesNotMatch(appSource, new RegExp(`key: "/plaza/${page}`));
}
for (const page of ["overview", "user", "graph"]) {
assert.match(appSource, new RegExp(`/admin/plaza/${page}`));
}
});
test("retired system pages and the notification bell are absent", () => {
for (const page of ["areas", "notifications", "settings", "agents", "logs", "permissions"]) {
assert.doesNotMatch(appSource, new RegExp(`/admin/system/${page}`));
assert.doesNotMatch(appSource, new RegExp(`key: "/system/${page}`));
}
for (const component of [
"AreaManagement",
"Notifications",
"AgentSettings",
"AgentTasksPanel",
"LogsPanel",
"PermissionsAudit",
"NotificationBell",
]) {
assert.doesNotMatch(appSource, new RegExp(component));
}
assert.match(appSource, /key: "\/system\/users"[\s\S]*label: "用户管理"/);
assert.match(appSource, /path="\/admin\/system\/users"/);
});
test("the data center uses its own full-width workbench surface", () => {
assert.match(appSource, /const showDataCenterWorkbench = location\.pathname === "\/admin\/data"/);
assert.match(appSource, /\{!showDataCenterWorkbench && \(\s*<Sider/);
assert.match(appSource, /path="\/admin\/data" element=\{<DataCenterPanel canManage=\{isDataManager\} \/>\}/);
});
test("the data center entry opens the standalone URL in a new browser tab", () => {
assert.match(
appSource,
/if \(key === "\/data"\) \{\s*window\.open\("\/admin\/data", "_blank", "noopener,noreferrer"\)/,
);
});
test("database creation is a root action inside the data center tree", () => {
assert.doesNotMatch(dataCenterSource, /data-center-toolbar/);
assert.doesNotMatch(dataCenterSource, /PostgreSQL · 已连接/);
assert.match(dataCenterSource, /<Text strong>数据中心<\/Text>/);
const treeStart = dataCenterSource.indexOf('<div className="data-center-tree">');
const projectNode = dataCenterSource.indexOf("data-center-project-node", treeStart);
const createDatabase = dataCenterSource.indexOf("data-center-create-database", projectNode);
assert.ok(treeStart >= 0);
assert.ok(projectNode > treeStart);
assert.ok(createDatabase > projectNode);
assert.match(
dataCenterSource.slice(createDatabase, createDatabase + 260),
/onClick=\{openDatabaseCreate\}[\s\S]*新建数据库/,
);
});