Skip to content

Commit d2d4704

Browse files
E2E: flacky try fix or just know reason (#1420)
Co-authored-by: German Osin <[email protected]>
1 parent c6313ce commit d2d4704

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

e2e-playwright/src/steps/KafkaConnect.steps.ts

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Given, When, Then, setDefaultTimeout } from "@cucumber/cucumber";
33
import { expectVisibility } from "../services/uiHelper";
44
import { PlaywrightWorld } from "../support/PlaywrightWorld";
5+
import { expect } from "@playwright/test";
56

67
setDefaultTimeout(60 * 1000 * 2);
78

@@ -25,8 +26,29 @@ Given('KafkaConnect satus is: {string}, type is: {string}', async function(this:
2526
});
2627

2728
Given('KafkaConnect row menu menu item {string} is clicked', async function(this: PlaywrightWorld, menuItem: string) {
28-
await this.locators.connectors.rowMenu.click();
29-
await this.locators.connectors.rowMenuItem(menuItem).click();
29+
const { page } = this;
30+
const rowMenu = this.locators.connectors.rowMenu;
31+
const rowMenuItem = this.locators.connectors.rowMenuItem(menuItem);
32+
33+
async function attemptClick() {
34+
await expect(rowMenu).toBeVisible({ timeout: 5000 });
35+
await expect(rowMenu).toBeEnabled({ timeout: 5000 });
36+
await rowMenu.scrollIntoViewIfNeeded();
37+
38+
await rowMenu.click();
39+
40+
await expect(rowMenuItem).toBeVisible({ timeout: 5000 });
41+
await rowMenuItem.click();
42+
}
43+
44+
try {
45+
await attemptClick();
46+
} catch (firstErr) {
47+
await page.reload({ waitUntil: 'domcontentloaded' });
48+
await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {});
49+
50+
await attemptClick();
51+
}
3052
});
3153

3254
When('KafkaConnect connector named: {string} clicked', async function(this: PlaywrightWorld, name: string) {
@@ -42,8 +64,29 @@ Given('KafkaConnect connector page status is: {string}', async function(this: Pl
4264
});
4365

4466
When('KafkaConnect connector menu item {string} clicked', async function(this: PlaywrightWorld, menuItem: string) {
45-
await this.locators.connectors.internalMenuButton.click();
46-
await this.locators.connectors.internalMenuButtonItem(menuItem).click();
67+
const { page } = this;
68+
const menuButton = this.locators.connectors.internalMenuButton;
69+
const menuItemLocator = this.locators.connectors.internalMenuButtonItem(menuItem);
70+
71+
async function attemptClick() {
72+
await expect(menuButton).toBeVisible({ timeout: 5000 });
73+
await expect(menuButton).toBeEnabled({ timeout: 5000 });
74+
75+
await menuButton.click();
76+
77+
await expect(menuItemLocator).toBeVisible({ timeout: 5000 });
78+
await menuItemLocator.click();
79+
}
80+
81+
try {
82+
await attemptClick();
83+
} catch (firstErr) {
84+
await page.reload({ waitUntil: 'domcontentloaded' });
85+
86+
await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {});
87+
88+
await attemptClick();
89+
}
4790
});
4891

4992
Given('KafkaConnect connector page state is: {string}', async function(this: PlaywrightWorld, state: string) {

0 commit comments

Comments
 (0)