62 行
3.6 KiB
TypeScript
62 行
3.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 adminRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const routesPath = path.join(adminRoot, 'src/routes.ts');
|
|
const layoutPath = path.join(adminRoot, 'src/layout.tsx');
|
|
const localePath = path.join(adminRoot, 'src/locale/index.ts');
|
|
const navBarPath = path.join(adminRoot, 'src/components/NavBar/index.tsx');
|
|
const subscribersPagePath = path.join(adminRoot, 'src/pages/platform/subscribers/index.tsx');
|
|
const renewalsPagePath = path.join(adminRoot, 'src/pages/platform/renewals/index.tsx');
|
|
const subscriptionsPagePath = path.join(adminRoot, 'src/pages/platform/subscriptions/index.tsx');
|
|
|
|
test('1. routes.ts 必须配置 platform 平台总控与会员/续费/订阅三大路由', () => {
|
|
const content = fs.readFileSync(routesPath, 'utf-8');
|
|
assert.ok(content.includes("key: 'platform'"), 'routes.ts 必须包含 platform 模块');
|
|
assert.ok(content.includes("key: 'platform/subscribers'"), 'routes.ts 必须包含 会员列表 路由');
|
|
assert.ok(content.includes("key: 'platform/renewals'"), 'routes.ts 必须包含 续费列表 路由');
|
|
assert.ok(content.includes("key: 'platform/subscriptions'"), 'routes.ts 必须包含 订阅管理 路由');
|
|
});
|
|
|
|
test('2. layout.tsx 必须为 platform 模块配置专属图标', () => {
|
|
const content = fs.readFileSync(layoutPath, 'utf-8');
|
|
assert.ok(content.includes("case 'platform':"), 'layout.tsx 必须处理 platform 模块的图标');
|
|
});
|
|
|
|
test('3. locale/index.ts 必须包含平台总控相关中英文词条', () => {
|
|
const content = fs.readFileSync(localePath, 'utf-8');
|
|
assert.ok(content.includes("'menu.platform':"), '缺少 menu.platform 国际化词条');
|
|
assert.ok(content.includes("'menu.platform.subscribers':"), '缺少 会员列表 国际化词条');
|
|
assert.ok(content.includes("'menu.platform.renewals':"), '缺少 续费列表 国际化词条');
|
|
assert.ok(content.includes("'menu.platform.subscriptions':"), '缺少 订阅管理 国际化词条');
|
|
});
|
|
|
|
test('4. NavBar 组件必须展示超级管理员 [最高权限] 身份标签', () => {
|
|
const content = fs.readFileSync(navBarPath, 'utf-8');
|
|
assert.ok(
|
|
content.includes('超级管理员') || content.includes('Platform Super Admin') || content.includes('最高权限'),
|
|
'NavBar 必须展示超级管理员或最高权限身份标识'
|
|
);
|
|
});
|
|
|
|
test('5. 平台总控三大页面文件必须存在且包含核心 Arco 组件与 API 路由', () => {
|
|
assert.ok(fs.existsSync(subscribersPagePath), '必须存在 platform/subscribers/index.tsx');
|
|
assert.ok(fs.existsSync(renewalsPagePath), '必须存在 platform/renewals/index.tsx');
|
|
assert.ok(fs.existsSync(subscriptionsPagePath), '必须存在 platform/subscriptions/index.tsx');
|
|
|
|
const subContent = fs.readFileSync(subscribersPagePath, 'utf-8');
|
|
assert.ok(subContent.includes('/api/admin/team/platform/subscribers'), '会员列表必须调用对应后端接口');
|
|
assert.ok(subContent.includes('Table'), '会员列表必须使用 Arco Table');
|
|
|
|
const renewContent = fs.readFileSync(renewalsPagePath, 'utf-8');
|
|
assert.ok(renewContent.includes('/api/admin/team/platform/renewals'), '续费列表必须调用对应后端接口');
|
|
assert.ok(renewContent.includes('Table'), '续费列表必须使用 Arco Table');
|
|
|
|
const planContent = fs.readFileSync(subscriptionsPagePath, 'utf-8');
|
|
assert.ok(planContent.includes('/api/admin/team/platform/plans'), '订阅管理必须调用对应后端接口');
|
|
assert.ok(planContent.includes('Card'), '订阅管理必须使用 Arco Card');
|
|
});
|