From d5ca346270f893c0311319a90c5d095a72ab481d Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:08:34 +0530 Subject: [PATCH] fix(test): flaky login spec (#23359) * fix(test): flaky login spec * fix ingestion bot spec --- .../ui/playwright/e2e/Flow/IngestionBot.spec.ts | 14 +++++++++++++- .../ui/playwright/e2e/Pages/Login.spec.ts | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts index c05615cf8e9..b8c1c86cb4a 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { expect, Page, test as base } from '@playwright/test'; +import { test as base, expect, Page } from '@playwright/test'; import { SidebarItem } from '../../constant/sidebar'; import { Domain } from '../../support/domain/Domain'; import { AdminClass } from '../../support/user/AdminClass'; @@ -109,6 +109,9 @@ test.describe('Ingestion Bot ', () => { await redirectToHomePage(page); await sidebarClick(page, SidebarItem.DOMAIN); await page.waitForLoadState('networkidle'); + await page.waitForSelector('[data-testid="loader"]', { + state: 'detached', + }); await selectDomain(page, domain1.data); await addAssetsToDomain(page, domain1, domainAsset1); @@ -116,6 +119,9 @@ test.describe('Ingestion Bot ', () => { await redirectToHomePage(page); await sidebarClick(page, SidebarItem.DOMAIN); await page.waitForLoadState('networkidle'); + await page.waitForSelector('[data-testid="loader"]', { + state: 'detached', + }); await selectDomain(page, domain2.data); await addAssetsToDomain(page, domain2, domainAsset2); }); @@ -159,6 +165,9 @@ test.describe('Ingestion Bot ', () => { await redirectToHomePage(page); await sidebarClick(page, SidebarItem.DOMAIN); await page.waitForLoadState('networkidle'); + await page.waitForSelector('[data-testid="loader"]', { + state: 'detached', + }); await selectDomain(page, domain1.data); await addServicesToDomain(page, domain1.data, [ domainAsset1[0].get().service, @@ -168,6 +177,9 @@ test.describe('Ingestion Bot ', () => { await redirectToHomePage(page); await sidebarClick(page, SidebarItem.DOMAIN); await page.waitForLoadState('networkidle'); + await page.waitForSelector('[data-testid="loader"]', { + state: 'detached', + }); await selectDomain(page, domain2.data); await addServicesToDomain(page, domain2.data, [ domainAsset2[0].get().service, diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Login.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Login.spec.ts index 249d3a30b8d..f0abdda7269 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Login.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Login.spec.ts @@ -61,6 +61,7 @@ test.describe('Login flow should work properly', () => { test('Signup and Login with signed up credentials', async ({ page }) => { await page.goto('/'); + await page.waitForLoadState('networkidle'); await expect(page).toHaveURL(`/signin`); @@ -85,15 +86,21 @@ test.describe('Login flow should work properly', () => { await expect(page.locator('#password')).toHaveAttribute('type', 'password'); await page.locator('#confirmPassword').fill(CREDENTIALS.password); + + const createUserResponse = page.waitForResponse(`/api/v1/users/signup`); // Click on create account button await page.getByRole('button', { name: 'Create Account' }).click(); + await createUserResponse; await expect(page).toHaveURL(`/signin`); // Login with the created user await page.fill('#email', CREDENTIALS.email); await page.fill('#password', CREDENTIALS.password); + const loginResponse = page.waitForResponse(`/api/v1/users/login`); await page.locator('[data-testid="login"]').click(); + await loginResponse; + await page.waitForLoadState('networkidle'); await expect(page).toHaveURL(`/my-data`); @@ -107,10 +114,13 @@ test.describe('Login flow should work properly', () => { test('Signin using invalid credentials', async ({ page }) => { await page.goto(`/signin`); + await page.waitForLoadState('networkidle'); // Login with invalid email await page.fill('#email', invalidEmail); await page.fill('#password', CREDENTIALS.password); + const loginResponse = page.waitForResponse(`/api/v1/users/login`); await page.locator('[data-testid="login"]').click(); + await loginResponse; await expect(page.locator('[data-testid="alert-bar"]')).toHaveText( LOGIN_ERROR_MESSAGE @@ -119,7 +129,9 @@ test.describe('Login flow should work properly', () => { // Login with invalid password await page.fill('#email', CREDENTIALS.email); await page.fill('#password', invalidPassword); + const loginResponse2 = page.waitForResponse(`/api/v1/users/login`); await page.locator('[data-testid="login"]').click(); + await loginResponse2; await expect(page.locator('[data-testid="alert-bar"]')).toHaveText( LOGIN_ERROR_MESSAGE