mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671)
This also gets rid of `Db.collection`, which was another source of circular dependencies.
This commit is contained in:
committed by
GitHub
parent
37dd658dc5
commit
000e76e3b4
@@ -1,18 +1,19 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import * as Db from '@/Db';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
import type { TagEntity } from '@db/entities/TagEntity';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
|
||||
|
||||
import { randomApiKey } from '../shared/random';
|
||||
import * as utils from '../shared/utils/';
|
||||
import * as testDb from '../shared/testDb';
|
||||
import Container from 'typedi';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
import { STARTING_NODES } from '@/constants';
|
||||
import { License } from '@/License';
|
||||
import { WorkflowHistoryRepository } from '@/databases/repositories';
|
||||
import Container from 'typedi';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
import type { TagEntity } from '@db/entities/TagEntity';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
|
||||
import type { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
|
||||
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { randomApiKey } from '../shared/random';
|
||||
import * as utils from '../shared/utils/';
|
||||
import * as testDb from '../shared/testDb';
|
||||
import { getAllRoles } from '../shared/db/roles';
|
||||
import { createUser } from '../shared/db/users';
|
||||
import { createWorkflow, createWorkflowWithTrigger } from '../shared/db/workflows';
|
||||
@@ -27,7 +28,7 @@ let workflowRunner: ActiveWorkflowRunner;
|
||||
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['publicApi'] });
|
||||
|
||||
const licenseLike = utils.mockInstance(License, {
|
||||
const licenseLike = mockInstance(License, {
|
||||
isWorkflowHistoryLicensed: jest.fn().mockReturnValue(false),
|
||||
isWithinUsersLimit: jest.fn().mockReturnValue(true),
|
||||
});
|
||||
@@ -58,7 +59,7 @@ beforeEach(async () => {
|
||||
'Tag',
|
||||
'Workflow',
|
||||
'Credentials',
|
||||
WorkflowHistoryRepository,
|
||||
'WorkflowHistory',
|
||||
]);
|
||||
|
||||
authOwnerAgent = testServer.publicApiAgentFor(owner);
|
||||
@@ -397,7 +398,7 @@ describe('DELETE /workflows/:id', () => {
|
||||
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
||||
|
||||
// make sure the workflow actually deleted from the db
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOneBy({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOneBy({
|
||||
workflowId: workflow.id,
|
||||
});
|
||||
|
||||
@@ -426,7 +427,7 @@ describe('DELETE /workflows/:id', () => {
|
||||
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
||||
|
||||
// make sure the workflow actually deleted from the db
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOneBy({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOneBy({
|
||||
workflowId: workflow.id,
|
||||
});
|
||||
|
||||
@@ -474,7 +475,7 @@ describe('POST /workflows/:id/activate', () => {
|
||||
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
||||
|
||||
// check whether the workflow is on the database
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: workflow.id,
|
||||
@@ -509,7 +510,7 @@ describe('POST /workflows/:id/activate', () => {
|
||||
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
|
||||
|
||||
// check whether the workflow is on the database
|
||||
const sharedOwnerWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedOwnerWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: owner.id,
|
||||
workflowId: workflow.id,
|
||||
@@ -518,7 +519,7 @@ describe('POST /workflows/:id/activate', () => {
|
||||
|
||||
expect(sharedOwnerWorkflow).toBeNull();
|
||||
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: workflow.id,
|
||||
@@ -572,7 +573,7 @@ describe('POST /workflows/:id/deactivate', () => {
|
||||
expect(updatedAt).toBeDefined();
|
||||
|
||||
// get the workflow after it was deactivated
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: workflow.id,
|
||||
@@ -609,7 +610,7 @@ describe('POST /workflows/:id/deactivate', () => {
|
||||
expect(updatedAt).toBeDefined();
|
||||
|
||||
// check whether the workflow is deactivated in the database
|
||||
const sharedOwnerWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedOwnerWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: owner.id,
|
||||
workflowId: workflow.id,
|
||||
@@ -618,7 +619,7 @@ describe('POST /workflows/:id/deactivate', () => {
|
||||
|
||||
expect(sharedOwnerWorkflow).toBeNull();
|
||||
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: workflow.id,
|
||||
@@ -685,7 +686,7 @@ describe('POST /workflows', () => {
|
||||
expect(updatedAt).toEqual(createdAt);
|
||||
|
||||
// check if created workflow in DB
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: response.body.id,
|
||||
@@ -924,7 +925,7 @@ describe('PUT /workflows/:id', () => {
|
||||
expect(updatedAt).not.toBe(workflow.updatedAt.toISOString());
|
||||
|
||||
// check updated workflow in DB
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: response.body.id,
|
||||
@@ -1093,7 +1094,7 @@ describe('PUT /workflows/:id', () => {
|
||||
expect(updatedAt).not.toBe(workflow.updatedAt.toISOString());
|
||||
|
||||
// check updated workflow in DB
|
||||
const sharedOwnerWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedOwnerWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: owner.id,
|
||||
workflowId: response.body.id,
|
||||
@@ -1102,7 +1103,7 @@ describe('PUT /workflows/:id', () => {
|
||||
|
||||
expect(sharedOwnerWorkflow).toBeNull();
|
||||
|
||||
const sharedWorkflow = await Db.collections.SharedWorkflow.findOne({
|
||||
const sharedWorkflow = await Container.get(SharedWorkflowRepository).findOne({
|
||||
where: {
|
||||
userId: member.id,
|
||||
workflowId: response.body.id,
|
||||
|
||||
Reference in New Issue
Block a user