114 lines
3.6 KiB
TypeScript
114 lines
3.6 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
|
|
async function readSource(path: string) {
|
|
return readFile(new URL(path, import.meta.url), "utf8");
|
|
}
|
|
|
|
test("independent Boss admin web app declares Vue Ant Design Vue runtime", async () => {
|
|
const source = await readSource("../apps/boss-admin-web/package.json");
|
|
const pkg = JSON.parse(source);
|
|
|
|
assert.equal(pkg.name, "@boss/admin-web");
|
|
assert.equal(pkg.private, true);
|
|
assert.match(pkg.scripts.dev, /vite/);
|
|
assert.match(pkg.scripts.build, /vite build/);
|
|
assert.ok(pkg.dependencies.vue);
|
|
assert.ok(pkg.dependencies["ant-design-vue"]);
|
|
assert.ok(pkg.devDependencies.vite);
|
|
assert.ok(pkg.devDependencies["@vitejs/plugin-vue"]);
|
|
});
|
|
|
|
test("independent Boss admin web app uses the backoffice BFF with cookie session", async () => {
|
|
const apiSource = await readSource("../apps/boss-admin-web/src/api/bossAdmin.ts");
|
|
|
|
assert.match(apiSource, /\/api\/v1\/admin\/backoffice/);
|
|
assert.match(apiSource, /\/api\/v1\/admin\/access/);
|
|
assert.match(apiSource, /\/api\/v1\/admin\/risks\/actions/);
|
|
assert.match(apiSource, /\/api\/v1\/admin\/skills\/requests/);
|
|
assert.match(apiSource, /credentials:\s*["']include["']/);
|
|
assert.match(apiSource, /menuTree/);
|
|
assert.match(apiSource, /tenants/);
|
|
assert.match(apiSource, /resourceGroups/);
|
|
for (const fn of ["postAdminAccess", "postRiskAction", "postSkillLifecycleRequest"]) {
|
|
assert.match(apiSource, new RegExp(`function\\s+${fn}|const\\s+${fn}`));
|
|
}
|
|
});
|
|
|
|
test("independent Boss admin web app includes enterprise management sections", async () => {
|
|
const appSource = await readSource("../apps/boss-admin-web/src/App.vue");
|
|
|
|
for (const label of [
|
|
"Boss 企业后台",
|
|
"工作台",
|
|
"租户管理",
|
|
"账号管理",
|
|
"角色权限",
|
|
"资源授权",
|
|
"Skill 中心",
|
|
"风险告警",
|
|
"审计日志",
|
|
]) {
|
|
assert.match(appSource, new RegExp(label));
|
|
}
|
|
assert.match(appSource, /menuTree/);
|
|
assert.match(appSource, /workbench/);
|
|
assert.match(appSource, /tenants/);
|
|
});
|
|
|
|
test("independent Boss admin web app exposes management actions instead of read only tables", async () => {
|
|
const appSource = await readSource("../apps/boss-admin-web/src/App.vue");
|
|
|
|
for (const label of [
|
|
"新建租户",
|
|
"启用租户",
|
|
"停用租户",
|
|
"新建账号",
|
|
"重置密码",
|
|
"离职回收",
|
|
"分配资源",
|
|
"套用权限模板",
|
|
"撤销授权",
|
|
"指派负责人",
|
|
"设置 SLA",
|
|
"确认风险",
|
|
"关闭风险",
|
|
"创建工单",
|
|
"创建 Skill 请求",
|
|
]) {
|
|
assert.match(appSource, new RegExp(label));
|
|
}
|
|
|
|
for (const action of [
|
|
"upsert_company",
|
|
"set_company_status",
|
|
"upsert_account",
|
|
"reset_account_password",
|
|
"reclaim_account",
|
|
"apply_template",
|
|
"grant_device",
|
|
"grant_project",
|
|
"grant_skill",
|
|
"revoke_grant",
|
|
]) {
|
|
assert.match(appSource, new RegExp(action));
|
|
}
|
|
});
|
|
|
|
test("root Next project isolates the independent Vue admin workspace", async () => {
|
|
const [tsconfigSource, eslintSource, rootPkgSource] = await Promise.all([
|
|
readSource("../tsconfig.json"),
|
|
readSource("../eslint.config.mjs"),
|
|
readSource("../package.json"),
|
|
]);
|
|
const tsconfig = JSON.parse(tsconfigSource);
|
|
const rootPkg = JSON.parse(rootPkgSource);
|
|
|
|
assert.ok(tsconfig.exclude.includes("apps/boss-admin-web/**"));
|
|
assert.match(eslintSource, /apps\/boss-admin-web\/\*\*/);
|
|
assert.match(eslintSource, /public\/admin-web\/\*\*/);
|
|
assert.match(rootPkg.scripts["admin:web:dev"], /apps\/boss-admin-web/);
|
|
assert.match(rootPkg.scripts["admin:web:build"], /apps\/boss-admin-web/);
|
|
});
|