|
| 1 | +import type { n8nPage } from '../pages/n8nPage'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Composer for UI test entry points. All methods in this class navigate to or verify UI state. |
| 5 | + * For API-only testing, use the standalone `api` fixture directly instead. |
| 6 | + */ |
| 7 | +export class TestEntryComposer { |
| 8 | + constructor(private readonly n8n: n8nPage) {} |
| 9 | + |
| 10 | + /** |
| 11 | + * Start UI test from the home page and navigate to canvas |
| 12 | + */ |
| 13 | + async fromHome() { |
| 14 | + await this.n8n.goHome(); |
| 15 | + await this.n8n.page.waitForURL('/home/workflows'); |
| 16 | + } |
| 17 | + |
| 18 | + /** |
| 19 | + * Start UI test from a blank canvas (assumes already on canvas) |
| 20 | + */ |
| 21 | + async fromBlankCanvas() { |
| 22 | + await this.n8n.goHome(); |
| 23 | + await this.n8n.workflows.clickAddWorkflowButton(); |
| 24 | + // Verify we're on canvas |
| 25 | + await this.n8n.canvas.canvasPane().isVisible(); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Start UI test from a workflow in a new project |
| 30 | + */ |
| 31 | + async fromNewProject() { |
| 32 | + // Enable features to allow us to create a new project |
| 33 | + await this.n8n.api.enableFeature('projectRole:admin'); |
| 34 | + await this.n8n.api.enableFeature('projectRole:editor'); |
| 35 | + await this.n8n.api.setMaxTeamProjectsQuota(-1); |
| 36 | + |
| 37 | + // Create a project using the API |
| 38 | + const response = await this.n8n.api.projectApi.createProject(); |
| 39 | + |
| 40 | + const projectId = response.id; |
| 41 | + await this.n8n.page.goto(`workflow/new?projectId=${projectId}`); |
| 42 | + await this.n8n.canvas.canvasPane().isVisible(); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Start UI test from the canvas of an imported workflow |
| 47 | + * Returns the workflow import result for use in the test |
| 48 | + */ |
| 49 | + async fromImportedWorkflow(workflowFile: string) { |
| 50 | + const workflowImportResult = await this.n8n.api.workflowApi.importWorkflow(workflowFile); |
| 51 | + await this.n8n.page.goto(`workflow/${workflowImportResult.workflowId}`); |
| 52 | + return workflowImportResult; |
| 53 | + } |
| 54 | +} |
0 commit comments