From 6ee8a666c7a277b56721acb1074519446b56985f Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Thu, 24 Aug 2023 23:36:02 +0530 Subject: [PATCH] test: retry logic for cell access & page reload wait Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/common/Cell/index.ts | 17 ++++++++++++++--- .../tests/db/views/viewGridShare.spec.ts | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index 5f5d8ace99..73366bcf08 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/index.ts @@ -300,19 +300,30 @@ export class CellPageObject extends BasePage { if (type === 'bt') { const chips = cell.locator('.chips > .chip'); - await expect(await chips.count()).toBe(count); + expect(await chips.count()).toBe(count); for (let i = 0; i < value.length; ++i) { await chips.nth(i).locator('.name').waitFor({ state: 'visible' }); await chips.nth(i).locator('.name').scrollIntoViewIfNeeded(); - await expect(await chips.nth(i).locator('.name')).toHaveText(value[i]); + await expect(chips.nth(i).locator('.name')).toHaveText(value[i]); } return; } // verify chip count & contents if (count) { - await expect(await cell.innerText()).toContain(`${count} ${count === 1 ? options.singular : options.plural}`); + const expectedText = `${count} ${count === 1 ? options.singular : options.plural}`; + let retryCount = 0; + while (retryCount < 5) { + const receivedText = await linkText.innerText(); + if (receivedText.includes(expectedText)) { + break; + } + retryCount++; + // add delay of 100ms + await this.rootPage.waitForTimeout(100 * retryCount); + } + expect(await cell.innerText()).toContain(expectedText); } if (verifyChildList) { diff --git a/tests/playwright/tests/db/views/viewGridShare.spec.ts b/tests/playwright/tests/db/views/viewGridShare.spec.ts index 7d0c3d10b2..cdae92f96f 100644 --- a/tests/playwright/tests/db/views/viewGridShare.spec.ts +++ b/tests/playwright/tests/db/views/viewGridShare.spec.ts @@ -98,6 +98,8 @@ test.describe('Shared view', () => { await dashboard.goto(); await page.reload(); + // kludge: wait for 3 seconds to avoid flaky test + await page.waitForTimeout(5000); await dashboard.treeView.openTable({ title: 'Film' }); await dashboard.grid.toolbar.clickGroupBy(); @@ -106,6 +108,8 @@ test.describe('Shared view', () => { await page.goto(sharedLink); await page.reload(); + // kludge: wait for 3 seconds to avoid flaky test + await page.waitForTimeout(5000); await sharedPage.grid.cell.verify({ index: 0, columnHeader: 'Title', value: 'ZORRO ARK' }); });