refactor(core): Reduce boilterplate code in between tests 🧹, and fix the tests in node.js 20 (no-changelog) (#6654)

refactor(core): Reduce boilterplate code in between tests

also cleaned up some imports, and fixed the tests in node.js 20
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-07-13 10:14:48 +02:00
committed by GitHub
parent 3e07ffa73e
commit b895ba438a
78 changed files with 1197 additions and 1597 deletions

View File

@@ -16,7 +16,7 @@ import type { InstalledNodes } from '@db/entities/InstalledNodes';
import { NodeTypes } from '@/NodeTypes';
import { Push } from '@/push';
import { COMMUNITY_PACKAGE_VERSION } from './shared/constants';
import * as utils from './shared/utils';
import * as utils from './shared/utils/';
import * as testDb from './shared/testDb';
const mockLoadNodesAndCredentials = utils.mockInstance(LoadNodesAndCredentials);
@@ -44,17 +44,15 @@ jest.mock('@/CommunityNodes/packageModel', () => {
const mockedEmptyPackage = mocked(utils.emptyPackage);
const testServer = utils.setupTestServer({ endpointGroups: ['nodes'] });
let ownerShell: User;
let authOwnerShellAgent: SuperAgentTest;
beforeAll(async () => {
const app = await utils.initTestServer({ endpointGroups: ['nodes'] });
const globalOwnerRole = await testDb.getGlobalOwnerRole();
ownerShell = await testDb.createUserShell(globalOwnerRole);
authOwnerShellAgent = utils.createAuthAgent(app)(ownerShell);
await utils.initConfigFile();
authOwnerShellAgent = testServer.authAgentFor(ownerShell);
});
beforeEach(async () => {
@@ -64,10 +62,6 @@ beforeEach(async () => {
mocked(findInstalledPackage).mockReset();
});
afterAll(async () => {
await testDb.terminate();
});
describe('GET /nodes', () => {
test('should respond 200 if no nodes are installed', async () => {
const {