mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Add central license mock for integration tests (no-changelog) (#7871)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
import { License } from '@/License';
|
||||
|
||||
import * as utils from './shared/utils/';
|
||||
import * as testDb from './shared/testDb';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { createAdmin, createMember, createOwner } from './shared/db/users';
|
||||
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type { User } from '@db/entities/User';
|
||||
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['role'] });
|
||||
|
||||
const license = mockInstance(License, {
|
||||
isAdvancedPermissionsLicensed: jest.fn().mockReturnValue(true),
|
||||
isWithinUsersLimit: jest.fn().mockReturnValue(true),
|
||||
const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['role'],
|
||||
enabledFeatures: ['feat:advancedPermissions'],
|
||||
});
|
||||
|
||||
const license = testServer.license;
|
||||
|
||||
describe('GET /roles', () => {
|
||||
let owner: User;
|
||||
let admin: User;
|
||||
@@ -46,7 +43,7 @@ describe('GET /roles', () => {
|
||||
|
||||
describe('with advanced permissions licensed', () => {
|
||||
test.each(['owner', 'admin', 'member'])('should return all roles to %s', async (user) => {
|
||||
license.isAdvancedPermissionsLicensed.mockReturnValue(true);
|
||||
license.enable('feat:advancedPermissions');
|
||||
|
||||
const response = await toAgent[user].get('/roles').expect(200);
|
||||
|
||||
@@ -64,7 +61,7 @@ describe('GET /roles', () => {
|
||||
|
||||
describe('with advanced permissions not licensed', () => {
|
||||
test.each(['owner', 'admin', 'member'])('should return all roles to %s', async (user) => {
|
||||
license.isAdvancedPermissionsLicensed.mockReturnValue(false);
|
||||
license.disable('feat:advancedPermissions');
|
||||
|
||||
const response = await toAgent[user].get('/roles').expect(200);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user