Enhance: コンディショナルロールの条件に「マニュアルロールへのアサイン」を追加 (#13463)

* コンディショナルロールの条件に「マニュアルロールへのアサイン」を追加

* コメント修正
This commit is contained in:
zawa-ch 2024-02-27 18:45:46 +09:00 committed by GitHub
parent 0fb7b98f96
commit f906ad6ca7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 97 additions and 9 deletions

View file

@ -251,6 +251,34 @@ describe('RoleService', () => {
expect(user2Policies.canManageCustomEmojis).toBe(true);
});
test('コンディショナルロール: マニュアルロールにアサイン済み', async () => {
const [user1, user2, role1] = await Promise.all([
createUser(),
createUser(),
createRole({
name: 'manual role',
}),
]);
const role2 = await createRole({
name: 'conditional role',
target: 'conditional',
condFormula: {
// idはバックエンドのロジックに必要ない
id: 'bdc612bd-9d54-4675-ae83-0499c82ea670',
type: 'roleAssignedTo',
roleId: role1.id,
},
});
await roleService.assign(user2.id, role1.id);
const [u1role, u2role] = await Promise.all([
roleService.getUserRoles(user1.id),
roleService.getUserRoles(user2.id),
]);
expect(u1role.some(r => r.id === role2.id)).toBe(false);
expect(u2role.some(r => r.id === role2.id)).toBe(true);
});
test('expired role', async () => {
const user = await createUser();
const role = await createRole({