429f991bde
Project CI / AI game creator shell Rust shard 2/4 (push) Failing after 19s
Project CI / AI game creator shell Rust shard 3/4 (push) Failing after 20s
Project CI / AI game creator shell Rust shard 1/4 (push) Failing after 20s
Project CI / AI game creator shell Rust shard 4/4 (push) Failing after 20s
Project CI / Backend tests (push) Failing after 17s
Project CI / AI game creator shell Rust crates (push) Failing after 17s
Project CI / AI game creator shell Rust smoke (push) Failing after 19s
Project CI / Native shell tests (push) Failing after 18s
Project CI / Frontend tests (push) Failing after 8s
Project CI / AI game creator shell web tests (push) Failing after 15s
Project CI / Repository checks (push) Failing after 17s
- 撤销 39aed2e48 夹带的游戏分发前后端、SpacetimeDB 绑定、主站路由、后台审核页、文档与 nginx 改动,master 恢复可编译状态
- 保留该提交自身的 AGC 发号改动:agc-global-version.mjs 与其参数构造单测
- 恢复被误删的 output 产物,避免把无关清理混进该提交
- 补回两篇技术文档在 docs/README.md 的索引(它们属于后续两个补提交文档,不属于游戏分发)
- 游戏分发完整实现保留在 codex/game-distribution 分支继续开发
150 lines
4.6 KiB
TypeScript
150 lines
4.6 KiB
TypeScript
import { expect, test } from 'vitest';
|
|
|
|
import {
|
|
adminRoutes,
|
|
getAccessibleAdminRoutes,
|
|
resolveAccessibleAdminRoute,
|
|
resolveAdminRoute,
|
|
routeHash,
|
|
} from './adminRoutes';
|
|
|
|
test('后台默认进入 Dashboard', () => {
|
|
expect(adminRoutes[0]).toEqual({
|
|
id: 'dashboard',
|
|
label: 'Dashboard',
|
|
hash: '#dashboard',
|
|
});
|
|
expect(resolveAdminRoute('')).toBe('dashboard');
|
|
expect(resolveAdminRoute('#unknown')).toBe('dashboard');
|
|
expect(routeHash('dashboard')).toBe('#dashboard');
|
|
});
|
|
|
|
test('后台模型定价路由可通过导航和 hash 访问', () => {
|
|
expect(adminRoutes).toContainEqual({
|
|
id: 'editor-generation-pricing',
|
|
label: '模型定价',
|
|
hash: '#editor-generation-pricing',
|
|
});
|
|
expect(resolveAdminRoute('#editor-generation-pricing')).toBe(
|
|
'editor-generation-pricing',
|
|
);
|
|
expect(routeHash('editor-generation-pricing')).toBe(
|
|
'#editor-generation-pricing',
|
|
);
|
|
});
|
|
|
|
test('后台灰度发布路由可通过导航和 hash 访问', () => {
|
|
expect(adminRoutes).toContainEqual({
|
|
id: 'gray-release',
|
|
label: '灰度发布',
|
|
hash: '#gray-release',
|
|
});
|
|
expect(resolveAdminRoute('#gray-release')).toBe('gray-release');
|
|
expect(routeHash('gray-release')).toBe('#gray-release');
|
|
});
|
|
|
|
test('后台不再暴露旧创作模板管理路由', () => {
|
|
expect(resolveAdminRoute('#creation-entry')).toBe('dashboard');
|
|
expect(resolveAdminRoute('#creation-announcement')).toBe('dashboard');
|
|
expect(resolveAdminRoute('#work-visibility')).toBe('dashboard');
|
|
});
|
|
|
|
test('后台素材查询路由可通过导航和 hash 访问', () => {
|
|
expect(adminRoutes).toContainEqual({
|
|
id: 'editor-assets',
|
|
label: '素材查询',
|
|
hash: '#editor-assets',
|
|
});
|
|
expect(resolveAdminRoute('#editor-assets')).toBe('editor-assets');
|
|
expect(routeHash('editor-assets')).toBe('#editor-assets');
|
|
});
|
|
|
|
test('后台精选审核路由可通过导航和 hash 访问', () => {
|
|
expect(adminRoutes).toContainEqual({
|
|
id: 'editor-showcase',
|
|
label: '精选审核',
|
|
hash: '#editor-showcase',
|
|
});
|
|
expect(resolveAdminRoute('#editor-showcase')).toBe('editor-showcase');
|
|
expect(routeHash('editor-showcase')).toBe('#editor-showcase');
|
|
});
|
|
|
|
test('后台充值管理路由可通过导航和 hash 访问', () => {
|
|
expect(adminRoutes).toContainEqual({
|
|
id: 'recharge-orders',
|
|
label: '充值管理',
|
|
hash: '#recharge-orders',
|
|
});
|
|
expect(resolveAdminRoute('#recharge-orders')).toBe('recharge-orders');
|
|
expect(routeHash('recharge-orders')).toBe('#recharge-orders');
|
|
});
|
|
|
|
test('owner 可访问全部业务 Tab 和账号管理', () => {
|
|
const routes = getAccessibleAdminRoutes({
|
|
accountRole: 'owner',
|
|
tabPermissions: [],
|
|
});
|
|
expect(routes).toEqual(adminRoutes);
|
|
expect(routes.at(-1)).toMatchObject({ id: 'accounts', ownerOnly: true });
|
|
});
|
|
|
|
test('member 只访问已分配 Tab 且无权 hash 回落到第一项', () => {
|
|
const routes = getAccessibleAdminRoutes({
|
|
accountRole: 'member',
|
|
tabPermissions: ['tracking', 'recharge-orders'],
|
|
});
|
|
expect(routes.map((route) => route.id)).toEqual([
|
|
'tracking',
|
|
'recharge-orders',
|
|
]);
|
|
expect(resolveAccessibleAdminRoute('#accounts', routes)).toBe('tracking');
|
|
expect(resolveAccessibleAdminRoute('#recharge-orders', routes)).toBe(
|
|
'recharge-orders',
|
|
);
|
|
});
|
|
|
|
test('member 可单独获得灰度发布 Tab 权限', () => {
|
|
const routes = getAccessibleAdminRoutes({
|
|
accountRole: 'member',
|
|
tabPermissions: ['gray-release'],
|
|
});
|
|
expect(routes.map((route) => route.id)).toEqual(['gray-release']);
|
|
expect(resolveAccessibleAdminRoute('#gray-release', routes)).toBe(
|
|
'gray-release',
|
|
);
|
|
});
|
|
|
|
test('零权限 member 不回落到 Dashboard', () => {
|
|
const routes = getAccessibleAdminRoutes({
|
|
accountRole: 'member',
|
|
tabPermissions: [],
|
|
});
|
|
expect(routes).toEqual([]);
|
|
expect(resolveAccessibleAdminRoute('#dashboard', routes)).toBeNull();
|
|
});
|
|
|
|
test('项目工程入口对 owner 与已授权 member 开放且可分配权限', () => {
|
|
const route = {
|
|
id: 'project-snapshots',
|
|
label: '项目工程',
|
|
hash: '#project-snapshots',
|
|
};
|
|
expect(adminRoutes.filter((item) => !item.ownerOnly)).toContainEqual(route);
|
|
expect(resolveAdminRoute('#project-snapshots')).toBe('project-snapshots');
|
|
expect(
|
|
getAccessibleAdminRoutes({ accountRole: 'owner', tabPermissions: [] }),
|
|
).toContainEqual(route);
|
|
expect(
|
|
getAccessibleAdminRoutes({
|
|
accountRole: 'member',
|
|
tabPermissions: ['project-snapshots'],
|
|
}),
|
|
).toEqual([route]);
|
|
expect(
|
|
getAccessibleAdminRoutes({
|
|
accountRole: 'member',
|
|
tabPermissions: ['tracking'],
|
|
}),
|
|
).not.toContainEqual(route);
|
|
});
|