chore: fix tests, remove unnecessary imports

This commit is contained in:
Danny Avila 2025-07-10 22:23:50 -04:00
parent ec1a8567a4
commit 4caac90909
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
5 changed files with 108 additions and 106 deletions

View file

@ -165,7 +165,8 @@ describe('Access Middleware', () => {
expect(result).toBe(false);
});
test('should return true if user has any of multiple permissions', async () => {
test('should return false if user has only some of multiple permissions', async () => {
// User has USE but not CREATE, so should fail when checking for both
const result = await checkAccess({
req: {},
user: { id: 'user123', role: 'user' },
@ -173,6 +174,18 @@ describe('Access Middleware', () => {
permissions: [Permissions.CREATE, Permissions.USE],
getRoleByName,
});
expect(result).toBe(false);
});
test('should return true if user has all of multiple permissions', async () => {
// Admin has both USE and CREATE
const result = await checkAccess({
req: {},
user: { id: 'admin123', role: 'admin' },
permissionType: PermissionTypes.AGENTS,
permissions: [Permissions.CREATE, Permissions.USE],
getRoleByName,
});
expect(result).toBe(true);
});