mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Remove roleId indirection (no-changelog) (#8413)
This commit is contained in:
committed by
GitHub
parent
1affebd85e
commit
d6deceacde
@@ -44,7 +44,7 @@ describe('MeController', () => {
|
||||
id: '123',
|
||||
password: 'password',
|
||||
authIdentities: [],
|
||||
globalRoleId: '1',
|
||||
role: 'global:owner',
|
||||
});
|
||||
const reqBody = { email: 'valid@email.com', firstName: 'John', lastName: 'Potato' };
|
||||
const req = mock<MeRequest.UserUpdate>({ user, body: reqBody });
|
||||
@@ -79,7 +79,7 @@ describe('MeController', () => {
|
||||
id: '123',
|
||||
password: 'password',
|
||||
authIdentities: [],
|
||||
globalRoleId: '1',
|
||||
role: 'global:owner',
|
||||
});
|
||||
const reqBody = { email: 'valid@email.com', firstName: 'John', lastName: 'Potato' };
|
||||
const req = mock<MeRequest.UserUpdate>({ user, body: reqBody });
|
||||
@@ -88,7 +88,7 @@ describe('MeController', () => {
|
||||
jest.spyOn(jwt, 'sign').mockImplementation(() => 'signed-token');
|
||||
|
||||
// Add invalid data to the request payload
|
||||
Object.assign(reqBody, { id: '0', globalRoleId: '42' });
|
||||
Object.assign(reqBody, { id: '0', role: '42' });
|
||||
|
||||
await controller.updateCurrentUser(req, res);
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('MeController', () => {
|
||||
expect(updatedUser.firstName).toBe(reqBody.firstName);
|
||||
expect(updatedUser.lastName).toBe(reqBody.lastName);
|
||||
expect(updatedUser.id).not.toBe('0');
|
||||
expect(updatedUser.globalRoleId).not.toBe('42');
|
||||
expect(updatedUser.role).not.toBe('42');
|
||||
});
|
||||
|
||||
it('should throw BadRequestError if beforeUpdate hook throws BadRequestError', async () => {
|
||||
@@ -107,11 +107,11 @@ describe('MeController', () => {
|
||||
id: '123',
|
||||
password: 'password',
|
||||
authIdentities: [],
|
||||
globalRoleId: '1',
|
||||
role: 'global:owner',
|
||||
});
|
||||
const reqBody = { email: 'valid@email.com', firstName: 'John', lastName: 'Potato' };
|
||||
const req = mock<MeRequest.UserUpdate>({ user, body: reqBody });
|
||||
userService.findOneOrFail.mockResolvedValue(user);
|
||||
// userService.findOneOrFail.mockResolvedValue(user);
|
||||
|
||||
externalHooks.run.mockImplementationOnce(async (hookName) => {
|
||||
if (hookName === 'user.profile.beforeUpdate') {
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('OAuth1CredentialController', () => {
|
||||
id: '123',
|
||||
password: 'password',
|
||||
authIdentities: [],
|
||||
globalRoleId: '1',
|
||||
role: 'global:owner',
|
||||
});
|
||||
const credential = mock<CredentialsEntity>({
|
||||
id: '1',
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('OAuth2CredentialController', () => {
|
||||
id: '123',
|
||||
password: 'password',
|
||||
authIdentities: [],
|
||||
globalRoleId: '1',
|
||||
role: 'global:owner',
|
||||
});
|
||||
const credential = mock<CredentialsEntity>({
|
||||
id: '1',
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('OwnerController', () => {
|
||||
it('should setup the instance owner successfully', async () => {
|
||||
const user = mock<User>({
|
||||
id: 'userId',
|
||||
globalRole: { scope: 'global', name: 'owner' },
|
||||
role: 'global:owner',
|
||||
authIdentities: [],
|
||||
});
|
||||
const req = mock<OwnerRequest.Post>({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { ICredentialTypes } from 'n8n-workflow';
|
||||
import config from '@/config';
|
||||
import type { TranslationRequest } from '@/controllers/translation.controller';
|
||||
import {
|
||||
@@ -7,10 +6,11 @@ import {
|
||||
CREDENTIAL_TRANSLATIONS_DIR,
|
||||
} from '@/controllers/translation.controller';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import type { CredentialTypes } from '@/CredentialTypes';
|
||||
|
||||
describe('TranslationController', () => {
|
||||
const configGetSpy = jest.spyOn(config, 'getEnv');
|
||||
const credentialTypes = mock<ICredentialTypes>();
|
||||
const credentialTypes = mock<CredentialTypes>();
|
||||
const controller = new TranslationController(credentialTypes);
|
||||
|
||||
describe('getCredentialTranslation', () => {
|
||||
|
||||
Reference in New Issue
Block a user