mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-26 14:25:35 +02:00
feat(core): Send the right activation mode for activate endpoint (no-changelog) (#22276)
This commit is contained in:
parent
d366cb4f37
commit
362f33dbd0
|
|
@ -544,6 +544,9 @@ export class WorkflowService {
|
|||
return workflow;
|
||||
}
|
||||
|
||||
const wasActive = workflow.activeVersionId !== null;
|
||||
const activationMode = wasActive ? 'update' : 'activate';
|
||||
|
||||
await this.workflowRepository.update(workflowId, {
|
||||
activeVersionId: versionId,
|
||||
active: true,
|
||||
|
|
@ -572,7 +575,7 @@ export class WorkflowService {
|
|||
publicApi: false,
|
||||
});
|
||||
|
||||
await this._addToActiveWorkflowManager(user, workflowId, updatedWorkflow, 'activate', {
|
||||
await this._addToActiveWorkflowManager(user, workflowId, updatedWorkflow, activationMode, {
|
||||
active: workflow.active,
|
||||
activeVersionId: workflow.activeVersionId,
|
||||
activeVersion: workflow.activeVersion,
|
||||
|
|
|
|||
|
|
@ -2825,7 +2825,7 @@ describe('PATCH /workflows/:workflowId', () => {
|
|||
});
|
||||
|
||||
test('should not modify activeVersionId when explicitly provided', async () => {
|
||||
const workflow = await createWorkflow({}, owner);
|
||||
const workflow = await createWorkflowWithHistory({}, owner);
|
||||
const payload = {
|
||||
versionId: workflow.versionId,
|
||||
activeVersionId: workflow.versionId,
|
||||
|
|
@ -3033,6 +3033,29 @@ describe('POST /workflows/:workflowId/activate', () => {
|
|||
|
||||
expect(emitSpy).not.toHaveBeenCalledWith('workflow-deactivated', expect.anything());
|
||||
});
|
||||
|
||||
test('should call active workflow manager with activate mode if workflow is not active', async () => {
|
||||
const workflow = await createWorkflowWithHistory({}, owner);
|
||||
|
||||
await authOwnerAgent
|
||||
.post(`/workflows/${workflow.id}/activate`)
|
||||
.send({ versionId: workflow.versionId });
|
||||
|
||||
expect(activeWorkflowManagerLike.add).toBeCalledWith(workflow.id, 'activate');
|
||||
});
|
||||
|
||||
test('should call active workflow manager with update mode if workflow is active', async () => {
|
||||
const workflow = await createActiveWorkflow({}, owner);
|
||||
|
||||
const newVersionId = uuid();
|
||||
await createWorkflowHistoryItem(workflow.id, { versionId: newVersionId });
|
||||
|
||||
await authOwnerAgent
|
||||
.post(`/workflows/${workflow.id}/activate`)
|
||||
.send({ versionId: newVersionId });
|
||||
|
||||
expect(activeWorkflowManagerLike.add).toBeCalledWith(workflow.id, 'update');
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /workflows/:workflowId/deactivate', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user