feat(imports): 导入向导兼容旧版工作簿并完善执行/预览
- 新增 xls 工作簿回退解析与测试 - 执行/预览/权限校验逻辑完善
This commit is contained in:
37
apps/server/src/imports/imports.access.spec.ts
Normal file
37
apps/server/src/imports/imports.access.spec.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { ForbiddenException } from '@nestjs/common';
|
||||
import { assertStepPermission, permittedStepKeys } from './imports.access';
|
||||
|
||||
describe('permittedStepKeys', () => {
|
||||
it('超级管理员拥有全部导入阶段', () => {
|
||||
expect(
|
||||
permittedStepKeys({ id: 1, permissions: [], isSuperAdmin: true }),
|
||||
).toEqual(['students', 'rooms', 'checkins', 'transfers']);
|
||||
});
|
||||
|
||||
it('按细分权限计算可提交阶段', () => {
|
||||
expect(
|
||||
permittedStepKeys({
|
||||
id: 1,
|
||||
permissions: ['student:import', 'room:edit', 'occupancy:checkin'],
|
||||
isSuperAdmin: false,
|
||||
}),
|
||||
).toEqual(['students', 'rooms', 'checkins']);
|
||||
});
|
||||
|
||||
it('无导入权限时仅返回空数组', () => {
|
||||
expect(
|
||||
permittedStepKeys({ id: 1, permissions: ['ai:chat:use'], isSuperAdmin: false }),
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('assertStepPermission', () => {
|
||||
it('无对应细分权限时拒绝提交', () => {
|
||||
expect(() =>
|
||||
assertStepPermission(
|
||||
{ id: 1, permissions: ['ai:chat:use'], isSuperAdmin: false },
|
||||
'transfers',
|
||||
),
|
||||
).toThrow(ForbiddenException);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user