From ec2218408708e8ef9e94b89030d362041b08b8b8 Mon Sep 17 00:00:00 2001 From: "Jakub P." Date: Fri, 30 Aug 2024 12:53:35 +0200 Subject: [PATCH] test: add wait for substeps response --- .../e2e-tests/fixtures/flow-editor-page.js | 6 +++++- .../tests/app-integrations/webhook.spec.js | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/e2e-tests/fixtures/flow-editor-page.js b/packages/e2e-tests/fixtures/flow-editor-page.js index 6563502d..c68ab398 100644 --- a/packages/e2e-tests/fixtures/flow-editor-page.js +++ b/packages/e2e-tests/fixtures/flow-editor-page.js @@ -71,7 +71,11 @@ export class FlowEditorPage extends AuthenticatedPage { await this.page.getByRole('option', { name: appName }).click(); await expect(this.eventAutocomplete).toBeVisible(); await this.eventAutocomplete.click(); - await this.page.getByRole('option', { name: eventName }).click(); + await expect(this.page.locator('[data-testid="ErrorIcon"]')).toHaveCount(2); + await Promise.all([ + this.page.waitForResponse(resp => /(apps\/.*\/actions\/.*\/substeps)/.test(resp.url()) && resp.status() === 200), + this.page.getByRole('option', { name: eventName }).click(), + ]); await this.continueButton.click(); } diff --git a/packages/e2e-tests/tests/app-integrations/webhook.spec.js b/packages/e2e-tests/tests/app-integrations/webhook.spec.js index 7ea8a53a..e457abb8 100644 --- a/packages/e2e-tests/tests/app-integrations/webhook.spec.js +++ b/packages/e2e-tests/tests/app-integrations/webhook.spec.js @@ -1,5 +1,4 @@ const { test, expect } = require('../../fixtures/index'); -const axios = require('axios'); test.describe('Webhook flow', () => { test.beforeEach(async ({ page }) => { @@ -13,6 +12,7 @@ test.describe('Webhook flow', () => { test('Create a new flow with a sync Webhook step then a Webhook step', async ({ flowEditorPage, page, + request }) => { await flowEditorPage.flowName.click(); await flowEditorPage.flowNameInput.fill('syncWebhook'); @@ -36,20 +36,23 @@ test.describe('Webhook flow', () => { .locator('[contenteditable]') .fill('response from webhook'); await flowEditorPage.clickAway(); + await expect(page.getByTestId("parameters.headers.0.key-power-input")).toBeVisible(); await expect(flowEditorPage.continueButton).toBeEnabled(); await flowEditorPage.continueButton.click(); await flowEditorPage.testAndContinue(); await flowEditorPage.publishFlowButton.click(); + await expect(flowEditorPage.infoSnackbar).toBeVisible(); - const response = await axios.get(syncWebhookUrl); - await expect(response.status).toBe(200); - await expect(response.data).toBe('response from webhook'); + const response = await request.get(syncWebhookUrl); + await expect(response.status()).toBe(200); + await expect(await response.text()).toBe('response from webhook'); }); test('Create a new flow with an async Webhook step then a Webhook step', async ({ flowEditorPage, page, + request }) => { await flowEditorPage.flowName.click(); await flowEditorPage.flowNameInput.fill('asyncWebhook'); @@ -72,14 +75,16 @@ test.describe('Webhook flow', () => { .locator('[contenteditable]') .fill('response from webhook'); await flowEditorPage.clickAway(); + await expect(page.getByTestId("parameters.headers.0.key-power-input")).toBeVisible(); await expect(flowEditorPage.continueButton).toBeEnabled(); await flowEditorPage.continueButton.click(); await flowEditorPage.testAndContinue(); await flowEditorPage.publishFlowButton.click(); + await expect(flowEditorPage.infoSnackbar).toBeVisible(); - const response = await axios.get(asyncWebhookUrl); - await expect(response.status).toBe(204); - await expect(response.data).toBe(''); + const response = await request.get(asyncWebhookUrl); + await expect(response.status()).toBe(204); + await expect(await response.text()).toBe(''); }); });