Skip to content

Commit ad62c8f

Browse files
authored
test: Fix flaky demo test (#25076)
1 parent 659de94 commit ad62c8f

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

packages/testing/playwright/pages/DemoPage.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { BasePage } from './BasePage';
22

33
export class DemoPage extends BasePage {
4-
async visitDemoPage(theme?: 'dark' | 'light') {
4+
async goto(theme?: 'dark' | 'light') {
55
const query = theme ? `?theme=${theme}` : '';
66
await this.page.goto('/workflows/demo' + query);
7-
await this.getBody().waitFor({ state: 'visible' });
8-
await this.page.evaluate(() => {
9-
// @ts-expect-error - this is a custom property added by the demo page
10-
window.preventNodeViewBeforeUnload = true;
11-
});
7+
await this.page.getByTestId('canvas-background').waitFor({ state: 'visible' });
128
}
139

1410
/**

packages/testing/playwright/tests/e2e/app-config/demo.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ test.describe('Demo', () => {
1717
});
1818

1919
test('can import template', async ({ n8n }) => {
20-
await n8n.demo.visitDemoPage();
20+
await n8n.demo.goto();
2121
expect(await n8n.notifications.getAllNotificationTexts()).toHaveLength(0);
2222
await n8n.demo.importWorkflow(simpleWorkflow);
2323
await expect(n8n.canvas.getCanvasNodes()).toHaveCount(3);
2424
});
2525

2626
test('can import workflow with pin data', async ({ n8n }) => {
27-
await n8n.demo.visitDemoPage();
27+
await n8n.demo.goto();
2828
await expect(n8n.canvas.canvasPane()).toBeVisible();
2929
await n8n.demo.importWorkflow(workflowWithPinned);
3030
await expect(n8n.canvas.getCanvasNodes()).toHaveCount(2);
@@ -34,13 +34,13 @@ test.describe('Demo', () => {
3434
});
3535

3636
test('can override theme to dark', async ({ n8n }) => {
37-
await n8n.demo.visitDemoPage('dark');
37+
await n8n.demo.goto('dark');
3838
await expect(n8n.demo.getBody()).toHaveAttribute('data-theme', 'dark');
3939
expect(await n8n.notifications.getAllNotificationTexts()).toHaveLength(0);
4040
});
4141

4242
test('can override theme to light', async ({ n8n }) => {
43-
await n8n.demo.visitDemoPage('light');
43+
await n8n.demo.goto('light');
4444
await expect(n8n.demo.getBody()).toHaveAttribute('data-theme', 'light');
4545
expect(await n8n.notifications.getAllNotificationTexts()).toHaveLength(0);
4646
});

0 commit comments

Comments
 (0)