mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
wip: Addressing PR comments
This commit is contained in:
parent
dc27ff83e0
commit
36bc011ae9
|
@ -14,8 +14,9 @@ export class TestRunsController {
|
||||||
private readonly testRunRepository: TestRunRepository,
|
private readonly testRunRepository: TestRunRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
// This method is used in multiple places in the controller to get the test definition
|
/** This method is used in multiple places in the controller to get the test definition
|
||||||
// (or just check that it exists and the user has access to it).
|
* (or just check that it exists and the user has access to it).
|
||||||
|
*/
|
||||||
private async getTestDefinition(
|
private async getTestDefinition(
|
||||||
req: TestRunsRequest.GetOne | TestRunsRequest.GetMany | TestRunsRequest.Delete,
|
req: TestRunsRequest.GetOne | TestRunsRequest.GetMany | TestRunsRequest.Delete,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { createWorkflow } from '@test-integration/db/workflows';
|
||||||
import * as testDb from '@test-integration/test-db';
|
import * as testDb from '@test-integration/test-db';
|
||||||
import type { SuperAgentTest } from '@test-integration/types';
|
import type { SuperAgentTest } from '@test-integration/types';
|
||||||
import * as utils from '@test-integration/utils';
|
import * as utils from '@test-integration/utils';
|
||||||
|
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||||
|
|
||||||
let authOwnerAgent: SuperAgentTest;
|
let authOwnerAgent: SuperAgentTest;
|
||||||
let workflowUnderTest: WorkflowEntity;
|
let workflowUnderTest: WorkflowEntity;
|
||||||
|
@ -18,7 +19,10 @@ let testDefinition: TestDefinition;
|
||||||
let otherTestDefinition: TestDefinition;
|
let otherTestDefinition: TestDefinition;
|
||||||
let ownerShell: User;
|
let ownerShell: User;
|
||||||
|
|
||||||
const testServer = utils.setupTestServer({ endpointGroups: ['evaluation'] });
|
const testServer = utils.setupTestServer({
|
||||||
|
endpointGroups: ['workflows', 'evaluation'],
|
||||||
|
enabledFeatures: ['feat:sharing'],
|
||||||
|
});
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
ownerShell = await createUserShell('global:owner');
|
ownerShell = await createUserShell('global:owner');
|
||||||
|
@ -26,7 +30,7 @@ beforeAll(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await testDb.truncate(['TestDefinition', 'TestRun']);
|
await testDb.truncate(['TestDefinition', 'TestRun', 'Workflow', 'SharedWorkflow']);
|
||||||
|
|
||||||
workflowUnderTest = await createWorkflow({ name: 'workflow-under-test' }, ownerShell);
|
workflowUnderTest = await createWorkflow({ name: 'workflow-under-test' }, ownerShell);
|
||||||
|
|
||||||
|
@ -165,6 +169,37 @@ describe('GET /evaluation/test-definitions/:testDefinitionId/runs/:id', () => {
|
||||||
|
|
||||||
expect(resp.statusCode).toBe(404);
|
expect(resp.statusCode).toBe(404);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should retrieve test run for a test definition of a shared workflow', async () => {
|
||||||
|
const memberShell = await createUserShell('global:member');
|
||||||
|
const memberAgent = testServer.authAgentFor(memberShell);
|
||||||
|
const memberPersonalProject = await Container.get(
|
||||||
|
ProjectRepository,
|
||||||
|
).getPersonalProjectForUserOrFail(memberShell.id);
|
||||||
|
|
||||||
|
// Share workflow with a member
|
||||||
|
const sharingResponse = await authOwnerAgent
|
||||||
|
.put(`/workflows/${workflowUnderTest.id}/share`)
|
||||||
|
.send({ shareWithIds: [memberPersonalProject.id] });
|
||||||
|
|
||||||
|
expect(sharingResponse.statusCode).toBe(200);
|
||||||
|
|
||||||
|
// Create a test run for the shared workflow
|
||||||
|
const testRunRepository = Container.get(TestRunRepository);
|
||||||
|
const testRun = await testRunRepository.createTestRun(testDefinition.id);
|
||||||
|
|
||||||
|
// Check if member can retrieve the test run of a shared workflow
|
||||||
|
const resp = await memberAgent.get(
|
||||||
|
`/evaluation/test-definitions/${testDefinition.id}/runs/${testRun.id}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(resp.statusCode).toBe(200);
|
||||||
|
expect(resp.body.data).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
id: testRun.id,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('DELETE /evaluation/test-definitions/:testDefinitionId/runs/:id', () => {
|
describe('DELETE /evaluation/test-definitions/:testDefinitionId/runs/:id', () => {
|
||||||
|
|
Loading…
Reference in a new issue