test: harden business boundary conditions

This commit is contained in:
2026-07-15 00:03:55 +08:00
parent 17a5046ea0
commit b1f35f9d1a
65 changed files with 2311 additions and 293 deletions

View File

@@ -33,6 +33,23 @@ describe('JwtStrategy', () => {
});
});
it('recognizes the canonical super_admin role code even when the display name changes', async () => {
const userRepo = {
findOne: jest.fn().mockResolvedValue({
id: 1,
username: 'admin',
isActive: true,
isArchived: false,
roles: [{ name: '系统管理员', code: 'super_admin', status: 1, permissions: [] }],
}),
};
const strategy = new JwtStrategy(config as never, userRepo as never);
await expect(strategy.validate({ sub: 1 })).resolves.toEqual(
expect.objectContaining({ isSuperAdmin: true }),
);
});
it.each([
[{ id: 7, isActive: false, isArchived: false, roles: [] }],
[{ id: 7, isActive: true, isArchived: true, roles: [] }],