Skip to content

Commit

Permalink
fix(core): Route /rest/workflows/new correctly (no-changelog) (#6572)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Jul 4, 2023
1 parent c2b9d5a commit c906e73
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/workflows/workflows.controller.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ EEWorkflowController.put(

EEWorkflowController.get(
'/:id(\\w+)',
(req, res, next) => (req.params.id === 'new' ? next('router') : next()), // skip ee router and use free one for naming
ResponseHelper.send(async (req: WorkflowRequest.Get) => {
const { id: workflowId } = req.params;

Expand Down
17 changes: 17 additions & 0 deletions packages/cli/test/integration/workflows.controller.ee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,23 @@ describe('GET /workflows', () => {
});
});

describe('GET /workflows/new', () => {
[true, false].forEach((sharingEnabled) => {
test(`should return an auto-incremented name, even when sharing is ${
sharingEnabled ? 'enabled' : 'disabled'
}`, async () => {
sharingSpy.mockReturnValueOnce(sharingEnabled);

await createWorkflow({ name: 'My workflow' }, owner);
await createWorkflow({ name: 'My workflow 7' }, owner);

const response = await authOwnerAgent.get('/workflows/new');
expect(response.statusCode).toBe(200);
expect(response.body.data.name).toEqual('My workflow 8');
});
});
});

describe('GET /workflows/:id', () => {
test('GET should fail with invalid id due to route rule', async () => {
const response = await authOwnerAgent.get('/workflows/potatoes');
Expand Down

0 comments on commit c906e73

Please sign in to comment.