refactor(core): Post-release refactorings of Public API (#3495)

*  Post-release refactorings

* 🧪 Add `--forceExit`

* 🛠 typing refactor (#3486)

* 🐛 Fix middleware arguments

* 👕 Fix lint

*  Restore commented out block

Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
This commit is contained in:
Iván Ovejero
2022-06-14 18:32:19 +02:00
committed by GitHub
parent 2ebcf4bb91
commit b8e3bcc052
19 changed files with 307 additions and 343 deletions

View File

@@ -1,5 +1,7 @@
import express from 'express';
import { UserSettings } from 'n8n-core';
import { Db } from '../../../src';
import { randomApiKey, randomName, randomString } from '../shared/random';
import * as utils from '../shared/utils';
@@ -9,13 +11,10 @@ import type { User } from '../../../src/databases/entities/User';
import * as testDb from '../shared/testDb';
import { RESPONSE_ERROR_MESSAGES } from '../../../src/constants';
jest.mock('../../../src/telemetry');
let app: express.Application;
let testDbName = '';
let globalOwnerRole: Role;
let globalMemberRole: Role;
let workflowOwnerRole: Role;
let credentialOwnerRole: Role;
let saveCredential: SaveCredentialFunction;
@@ -30,13 +29,12 @@ beforeAll(async () => {
const [
fetchedGlobalOwnerRole,
fetchedGlobalMemberRole,
fetchedWorkflowOwnerRole,
_,
fetchedCredentialOwnerRole,
] = await testDb.getAllRoles();
globalOwnerRole = fetchedGlobalOwnerRole;
globalMemberRole = fetchedGlobalMemberRole;
workflowOwnerRole = fetchedWorkflowOwnerRole;
credentialOwnerRole = fetchedCredentialOwnerRole;
saveCredential = affixRoleToSaveCredential(credentialOwnerRole);
@@ -377,6 +375,7 @@ const credentialPayload = (): CredentialPayload => ({
const dbCredential = () => {
const credential = credentialPayload();
credential.nodesAccess = [{ nodeType: credential.type }];
return credential;
};

View File

@@ -1,7 +1,7 @@
import express = require('express');
import express from 'express';
import { ActiveWorkflowRunner } from '../../../src';
import config = require('../../../config');
import config from '../../../config';
import { Role } from '../../../src/databases/entities/Role';
import { randomApiKey } from '../shared/random';
@@ -11,11 +11,8 @@ import * as testDb from '../shared/testDb';
let app: express.Application;
let testDbName = '';
let globalOwnerRole: Role;
let workflowRunner: ActiveWorkflowRunner.ActiveWorkflowRunner;
jest.mock('../../../src/telemetry');
beforeAll(async () => {
app = await utils.initTestServer({ endpointGroups: ['publicApi'], applyAuth: false });
const initResult = await testDb.init();
@@ -25,21 +22,29 @@ beforeAll(async () => {
utils.initTestTelemetry();
utils.initTestLogger();
// initializing binary manager leave some async operations open
// TODO mockup binary data mannager to avoid error
await utils.initBinaryManager();
await utils.initNodeTypes();
workflowRunner = await utils.initActiveWorkflowRunner();
});
beforeEach(async () => {
// do not combine calls - shared tables must be cleared first and separately
await testDb.truncate(['SharedCredentials', 'SharedWorkflow'], testDbName);
await testDb.truncate(['User', 'Workflow', 'Credentials', 'Execution', 'Settings'], testDbName);
await testDb.truncate(
[
'SharedCredentials',
'SharedWorkflow',
'User',
'Workflow',
'Credentials',
'Execution',
'Settings',
],
testDbName,
);
config.set('userManagement.disabled', false);
config.set('userManagement.isInstanceOwnerSetUp', true);
config.set('userManagement.emails.mode', 'smtp');
});
afterEach(async () => {
@@ -50,7 +55,7 @@ afterAll(async () => {
await testDb.terminate(testDbName);
});
test.skip('GET /executions/:executionId should fail due to missing API Key', async () => {
test('GET /executions/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -65,7 +70,7 @@ test.skip('GET /executions/:executionId should fail due to missing API Key', asy
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions/:executionId should fail due to invalid API Key', async () => {
test('GET /executions/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -81,7 +86,7 @@ test.skip('GET /executions/:executionId should fail due to invalid API Key', asy
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions/:executionId should get an execution', async () => {
test('GET /executions/:id should get an execution', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -93,7 +98,7 @@ test.skip('GET /executions/:executionId should get an execution', async () => {
const workflow = await testDb.createWorkflow({}, owner);
const execution = await testDb.createSuccessfullExecution(workflow);
const execution = await testDb.createSuccessfulExecution(workflow);
const response = await authOwnerAgent.get(`/executions/${execution.id}`);
@@ -122,7 +127,7 @@ test.skip('GET /executions/:executionId should get an execution', async () => {
expect(waitTill).toBeNull();
});
test.skip('DELETE /executions/:executionId should fail due to missing API Key', async () => {
test('DELETE /executions/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -137,7 +142,7 @@ test.skip('DELETE /executions/:executionId should fail due to missing API Key',
expect(response.statusCode).toBe(401);
});
test.skip('DELETE /executions/:executionId should fail due to invalid API Key', async () => {
test('DELETE /executions/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -153,7 +158,7 @@ test.skip('DELETE /executions/:executionId should fail due to invalid API Key',
expect(response.statusCode).toBe(401);
});
test.skip('DELETE /executions/:executionId should delete an execution', async () => {
test('DELETE /executions/:id should delete an execution', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -165,7 +170,7 @@ test.skip('DELETE /executions/:executionId should delete an execution', async ()
const workflow = await testDb.createWorkflow({}, owner);
const execution = await testDb.createSuccessfullExecution(workflow);
const execution = await testDb.createSuccessfulExecution(workflow);
const response = await authOwnerAgent.delete(`/executions/${execution.id}`);
@@ -194,7 +199,7 @@ test.skip('DELETE /executions/:executionId should delete an execution', async ()
expect(waitTill).toBeNull();
});
test.skip('GET /executions should fail due to missing API Key', async () => {
test('GET /executions should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -209,7 +214,7 @@ test.skip('GET /executions should fail due to missing API Key', async () => {
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions should fail due to invalid API Key', async () => {
test('GET /executions should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -225,7 +230,7 @@ test.skip('GET /executions should fail due to invalid API Key', async () => {
expect(response.statusCode).toBe(401);
});
test.skip('GET /executions should retrieve all successfull executions', async () => {
test('GET /executions should retrieve all successfull executions', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -237,7 +242,7 @@ test.skip('GET /executions should retrieve all successfull executions', async ()
const workflow = await testDb.createWorkflow({}, owner);
const successfullExecution = await testDb.createSuccessfullExecution(workflow);
const successfullExecution = await testDb.createSuccessfulExecution(workflow);
await testDb.createErrorExecution(workflow);
@@ -272,7 +277,7 @@ test.skip('GET /executions should retrieve all successfull executions', async ()
expect(waitTill).toBeNull();
});
test.skip('GET /executions should retrieve all error executions', async () => {
test('GET /executions should retrieve all error executions', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -284,7 +289,7 @@ test.skip('GET /executions should retrieve all error executions', async () => {
const workflow = await testDb.createWorkflow({}, owner);
await testDb.createSuccessfullExecution(workflow);
await testDb.createSuccessfulExecution(workflow);
const errorExecution = await testDb.createErrorExecution(workflow);
@@ -319,7 +324,7 @@ test.skip('GET /executions should retrieve all error executions', async () => {
expect(waitTill).toBeNull();
});
test.skip('GET /executions should return all waiting executions', async () => {
test('GET /executions should return all waiting executions', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -331,7 +336,7 @@ test.skip('GET /executions should return all waiting executions', async () => {
const workflow = await testDb.createWorkflow({}, owner);
await testDb.createSuccessfullExecution(workflow);
await testDb.createSuccessfulExecution(workflow);
await testDb.createErrorExecution(workflow);
@@ -368,7 +373,7 @@ test.skip('GET /executions should return all waiting executions', async () => {
expect(new Date(waitTill).getTime()).toBeGreaterThan(Date.now() - 1000);
});
test.skip('GET /executions should retrieve all executions of specific workflow', async () => {
test('GET /executions should retrieve all executions of specific workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -384,10 +389,10 @@ test.skip('GET /executions should retrieve all executions of specific workflow',
2,
workflow,
// @ts-ignore
testDb.createSuccessfullExecution,
testDb.createSuccessfulExecution,
);
// @ts-ignore
await testDb.createManyExecutions(2, workflow2, testDb.createSuccessfullExecution);
await testDb.createManyExecutions(2, workflow2, testDb.createSuccessfulExecution);
const response = await authOwnerAgent.get(`/executions`).query({
workflowId: workflow.id.toString(),

View File

@@ -1,7 +1,7 @@
import express = require('express');
import express from 'express';
import { ActiveWorkflowRunner, Db } from '../../../src';
import config = require('../../../config');
import config from '../../../config';
import { Role } from '../../../src/databases/entities/Role';
import { randomApiKey } from '../shared/random';
@@ -14,11 +14,8 @@ let testDbName = '';
let globalOwnerRole: Role;
let globalMemberRole: Role;
let workflowOwnerRole: Role;
let credentialOwnerRole: Role;
let workflowRunner: ActiveWorkflowRunner.ActiveWorkflowRunner;
jest.mock('../../../src/telemetry');
beforeAll(async () => {
app = await utils.initTestServer({ endpointGroups: ['publicApi'], applyAuth: false });
const initResult = await testDb.init();
@@ -28,13 +25,11 @@ beforeAll(async () => {
fetchedGlobalOwnerRole,
fetchedGlobalMemberRole,
fetchedWorkflowOwnerRole,
fetchedCredentialOwnerRole,
] = await testDb.getAllRoles();
globalOwnerRole = fetchedGlobalOwnerRole;
globalMemberRole = fetchedGlobalMemberRole;
workflowOwnerRole = fetchedWorkflowOwnerRole;
credentialOwnerRole = fetchedCredentialOwnerRole;
utils.initTestTelemetry();
utils.initTestLogger();
@@ -43,13 +38,13 @@ beforeAll(async () => {
});
beforeEach(async () => {
// do not combine calls - shared tables must be cleared first and separately
await testDb.truncate(['SharedCredentials', 'SharedWorkflow'], testDbName);
await testDb.truncate(['User', 'Workflow', 'Credentials'], testDbName);
await testDb.truncate(
['SharedCredentials', 'SharedWorkflow', 'User', 'Workflow', 'Credentials'],
testDbName,
);
config.set('userManagement.disabled', false);
config.set('userManagement.isInstanceOwnerSetUp', true);
config.set('userManagement.emails.mode', 'smtp');
});
afterEach(async () => {
@@ -352,7 +347,7 @@ test('GET /workflows should return all workflows for owner', async () => {
}
});
test('GET /workflows/:workflowId should fail due to missing API Key', async () => {
test('GET /workflows/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
owner.apiKey = null;
@@ -369,7 +364,7 @@ test('GET /workflows/:workflowId should fail due to missing API Key', async () =
expect(response.statusCode).toBe(401);
});
test('GET /workflows/:workflowId should fail due to invalid API Key', async () => {
test('GET /workflows/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -386,7 +381,7 @@ test('GET /workflows/:workflowId should fail due to invalid API Key', async () =
expect(response.statusCode).toBe(401);
});
test('GET /workflows/:workflowId should fail due to non existing workflow', async () => {
test('GET /workflows/:id should fail due to non existing workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -401,7 +396,7 @@ test('GET /workflows/:workflowId should fail due to non existing workflow', asyn
expect(response.statusCode).toBe(404);
});
test('GET /workflows/:workflowId should retrieve workflow', async () => {
test('GET /workflows/:id should retrieve workflow', async () => {
const member = await testDb.createUser({ globalRole: globalMemberRole, apiKey: randomApiKey() });
const authAgent = utils.createAgent(app, {
@@ -432,7 +427,7 @@ test('GET /workflows/:workflowId should retrieve workflow', async () => {
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
});
test('GET /workflows/:workflowId should retrieve non-owned workflow for owner', async () => {
test('GET /workflows/:id should retrieve non-owned workflow for owner', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const member = await testDb.createUser({ globalRole: globalMemberRole });
@@ -464,7 +459,7 @@ test('GET /workflows/:workflowId should retrieve non-owned workflow for owner',
expect(updatedAt).toEqual(workflow.updatedAt.toISOString());
});
test('DELETE /workflows/:workflowId should fail due to missing API Key', async () => {
test('DELETE /workflows/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -479,7 +474,7 @@ test('DELETE /workflows/:workflowId should fail due to missing API Key', async (
expect(response.statusCode).toBe(401);
});
test('DELETE /workflows/:workflowId should fail due to invalid API Key', async () => {
test('DELETE /workflows/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -496,7 +491,7 @@ test('DELETE /workflows/:workflowId should fail due to invalid API Key', async (
expect(response.statusCode).toBe(401);
});
test('DELETE /workflows/:workflowId should fail due to non existing workflow', async () => {
test('DELETE /workflows/:id should fail due to non existing workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -511,7 +506,7 @@ test('DELETE /workflows/:workflowId should fail due to non existing workflow', a
expect(response.statusCode).toBe(404);
});
test('DELETE /workflows/:workflowId should delete the workflow', async () => {
test('DELETE /workflows/:id should delete the workflow', async () => {
const member = await testDb.createUser({ globalRole: globalMemberRole, apiKey: randomApiKey() });
const authAgent = utils.createAgent(app, {
@@ -549,7 +544,7 @@ test('DELETE /workflows/:workflowId should delete the workflow', async () => {
expect(sharedWorkflow).toBeUndefined();
});
test('DELETE /workflows/:workflowId should delete non-owned workflow when owner', async () => {
test('DELETE /workflows/:id should delete non-owned workflow when owner', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const member = await testDb.createUser({ globalRole: globalMemberRole });
@@ -588,7 +583,7 @@ test('DELETE /workflows/:workflowId should delete non-owned workflow when owner'
expect(sharedWorkflow).toBeUndefined();
});
test('POST /workflows/:workflowId/activate should fail due to missing API Key', async () => {
test('POST /workflows/:id/activate should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -603,7 +598,7 @@ test('POST /workflows/:workflowId/activate should fail due to missing API Key',
expect(response.statusCode).toBe(401);
});
test('POST /workflows/:workflowId/activate should fail due to invalid API Key', async () => {
test('POST /workflows/:id/activate should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -620,7 +615,7 @@ test('POST /workflows/:workflowId/activate should fail due to invalid API Key',
expect(response.statusCode).toBe(401);
});
test('POST /workflows/:workflowId/activate should fail due to non existing workflow', async () => {
test('POST /workflows/:id/activate should fail due to non existing workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -635,7 +630,7 @@ test('POST /workflows/:workflowId/activate should fail due to non existing workf
expect(response.statusCode).toBe(404);
});
test('POST /workflows/:workflowId/activate should fail due to trying to activate a workflow without a trigger', async () => {
test('POST /workflows/:id/activate should fail due to trying to activate a workflow without a trigger', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -652,7 +647,7 @@ test('POST /workflows/:workflowId/activate should fail due to trying to activate
expect(response.statusCode).toBe(400);
});
test.skip('POST /workflows/:workflowId/activate should set workflow as active', async () => {
test.skip('POST /workflows/:id/activate should set workflow as active', async () => {
const member = await testDb.createUser({ globalRole: globalMemberRole, apiKey: randomApiKey() });
const authAgent = utils.createAgent(app, {
@@ -696,7 +691,7 @@ test.skip('POST /workflows/:workflowId/activate should set workflow as active',
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(true);
});
test.skip('POST /workflows/:workflowId/activate should set non-owned workflow as active when owner', async () => {
test.skip('POST /workflows/:id/activate should set non-owned workflow as active when owner', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const member = await testDb.createUser({ globalRole: globalMemberRole });
@@ -750,7 +745,7 @@ test.skip('POST /workflows/:workflowId/activate should set non-owned workflow as
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(true);
});
test('POST /workflows/:workflowId/deactivate should fail due to missing API Key', async () => {
test('POST /workflows/:id/deactivate should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -765,7 +760,7 @@ test('POST /workflows/:workflowId/deactivate should fail due to missing API Key'
expect(response.statusCode).toBe(401);
});
test('POST /workflows/:workflowId/deactivate should fail due to invalid API Key', async () => {
test('POST /workflows/:id/deactivate should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -782,7 +777,7 @@ test('POST /workflows/:workflowId/deactivate should fail due to invalid API Key'
expect(response.statusCode).toBe(401);
});
test('POST /workflows/:workflowId/deactivate should fail due to non existing workflow', async () => {
test('POST /workflows/:id/deactivate should fail due to non existing workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -797,7 +792,7 @@ test('POST /workflows/:workflowId/deactivate should fail due to non existing wor
expect(response.statusCode).toBe(404);
});
test('POST /workflows/:workflowId/deactivate should deactive workflow', async () => {
test('POST /workflows/:id/deactivate should deactive workflow', async () => {
const member = await testDb.createUser({ globalRole: globalMemberRole, apiKey: randomApiKey() });
const authAgent = utils.createAgent(app, {
@@ -841,7 +836,7 @@ test('POST /workflows/:workflowId/deactivate should deactive workflow', async ()
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(false);
});
test('POST /workflows/:workflowId/deactivate should deactive non-owned workflow when owner', async () => {
test('POST /workflows/:id/deactivate should deactive non-owned workflow when owner', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const member = await testDb.createUser({ globalRole: globalMemberRole });
@@ -904,7 +899,7 @@ test('POST /workflows should fail due to missing API Key', async () => {
version: 1,
});
const response = await authOwnerAgent.post(`/workflows`);
const response = await authOwnerAgent.post('/workflows');
expect(response.statusCode).toBe(401);
});
@@ -921,7 +916,7 @@ test('POST /workflows should fail due to invalid API Key', async () => {
version: 1,
});
const response = await authOwnerAgent.post(`/workflows`);
const response = await authOwnerAgent.post('/workflows');
expect(response.statusCode).toBe(401);
});
@@ -936,7 +931,7 @@ test('POST /workflows should fail due to invalid body', async () => {
version: 1,
});
const response = await authOwnerAgent.post(`/workflows`).send({});
const response = await authOwnerAgent.post('/workflows').send({});
expect(response.statusCode).toBe(400);
});
@@ -974,7 +969,7 @@ test('POST /workflows should create workflow', async () => {
},
};
const response = await authAgent.post(`/workflows`).send(payload);
const response = await authAgent.post('/workflows').send(payload);
expect(response.statusCode).toBe(200);
@@ -1005,7 +1000,7 @@ test('POST /workflows should create workflow', async () => {
expect(sharedWorkflow?.role).toEqual(workflowOwnerRole);
});
test('PUT /workflows/:workflowId should fail due to missing API Key', async () => {
test('PUT /workflows/:id should fail due to missing API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
const authOwnerAgent = utils.createAgent(app, {
@@ -1020,7 +1015,7 @@ test('PUT /workflows/:workflowId should fail due to missing API Key', async () =
expect(response.statusCode).toBe(401);
});
test('PUT /workflows/:workflowId should fail due to invalid API Key', async () => {
test('PUT /workflows/:id should fail due to invalid API Key', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
owner.apiKey = 'abcXYZ';
@@ -1037,7 +1032,7 @@ test('PUT /workflows/:workflowId should fail due to invalid API Key', async () =
expect(response.statusCode).toBe(401);
});
test('PUT /workflows/:workflowId should fail due to non existing workflow', async () => {
test('PUT /workflows/:id should fail due to non existing workflow', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -1073,7 +1068,7 @@ test('PUT /workflows/:workflowId should fail due to non existing workflow', asyn
expect(response.statusCode).toBe(404);
});
test('PUT /workflows/:workflowId should fail due to invalid body', async () => {
test('PUT /workflows/:id should fail due to invalid body', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const authOwnerAgent = utils.createAgent(app, {
@@ -1108,7 +1103,7 @@ test('PUT /workflows/:workflowId should fail due to invalid body', async () => {
expect(response.statusCode).toBe(400);
});
test('PUT /workflows/:workflowId should update workflow', async () => {
test('PUT /workflows/:id should update workflow', async () => {
const member = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const workflow = await testDb.createWorkflow({}, member);
@@ -1182,7 +1177,7 @@ test('PUT /workflows/:workflowId should update workflow', async () => {
);
});
test('PUT /workflows/:workflowId should update non-owned workflow if owner', async () => {
test('PUT /workflows/:id should update non-owned workflow if owner', async () => {
const owner = await testDb.createUser({ globalRole: globalOwnerRole, apiKey: randomApiKey() });
const member = await testDb.createUser({ globalRole: globalMemberRole });