From 2d8d36c885ba93d67b5d8a917951a825859c4245 Mon Sep 17 00:00:00 2001 From: Karan Hotchandani <33024356+karanh37@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:41:11 +0530 Subject: [PATCH] chore(ui): fix flaky playwright (#23457) * fix expand collapse test issue * fix domain test --- .../ui/playwright/e2e/Pages/Domains.spec.ts | 5 +-- .../ui/playwright/e2e/Pages/Glossary.spec.ts | 40 ++++--------------- .../resources/ui/playwright/utils/domain.ts | 12 ------ .../resources/ui/playwright/utils/glossary.ts | 8 ++++ 4 files changed, 18 insertions(+), 47 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts index 7dec8c347a7..8c2096f6921 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts @@ -174,9 +174,8 @@ test.describe('Domains', () => { }); await test.step('Add assets to domain', async () => { - await redirectToHomePage(page); - await sidebarClick(page, SidebarItem.DOMAIN); - await addAssetsToDomain(page, domain, assets); + await page.getByTestId('assets').click(); + await addAssetsToDomain(page, domain, assets, false); }); await test.step('Delete domain using delete modal', async () => { diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts index 4a9df0739be..75338a6ffd1 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts @@ -59,6 +59,7 @@ import { filterStatus, goToAssetsTab, openColumnDropdown, + performExpandAll, renameGlossaryTerm, selectActiveGlossary, selectActiveGlossaryTerm, @@ -823,11 +824,7 @@ test.describe('Glossary tests', () => { }) ).not.toBeVisible(); - const termRes = page.waitForResponse('/api/v1/glossaryTerms?*'); - - // verify the term is moved under the parent term - await page.getByTestId('expand-collapse-all-button').click(); - await termRes; + await performExpandAll(page); await expect( page.getByRole('cell', { @@ -842,7 +839,7 @@ test.describe('Glossary tests', () => { await redirectToHomePage(page); await sidebarClick(page, SidebarItem.GLOSSARY); await selectActiveGlossary(page, glossary1.data.displayName); - await page.getByTestId('expand-collapse-all-button').click(); + await performExpandAll(page); await dragAndDropTerm( page, @@ -918,11 +915,7 @@ test.describe('Glossary tests', () => { }) ).not.toBeVisible(); - const termRes = page.waitForResponse('/api/v1/glossaryTerms?*'); - - // verify the term is moved under the parent term - await page.getByTestId('expand-collapse-all-button').click(); - await termRes; + await performExpandAll(page); await expect( page.getByRole('cell', { @@ -971,11 +964,7 @@ test.describe('Glossary tests', () => { }) ).not.toBeVisible(); - const termRes = page.waitForResponse('/api/v1/glossaryTerms?*'); - - // verify the term is moved under the parent term - await page.getByTestId('expand-collapse-all-button').click(); - await termRes; + await performExpandAll(page); await expect( page.getByRole('cell', { @@ -1029,12 +1018,7 @@ test.describe('Glossary tests', () => { await selectActiveGlossary(page, glossary2.data.displayName); - const termRes = page.waitForResponse( - '/api/v1/glossaryTerms?directChildrenOf=*&fields=childrenCount%2Cowners%2Creviewers&limit=1000' - ); - // verify the term is moved to the destination glossary - await page.getByTestId('expand-collapse-all-button').click(); - await termRes; + await performExpandAll(page); await expect( page.getByRole('cell', { @@ -1244,11 +1228,7 @@ test.describe('Glossary tests', () => { await selectActiveGlossaryTerm(page, glossaryTerm1.data.displayName); await page.getByTestId('terms').click(); - const termRes = page.waitForResponse( - '/api/v1/glossaryTerms?directChildrenOf=*&fields=childrenCount%2Cowners%2Creviewers&limit=1000' - ); - await page.getByTestId('expand-collapse-all-button').click(); - await termRes; + await performExpandAll(page); await expect( page.getByRole('cell', { name: glossaryTerm2.data.displayName }) @@ -1440,11 +1420,7 @@ test.describe('Glossary tests', () => { await sidebarClick(page, SidebarItem.GLOSSARY); await selectActiveGlossary(page, glossary1.data.displayName); - const termRes = page.waitForResponse( - '/api/v1/glossaryTerms?directChildrenOf=*&fields=childrenCount%2Cowners%2Creviewers&limit=1000' - ); - await page.getByTestId('expand-collapse-all-button').click(); - await termRes; + await performExpandAll(page); await expect( page.getByRole('cell', { name: glossaryTerm1.data.displayName }) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts index 2fbafaae660..8349afd02f1 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts @@ -10,18 +10,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * Copyright 2024 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import test, { APIRequestContext, expect, Page } from '@playwright/test'; import { get, isEmpty, isUndefined } from 'lodash'; import { SidebarItem } from '../constant/sidebar'; diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts index ec7bd41c88e..8e87800720a 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/glossary.ts @@ -1682,3 +1682,11 @@ export const setupGlossaryDenyPermissionTest = async ( cleanup, }; }; + +export const performExpandAll = async (page: Page) => { + const termRes = page.waitForResponse( + '/api/v1/glossaryTerms?directChildrenOf=*&fields=childrenCount%2Cowners%2Creviewers*' + ); + await page.getByTestId('expand-collapse-all-button').click(); + await termRes; +};