diff --git a/tests/playwright/pages/Base.ts b/tests/playwright/pages/Base.ts index 2b37d28661..b1aa1778eb 100644 --- a/tests/playwright/pages/Base.ts +++ b/tests/playwright/pages/Base.ts @@ -23,53 +23,32 @@ export default abstract class BasePage { requestUrlPathToMatch, // A function that takes the response body and returns true if the response is the one we are looking for responseJsonMatcher, - debug = false, - debugKey, }: { uiAction: () => Promise; requestUrlPathToMatch: string; httpMethodsToMatch?: string[]; responseJsonMatcher?: ResponseSelector; - debug?: boolean; - debugKey?: string; }) { - const waitForResponsePromise = this.rootPage.waitForResponse(async res => { - let isResJsonMatched = true; - if (responseJsonMatcher) { - try { - isResJsonMatched = responseJsonMatcher(await res.json()); - } catch (e) { - return false; - } - } + const [res] = await Promise.all([ + this.rootPage.waitForResponse( + res => + res.url().includes(requestUrlPathToMatch) && + res.status() === 200 && + httpMethodsToMatch.includes(res.request().method()) + ), + uiAction(), + ]); - if (debug) { - console.log(`${debugKey},waitForResponse`, { - resUrl: res.request().url(), - resMethod: res.request().method(), - }); - console.log(`${debugKey},result`, { - resUrlResult: res.request().url().includes(requestUrlPathToMatch), - resMethodResult: httpMethodsToMatch.includes(res.request().method()), - resJsonResult: isResJsonMatched, - }); + // handle JSON matcher if provided + let isResJsonMatched = true; + if (responseJsonMatcher) { + try { + isResJsonMatched = responseJsonMatcher(res.json()); + } catch { + isResJsonMatched = false; } - - const found = - res.request().url().includes(requestUrlPathToMatch) && - httpMethodsToMatch.includes(res.request().method()) && - isResJsonMatched; - - return found; - }); - - const uiActionWithDelay = () => { - // Create a promise that resolves after a delay - const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); - // Returning a promise that resolves with the result after the a delay - return delay(100).then(() => uiAction()); - }; - await Promise.all([waitForResponsePromise, uiActionWithDelay()]); + } + return isResJsonMatched; } async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise; filePath: string[] }) { diff --git a/tests/playwright/pages/Dashboard/Grid/index.ts b/tests/playwright/pages/Dashboard/Grid/index.ts index c59971c7b6..d008b3e8f1 100644 --- a/tests/playwright/pages/Dashboard/Grid/index.ts +++ b/tests/playwright/pages/Dashboard/Grid/index.ts @@ -69,6 +69,7 @@ export class GridPage extends BasePage { index, columnHeader, }); + await this.rootPage.waitForTimeout(500); await cell.locator('input').fill(value); } diff --git a/tests/playwright/pages/Dashboard/WebhookForm/index.ts b/tests/playwright/pages/Dashboard/WebhookForm/index.ts index c6d5827560..acceb38aff 100644 --- a/tests/playwright/pages/Dashboard/WebhookForm/index.ts +++ b/tests/playwright/pages/Dashboard/WebhookForm/index.ts @@ -148,8 +148,10 @@ export class WebhookFormPage extends BasePage { async configureHeader({ key, value }: { key: string; value: string }) { // hardcode "Content-type: application/json" await this.get().locator(`.ant-tabs-tab-btn:has-text("Headers")`).click(); + await this.rootPage.waitForTimeout(500); await this.get().locator('.nc-input-hook-header-key').click(); + await this.rootPage.waitForTimeout(500); // kludge, as the dropdown is not visible even after scroll into view await this.rootPage.locator('.ant-select-dropdown:visible').hover(); diff --git a/tests/playwright/pages/Dashboard/common/Topbar/index.ts b/tests/playwright/pages/Dashboard/common/Topbar/index.ts index e629096b7a..60bfc9bfc1 100644 --- a/tests/playwright/pages/Dashboard/common/Topbar/index.ts +++ b/tests/playwright/pages/Dashboard/common/Topbar/index.ts @@ -68,6 +68,7 @@ export class TopbarPage extends BasePage { async openDetailedTab() { await this.btn_details.click(); + await this.rootPage.waitForTimeout(500); } async openDataTab() {