mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
feat(core): Allow custom project roles from being set to a user project relation (#18926)
This commit is contained in:
committed by
GitHub
parent
5b5f60212a
commit
027edbe89d
@@ -41,6 +41,7 @@ import { createAdmin, createMember, createOwner, createUser, getUserById } from
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
import * as utils from './shared/utils/';
|
||||
import { validateUser } from './shared/utils/users';
|
||||
import { createRole } from '@test-integration/db/roles';
|
||||
|
||||
mockInstance(Telemetry);
|
||||
mockInstance(ExecutionService);
|
||||
@@ -1573,4 +1574,30 @@ describe('PATCH /users/:id/role', () => {
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.body.data).toStrictEqual({ success: true });
|
||||
});
|
||||
|
||||
test('should fail to change to non-existing role', async () => {
|
||||
const customRole = 'custom:project-role';
|
||||
await createRole({ slug: customRole, displayName: 'Custom Role', roleType: 'project' });
|
||||
const response = await ownerAgent.patch(`/users/${member.id}/role`).send({
|
||||
newRoleName: customRole,
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(400);
|
||||
expect(response.body.message).toBe('Role custom:project-role does not exist');
|
||||
});
|
||||
|
||||
test('should change to existing custom role', async () => {
|
||||
const customRole = 'custom:role';
|
||||
await createRole({ slug: customRole, displayName: 'Custom Role', roleType: 'global' });
|
||||
const response = await ownerAgent.patch(`/users/${member.id}/role`).send({
|
||||
newRoleName: customRole,
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.body.data).toStrictEqual({ success: true });
|
||||
|
||||
const user = await getUserById(member.id);
|
||||
|
||||
expect(user.role.slug).toBe(customRole);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user