chore(core): Use roles from database in global roles (#18768)

This commit is contained in:
Andreas Fitzek
2025-08-26 17:53:46 +02:00
committed by GitHub
parent cff3f4a67e
commit ecad12b77a
117 changed files with 956 additions and 424 deletions

View File

@@ -6,7 +6,12 @@ import {
randomValidPassword,
} from '@n8n/backend-test-utils';
import type { User } from '@n8n/db';
import { ProjectRelationRepository, UserRepository } from '@n8n/db';
import {
GLOBAL_ADMIN_ROLE,
GLOBAL_MEMBER_ROLE,
ProjectRelationRepository,
UserRepository,
} from '@n8n/db';
import { Container } from '@n8n/di';
import { Not } from '@n8n/typeorm';
@@ -52,7 +57,7 @@ describe('InvitationController', () => {
describe('POST /invitations/:id/accept', () => {
test('should fill out a member shell', async () => {
const memberShell = await createUserShell('global:member');
const memberShell = await createUserShell(GLOBAL_MEMBER_ROLE);
const memberProps = {
inviterId: instanceOwner.id,
@@ -83,7 +88,7 @@ describe('InvitationController', () => {
});
test('should fill out an admin shell', async () => {
const adminShell = await createUserShell('global:admin');
const adminShell = await createUserShell(GLOBAL_ADMIN_ROLE);
const memberProps = {
inviterId: instanceOwner.id,
@@ -116,7 +121,7 @@ describe('InvitationController', () => {
test('should fail with invalid payloads', async () => {
const memberShell = await userRepository.save({
email: randomEmail(),
role: 'global:member',
role: { slug: 'global:member' },
});
const invalidPaylods = [
@@ -374,7 +379,7 @@ describe('InvitationController', () => {
mailer.invite.mockResolvedValue({ emailSent: true });
const member = await createMember();
const memberShell = await createUserShell('global:member');
const memberShell = await createUserShell(GLOBAL_MEMBER_ROLE);
const newUserEmail = randomEmail();
const existingUserEmails = [member.email];