revert
This commit is contained in:
parent
032dc79210
commit
6651fd378a
|
@ -102,33 +102,33 @@ describe('RoleService', () => {
|
|||
});
|
||||
|
||||
describe('getUserPolicies', () => {
|
||||
test('instance default policies', async () => {
|
||||
test('instance default policies', async () => {
|
||||
const user = await createUser();
|
||||
metaService.fetch.mockResolvedValue({
|
||||
policies: {
|
||||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
||||
expect(result.canManageCustomEmojis).toBe(false);
|
||||
});
|
||||
|
||||
test('instance default policies 2', async () => {
|
||||
|
||||
test('instance default policies 2', async () => {
|
||||
const user = await createUser();
|
||||
metaService.fetch.mockResolvedValue({
|
||||
policies: {
|
||||
canManageCustomEmojis: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
||||
expect(result.canManageCustomEmojis).toBe(true);
|
||||
});
|
||||
|
||||
test('with role', async () => {
|
||||
|
||||
test('with role', async () => {
|
||||
const user = await createUser();
|
||||
const role = await createRole({
|
||||
name: 'a',
|
||||
|
@ -146,48 +146,48 @@ describe('RoleService', () => {
|
|||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
||||
expect(result.canManageCustomEmojis).toBe(true);
|
||||
});
|
||||
|
||||
// test('priority', async () => {
|
||||
// const user = await createUser();
|
||||
// const role1 = await createRole({
|
||||
// name: 'role1',
|
||||
// policies: {
|
||||
// driveCapacityMb: {
|
||||
// useDefault: false,
|
||||
// priority: 0,
|
||||
// value: 200,
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// const role2 = await createRole({
|
||||
// name: 'role2',
|
||||
// policies: {
|
||||
// driveCapacityMb: {
|
||||
// useDefault: false,
|
||||
// priority: 1,
|
||||
// value: 100,
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// await assign(role1.id, user.id);
|
||||
// await assign(role2.id, user.id);
|
||||
// metaService.fetch.mockResolvedValue({
|
||||
// policies: {
|
||||
// driveCapacityMb: 50,
|
||||
// },
|
||||
// } as any);
|
||||
test('priority', async () => {
|
||||
const user = await createUser();
|
||||
const role1 = await createRole({
|
||||
name: 'role1',
|
||||
policies: {
|
||||
driveCapacityMb: {
|
||||
useDefault: false,
|
||||
priority: 0,
|
||||
value: 200,
|
||||
},
|
||||
},
|
||||
});
|
||||
const role2 = await createRole({
|
||||
name: 'role2',
|
||||
policies: {
|
||||
driveCapacityMb: {
|
||||
useDefault: false,
|
||||
priority: 1,
|
||||
value: 100,
|
||||
},
|
||||
},
|
||||
});
|
||||
await assign(role1.id, user.id);
|
||||
await assign(role2.id, user.id);
|
||||
metaService.fetch.mockResolvedValue({
|
||||
policies: {
|
||||
driveCapacityMb: 50,
|
||||
},
|
||||
} as any);
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
expect(result.driveCapacityMb).toBe(100);
|
||||
});
|
||||
|
||||
// const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
// expect(result.driveCapacityMb).toBe(100);
|
||||
// });
|
||||
|
||||
test('conditional role', async () => {
|
||||
test('conditional role', async () => {
|
||||
const user1 = await createUser({
|
||||
createdAt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
||||
});
|
||||
|
@ -222,7 +222,7 @@ describe('RoleService', () => {
|
|||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
|
||||
|
||||
const user1Policies = await roleService.getUserPolicies(user1.id);
|
||||
const user2Policies = await roleService.getUserPolicies(user2.id);
|
||||
expect(user1Policies.canManageCustomEmojis).toBe(false);
|
||||
|
|
Loading…
Reference in a new issue