完善:同月多文件导入与当前用户离线迁移更新
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import ts from 'typescript';
|
||||
|
||||
const source = ts.transpileModule(readFileSync(new URL('../src/userRoles.ts', import.meta.url), 'utf8'), {
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext },
|
||||
}).outputText.replace(/export /g, '');
|
||||
const { USER_ROLE_OPTIONS, canAccessWorkspacePage } = new Function(`${source};return { USER_ROLE_OPTIONS, canAccessWorkspacePage };`)();
|
||||
|
||||
test('only three assigned roles are exposed with the agreed names', () => {
|
||||
assert.deepEqual(USER_ROLE_OPTIONS, [{ value: 'USER', label: '用户' }, { value: 'DATA_ADMIN', label: '数据管理员' }, { value: 'SYSTEM_ADMIN', label: '系统管理员' }]);
|
||||
});
|
||||
|
||||
test('higher roles inherit business pages while system settings stay system-only', () => {
|
||||
for (const role of ['USER', 'DATA_ADMIN', 'SYSTEM_ADMIN']) {
|
||||
const user = { roles: [role] };
|
||||
for (const page of ['overall', 'department', 'product', 'blackProduct', 'brightProduct', 'analysis'])
|
||||
assert.equal(canAccessWorkspacePage(user, page), true, `${role}: ${page}`);
|
||||
for (const page of ['sources', 'imports', 'rules', 'mappings', 'masterData', 'tasks'])
|
||||
assert.equal(canAccessWorkspacePage(user, page), role !== 'USER', `${role}: ${page}`);
|
||||
assert.equal(canAccessWorkspacePage(user, 'access'), role === 'SYSTEM_ADMIN');
|
||||
}
|
||||
});
|
||||
|
||||
test('unexpected or multiple role assignments do not expose management pages', () => {
|
||||
for (const roles of [[], ['QUALITY_VIEWER'], ['USER', 'SYSTEM_ADMIN']])
|
||||
assert.equal(canAccessWorkspacePage({ roles }, 'access'), false);
|
||||
});
|
||||
Reference in New Issue
Block a user