|
| 1 | +import { SCHEDULE_TRIGGER_NODE_NAME } from '../../../../../config/constants'; |
| 2 | +import { test, expect } from '../../../../../fixtures/base'; |
| 3 | +import type { n8nPage } from '../../../../../pages/n8nPage'; |
| 4 | + |
| 5 | +async function saveWorkflowAndGetId(n8n: n8nPage): Promise<string> { |
| 6 | + const saveResponsePromise = n8n.page.waitForResponse( |
| 7 | + (response) => |
| 8 | + response.url().includes('/rest/workflows') && |
| 9 | + (response.request().method() === 'POST' || response.request().method() === 'PATCH'), |
| 10 | + ); |
| 11 | + await n8n.canvas.saveWorkflow(); |
| 12 | + const saveResponse = await saveResponsePromise; |
| 13 | + const { |
| 14 | + data: { id }, |
| 15 | + } = await saveResponse.json(); |
| 16 | + return id; |
| 17 | +} |
| 18 | + |
| 19 | +async function goToWorkflow(n8n: n8nPage, workflowId: string): Promise<void> { |
| 20 | + const loadResponsePromise = n8n.page.waitForResponse( |
| 21 | + (response) => |
| 22 | + response.url().includes(`/rest/workflows/${workflowId}`) && |
| 23 | + response.request().method() === 'GET' && |
| 24 | + response.status() === 200, |
| 25 | + ); |
| 26 | + await n8n.page.goto(`/workflow/${workflowId}`); |
| 27 | + await loadResponsePromise; |
| 28 | +} |
| 29 | + |
| 30 | +// eslint-disable-next-line playwright/no-skipped-test |
| 31 | +test.skip('Workflow Archive', () => { |
| 32 | + test.beforeEach(async ({ n8n }) => { |
| 33 | + await n8n.start.fromBlankCanvas(); |
| 34 | + }); |
| 35 | + |
| 36 | + test('should not be able to archive or delete unsaved workflow', async ({ n8n }) => { |
| 37 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 38 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 39 | + |
| 40 | + await expect(n8n.workflowSettingsModal.getDeleteMenuItem()).toBeHidden(); |
| 41 | + await expect(n8n.workflowSettingsModal.getArchiveMenuItem().locator('..')).toHaveClass( |
| 42 | + /is-disabled/, |
| 43 | + ); |
| 44 | + }); |
| 45 | + |
| 46 | + test('should archive nonactive workflow and then delete it', async ({ n8n }) => { |
| 47 | + const workflowId = await saveWorkflowAndGetId(n8n); |
| 48 | + await expect(n8n.canvas.getArchivedTag()).not.toBeAttached(); |
| 49 | + |
| 50 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 51 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 52 | + |
| 53 | + await n8n.workflowSettingsModal.clickArchiveMenuItem(); |
| 54 | + |
| 55 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 56 | + await expect(n8n.page).toHaveURL(/\/workflows$/); |
| 57 | + |
| 58 | + await goToWorkflow(n8n, workflowId); |
| 59 | + |
| 60 | + await expect(n8n.canvas.getArchivedTag()).toBeVisible(); |
| 61 | + await expect(n8n.canvas.getNodeCreatorPlusButton()).not.toBeAttached(); |
| 62 | + |
| 63 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 64 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 65 | + await n8n.workflowSettingsModal.clickDeleteMenuItem(); |
| 66 | + await n8n.workflowSettingsModal.confirmDeleteModal(); |
| 67 | + |
| 68 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 69 | + await expect(n8n.page).toHaveURL(/\/workflows$/); |
| 70 | + }); |
| 71 | + |
| 72 | + // eslint-disable-next-line n8n-local-rules/no-skipped-tests -- Flaky in multi-main mode |
| 73 | + test.skip('should archive published workflow and then delete it', async ({ n8n }) => { |
| 74 | + await n8n.canvas.addNode(SCHEDULE_TRIGGER_NODE_NAME, { closeNDV: true }); |
| 75 | + const workflowId = await saveWorkflowAndGetId(n8n); |
| 76 | + await n8n.canvas.publishWorkflow(); |
| 77 | + await n8n.page.keyboard.press('Escape'); |
| 78 | + |
| 79 | + await expect(n8n.canvas.getPublishedIndicator()).toBeVisible(); |
| 80 | + await expect(n8n.canvas.getArchivedTag()).not.toBeAttached(); |
| 81 | + |
| 82 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 83 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 84 | + await n8n.workflowSettingsModal.clickArchiveMenuItem(); |
| 85 | + await n8n.workflowSettingsModal.confirmArchiveModal(); |
| 86 | + |
| 87 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 88 | + await expect(n8n.page).toHaveURL(/\/workflows$/); |
| 89 | + |
| 90 | + await goToWorkflow(n8n, workflowId); |
| 91 | + |
| 92 | + await expect(n8n.canvas.getArchivedTag()).toBeVisible(); |
| 93 | + await expect(n8n.canvas.getNodeCreatorPlusButton()).not.toBeAttached(); |
| 94 | + await expect(n8n.canvas.getPublishedIndicator()).not.toBeVisible(); |
| 95 | + |
| 96 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 97 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 98 | + await n8n.workflowSettingsModal.clickDeleteMenuItem(); |
| 99 | + await n8n.workflowSettingsModal.confirmDeleteModal(); |
| 100 | + |
| 101 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 102 | + await expect(n8n.page).toHaveURL(/\/workflows$/); |
| 103 | + }); |
| 104 | + |
| 105 | + test('should archive nonactive workflow and then unarchive it', async ({ n8n }) => { |
| 106 | + const workflowId = await saveWorkflowAndGetId(n8n); |
| 107 | + await expect(n8n.canvas.getArchivedTag()).not.toBeAttached(); |
| 108 | + |
| 109 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 110 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 111 | + |
| 112 | + await n8n.workflowSettingsModal.clickArchiveMenuItem(); |
| 113 | + |
| 114 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 115 | + await expect(n8n.page).toHaveURL(/\/workflows$/); |
| 116 | + |
| 117 | + await goToWorkflow(n8n, workflowId); |
| 118 | + |
| 119 | + await expect(n8n.canvas.getArchivedTag()).toBeVisible(); |
| 120 | + await expect(n8n.canvas.getNodeCreatorPlusButton()).not.toBeAttached(); |
| 121 | + |
| 122 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 123 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 124 | + await n8n.workflowSettingsModal.clickUnarchiveMenuItem(); |
| 125 | + |
| 126 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 127 | + await expect(n8n.canvas.getArchivedTag()).not.toBeAttached(); |
| 128 | + await expect(n8n.canvas.getNodeCreatorPlusButton()).toBeVisible(); |
| 129 | + }); |
| 130 | + |
| 131 | + test('should not show unpublish menu item for non-published workflow', async ({ n8n }) => { |
| 132 | + await n8n.canvas.addNode(SCHEDULE_TRIGGER_NODE_NAME, { closeNDV: true }); |
| 133 | + await n8n.canvas.saveWorkflow(); |
| 134 | + |
| 135 | + await expect(n8n.canvas.getPublishedIndicator()).not.toBeVisible(); |
| 136 | + |
| 137 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 138 | + await expect(n8n.workflowSettingsModal.getUnpublishMenuItem()).not.toBeAttached(); |
| 139 | + }); |
| 140 | + |
| 141 | + // TODO: flaky test - 18 similar failures across 10 branches in last 14 days |
| 142 | + test.skip('should unpublish a published workflow', async ({ n8n }) => { |
| 143 | + await n8n.canvas.addNode(SCHEDULE_TRIGGER_NODE_NAME, { closeNDV: true }); |
| 144 | + await n8n.canvas.publishWorkflow(); |
| 145 | + await n8n.page.keyboard.press('Escape'); |
| 146 | + |
| 147 | + await expect(n8n.canvas.getPublishedIndicator()).toBeVisible(); |
| 148 | + |
| 149 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 150 | + await n8n.workflowSettingsModal.clickUnpublishMenuItem(); |
| 151 | + |
| 152 | + await expect(n8n.workflowSettingsModal.getUnpublishModal()).toBeVisible(); |
| 153 | + await n8n.workflowSettingsModal.confirmUnpublishModal(); |
| 154 | + |
| 155 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 156 | + await expect(n8n.canvas.getPublishedIndicator()).not.toBeVisible(); |
| 157 | + }); |
| 158 | + |
| 159 | + // eslint-disable-next-line n8n-local-rules/no-skipped-tests -- Flaky in multi-main mode |
| 160 | + test.skip('should unpublish published workflow on archive', async ({ n8n }) => { |
| 161 | + await n8n.canvas.addNode(SCHEDULE_TRIGGER_NODE_NAME, { closeNDV: true }); |
| 162 | + const workflowId = await saveWorkflowAndGetId(n8n); |
| 163 | + await n8n.canvas.publishWorkflow(); |
| 164 | + await n8n.page.keyboard.press('Escape'); |
| 165 | + |
| 166 | + await expect(n8n.canvas.getPublishedIndicator()).toBeVisible(); |
| 167 | + |
| 168 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 169 | + await n8n.workflowSettingsModal.clickArchiveMenuItem(); |
| 170 | + await n8n.workflowSettingsModal.confirmArchiveModal(); |
| 171 | + |
| 172 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 173 | + await expect(n8n.page).toHaveURL(/\/workflows$/); |
| 174 | + |
| 175 | + await goToWorkflow(n8n, workflowId); |
| 176 | + |
| 177 | + await expect(n8n.canvas.getArchivedTag()).toBeVisible(); |
| 178 | + await expect(n8n.canvas.getPublishedIndicator()).not.toBeVisible(); |
| 179 | + await expect(n8n.canvas.getPublishButton()).not.toBeVisible(); |
| 180 | + |
| 181 | + await expect(n8n.workflowSettingsModal.getWorkflowMenu()).toBeVisible(); |
| 182 | + await n8n.workflowSettingsModal.getWorkflowMenu().click(); |
| 183 | + await n8n.workflowSettingsModal.clickUnarchiveMenuItem(); |
| 184 | + |
| 185 | + await expect(n8n.notifications.getSuccessNotifications().first()).toBeVisible(); |
| 186 | + await expect(n8n.canvas.getArchivedTag()).not.toBeAttached(); |
| 187 | + |
| 188 | + await n8n.canvas.publishWorkflow(); |
| 189 | + await n8n.page.keyboard.press('Escape'); |
| 190 | + |
| 191 | + await expect(n8n.canvas.getPublishedIndicator()).toBeVisible(); |
| 192 | + await expect(n8n.canvas.getOpenPublishModalButton()).toBeVisible(); |
| 193 | + }); |
| 194 | +}); |
0 commit comments