mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +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,8 +1,6 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { License } from '@/License';
|
||||
import type { User } from '@db/entities/User';
|
||||
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import * as testDb from './shared/testDb';
|
||||
import * as utils from './shared/utils/';
|
||||
import { createOwner, createUser } from './shared/db/users';
|
||||
@@ -14,13 +12,11 @@ let authOwnerAgent: SuperAgentTest;
|
||||
let member: User;
|
||||
let authMemberAgent: SuperAgentTest;
|
||||
|
||||
const licenseLike = mockInstance(License, {
|
||||
isWorkflowHistoryLicensed: jest.fn().mockReturnValue(true),
|
||||
isWithinUsersLimit: jest.fn().mockReturnValue(true),
|
||||
const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['workflowHistory'],
|
||||
enabledFeatures: ['feat:workflowHistory'],
|
||||
});
|
||||
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['workflowHistory'] });
|
||||
|
||||
beforeAll(async () => {
|
||||
owner = await createOwner();
|
||||
authOwnerAgent = testServer.authAgentFor(owner);
|
||||
@@ -28,17 +24,13 @@ beforeAll(async () => {
|
||||
authMemberAgent = testServer.authAgentFor(member);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
licenseLike.isWorkflowHistoryLicensed.mockReturnValue(true);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await testDb.truncate(['Workflow', 'SharedWorkflow', 'WorkflowHistory']);
|
||||
});
|
||||
|
||||
describe('GET /workflow-history/:workflowId', () => {
|
||||
test('should not work when license is not available', async () => {
|
||||
licenseLike.isWorkflowHistoryLicensed.mockReturnValue(false);
|
||||
testServer.license.disable('feat:workflowHistory');
|
||||
const resp = await authOwnerAgent.get('/workflow-history/workflow/badid');
|
||||
expect(resp.status).toBe(403);
|
||||
expect(resp.text).toBe('Workflow History license data not found');
|
||||
@@ -165,7 +157,7 @@ describe('GET /workflow-history/:workflowId', () => {
|
||||
|
||||
describe('GET /workflow-history/workflow/:workflowId/version/:versionId', () => {
|
||||
test('should not work when license is not available', async () => {
|
||||
licenseLike.isWorkflowHistoryLicensed.mockReturnValue(false);
|
||||
testServer.license.disable('feat:workflowHistory');
|
||||
const resp = await authOwnerAgent.get('/workflow-history/workflow/badid/version/badid');
|
||||
expect(resp.status).toBe(403);
|
||||
expect(resp.text).toBe('Workflow History license data not found');
|
||||
|
||||
Reference in New Issue
Block a user