test: add wait for substeps response

This commit is contained in:
Jakub P.
2024-08-30 12:53:35 +02:00
parent 01340f4597
commit ec22184087
2 changed files with 17 additions and 8 deletions

View File

@@ -71,7 +71,11 @@ export class FlowEditorPage extends AuthenticatedPage {
await this.page.getByRole('option', { name: appName }).click(); await this.page.getByRole('option', { name: appName }).click();
await expect(this.eventAutocomplete).toBeVisible(); await expect(this.eventAutocomplete).toBeVisible();
await this.eventAutocomplete.click(); 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(); await this.continueButton.click();
} }

View File

@@ -1,5 +1,4 @@
const { test, expect } = require('../../fixtures/index'); const { test, expect } = require('../../fixtures/index');
const axios = require('axios');
test.describe('Webhook flow', () => { test.describe('Webhook flow', () => {
test.beforeEach(async ({ page }) => { 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 ({ test('Create a new flow with a sync Webhook step then a Webhook step', async ({
flowEditorPage, flowEditorPage,
page, page,
request
}) => { }) => {
await flowEditorPage.flowName.click(); await flowEditorPage.flowName.click();
await flowEditorPage.flowNameInput.fill('syncWebhook'); await flowEditorPage.flowNameInput.fill('syncWebhook');
@@ -36,20 +36,23 @@ test.describe('Webhook flow', () => {
.locator('[contenteditable]') .locator('[contenteditable]')
.fill('response from webhook'); .fill('response from webhook');
await flowEditorPage.clickAway(); await flowEditorPage.clickAway();
await expect(page.getByTestId("parameters.headers.0.key-power-input")).toBeVisible();
await expect(flowEditorPage.continueButton).toBeEnabled(); await expect(flowEditorPage.continueButton).toBeEnabled();
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
await flowEditorPage.testAndContinue(); await flowEditorPage.testAndContinue();
await flowEditorPage.publishFlowButton.click(); await flowEditorPage.publishFlowButton.click();
await expect(flowEditorPage.infoSnackbar).toBeVisible();
const response = await axios.get(syncWebhookUrl); const response = await request.get(syncWebhookUrl);
await expect(response.status).toBe(200); await expect(response.status()).toBe(200);
await expect(response.data).toBe('response from webhook'); await expect(await response.text()).toBe('response from webhook');
}); });
test('Create a new flow with an async Webhook step then a Webhook step', async ({ test('Create a new flow with an async Webhook step then a Webhook step', async ({
flowEditorPage, flowEditorPage,
page, page,
request
}) => { }) => {
await flowEditorPage.flowName.click(); await flowEditorPage.flowName.click();
await flowEditorPage.flowNameInput.fill('asyncWebhook'); await flowEditorPage.flowNameInput.fill('asyncWebhook');
@@ -72,14 +75,16 @@ test.describe('Webhook flow', () => {
.locator('[contenteditable]') .locator('[contenteditable]')
.fill('response from webhook'); .fill('response from webhook');
await flowEditorPage.clickAway(); await flowEditorPage.clickAway();
await expect(page.getByTestId("parameters.headers.0.key-power-input")).toBeVisible();
await expect(flowEditorPage.continueButton).toBeEnabled(); await expect(flowEditorPage.continueButton).toBeEnabled();
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
await flowEditorPage.testAndContinue(); await flowEditorPage.testAndContinue();
await flowEditorPage.publishFlowButton.click(); await flowEditorPage.publishFlowButton.click();
await expect(flowEditorPage.infoSnackbar).toBeVisible();
const response = await axios.get(asyncWebhookUrl); const response = await request.get(asyncWebhookUrl);
await expect(response.status).toBe(204); await expect(response.status()).toBe(204);
await expect(response.data).toBe(''); await expect(await response.text()).toBe('');
}); });
}); });