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:
Val
2023-11-30 08:23:09 +00:00
committed by GitHub
parent b16dd21909
commit 5f4a9524ec
12 changed files with 124 additions and 94 deletions

View File

@@ -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);