Skip to content

Commit c7223a0

Browse files
Chore(UI): Fix playwright test failures in AUTs (#27706)
* Fix the failures in ExplorePageRightPanel, EntityPermissions, CustomProperties specs * Fix checkstyle * Fix customizeDetailsPage spec * Fix the test flakiness and failures * fix checkstyle
1 parent 7ae9be6 commit c7223a0

6 files changed

Lines changed: 22 additions & 111 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/CustomProperties.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ ALL_ENTITIES.forEach(({ key, makeInstance }) => {
303303
const { apiContext, afterAction } = await createNewPage(browser);
304304

305305
if (makeInstance !== null) {
306-
await mainEntity.cleanupCustomProperty(apiContext);
307306
await mainEntity.delete(apiContext);
308307
if (key === 'entity_dataProduct') {
309308
for (const domain of (mainEntity as DataProduct).getDomains()) {
@@ -495,9 +494,9 @@ ALL_ENTITIES.forEach(({ key, makeInstance }) => {
495494
await editButton.click();
496495

497496
await page.locator("pre[role='presentation']").last().click();
498-
await page.keyboard.type(
499-
"SELECT id, name, email\nFROM users\nWHERE active = true\nAND department = 'engineering'\nORDER BY created_at DESC\nLIMIT 100"
500-
);
497+
const value =
498+
"SELECT id, name, email\nFROM users\nWHERE active = true\nAND department = 'engineering'\nORDER BY created_at DESC\nLIMIT 100";
499+
await page.keyboard.type(value + '\n' + value);
501500

502501
const patchResponse = page.waitForResponse(
503502
`/api/v1/${entity.entityApiType}/*`

openmetadata-ui/src/main/resources/ui/playwright/support/entity/EntityClass.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import { DataProduct } from '../domain/DataProduct';
6565
import { Domain } from '../domain/Domain';
6666
import { GlossaryTerm } from '../glossary/GlossaryTerm';
6767
import { TagClass } from '../tag/TagClass';
68-
import { EntityTypeEndpoint, ENTITY_PATH } from './Entity.interface';
68+
import { EntityTypeEndpoint } from './Entity.interface';
6969

7070
export class EntityClass {
7171
type = '';
@@ -115,30 +115,6 @@ export class EntityClass {
115115
}
116116
}
117117

118-
async cleanupCustomProperty(apiContext: APIRequestContext) {
119-
// Delete custom property only for supported entities
120-
if (CustomPropertySupportedEntityList.includes(this.endpoint)) {
121-
await this.cleanupUser?.(apiContext);
122-
const entitySchemaResponse = await apiContext.get(
123-
`/api/v1/metadata/types/name/${
124-
ENTITY_PATH[this.endpoint as keyof typeof ENTITY_PATH]
125-
}`
126-
);
127-
const entitySchema = await entitySchemaResponse.json();
128-
await apiContext.patch(`/api/v1/metadata/types/${entitySchema.id}`, {
129-
data: [
130-
{
131-
op: 'remove',
132-
path: '/customProperties',
133-
},
134-
],
135-
headers: {
136-
'Content-Type': 'application/json-patch+json',
137-
},
138-
});
139-
}
140-
}
141-
142118
async domain(
143119
page: Page,
144120
domain1: Domain['responseData'],

openmetadata-ui/src/main/resources/ui/playwright/support/entity/EntityDataClass.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,6 @@ export class EntityDataClass {
213213
}
214214
}
215215

216-
static async cleanupCustomPropertyData(
217-
apiContext: APIRequestContext,
218-
entityType: string
219-
) {
220-
const entitySchemaResponse = await apiContext.get(
221-
`/api/v1/metadata/types/name/${entityType}`
222-
);
223-
const entitySchema = await entitySchemaResponse.json();
224-
await apiContext.patch(`/api/v1/metadata/types/${entitySchema.id}`, {
225-
data: [
226-
{
227-
op: 'remove',
228-
path: '/customProperties',
229-
},
230-
],
231-
headers: {
232-
'Content-Type': 'application/json-patch+json',
233-
},
234-
});
235-
}
236-
237216
static async preRequisitesForTests(apiContext: APIRequestContext) {
238217
// Add pre-requisites for tests
239218
const promises = [
@@ -380,12 +359,6 @@ export class EntityDataClass {
380359
this.worksheet2.delete(apiContext),
381360
];
382361

383-
for (const entityType of Object.values(CUSTOM_PROPERTIES_ENTITIES).map(
384-
(entity) => entity.name
385-
)) {
386-
await this.cleanupCustomPropertyData(apiContext, entityType);
387-
}
388-
389362
return await Promise.allSettled(promises);
390363
}
391364

openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ export const verifyTableColumnCustomPropertyPersistence = async ({
11451145
.includes(
11461146
`/api/v1/tables/name/${encodeURIComponent(tableFqn)}/columns`
11471147
) &&
1148-
response.url().includes('profile') &&
1148+
response.url().includes('fields') &&
11491149
response.request().method() === 'GET',
11501150
// TODO: Reduce timeout once the latency issue is fixed
11511151
{ timeout: 150_000 }

openmetadata-ui/src/main/resources/ui/playwright/utils/customizeNavigation.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* limitations under the License.
1212
*/
1313
import { expect, Page } from '@playwright/test';
14-
import { SidebarItem, SIDEBAR_LIST_ITEMS } from '../constant/sidebar';
14+
import { SIDEBAR_LIST_ITEMS, SidebarItem } from '../constant/sidebar';
1515
import { PersonaClass } from '../support/persona/PersonaClass';
1616

1717
const NAV_ITEMS = [
@@ -71,15 +71,7 @@ export const validateLeftSidebarWithHiddenItems = async (
7171
.locator(`[data-testid^="app-bar-item-"]`)
7272
.first();
7373

74-
try {
75-
// Wait for at least one child to be visible (with timeout)
76-
await anyChildInDropdown.waitFor({ state: 'visible', timeout: 3000 });
77-
} catch {
78-
// If no children are visible, the dropdown might not have expanded
79-
// Wait a bit more and continue
80-
// eslint-disable-next-line playwright/no-wait-for-timeout -- dropdown expansion fallback delay
81-
await page.waitForTimeout(500);
82-
}
74+
await expect(anyChildInDropdown).toBeVisible(); // Ensure at least one child is visible before proceeding
8375

8476
const childElement = page
8577
.locator(`[data-testid="app-bar-item-${items[1]}"]`)
@@ -103,15 +95,15 @@ export const validateLeftSidebarWithHiddenItems = async (
10395
}
10496

10597
await page.click(`[data-testid="${items[0]}"]`);
106-
107-
await page.mouse.move(1280, 0); // Move mouse to top right corner
108-
109-
continue;
11098
}
99+
const isNested = Object.keys(SIDEBAR_LIST_ITEMS).includes(item);
100+
111101
if (hiddenItems.includes(item)) {
112102
await expect(
113-
page.getByTestId('left-sidebar').getByTestId(`app-bar-item-${item}`)
103+
page.getByTestId(`app-bar-item-${item}`)
114104
).not.toBeVisible();
105+
} else if (isNested) {
106+
await expect(page.getByTestId(`app-bar-item-${item}`)).toBeVisible();
115107
} else {
116108
await expect(
117109
page.getByTestId('left-sidebar').getByTestId(`app-bar-item-${item}`)

openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,13 +1435,10 @@ export const navigateToSubDomain = async (
14351435
export const navigateToPortsTab = async (page: Page) => {
14361436
await waitForAllLoadersToDisappear(page);
14371437

1438-
const portsTab = page.getByTestId('input_output_ports');
1439-
await portsTab.waitFor({ state: 'visible' });
1440-
14411438
const portsViewResponse = page.waitForResponse((response) =>
14421439
response.url().includes('/portsView')
14431440
);
1444-
await portsTab.click();
1441+
await page.getByTestId('input_output_ports').click();
14451442
await portsViewResponse;
14461443
await waitForAllLoadersToDisappear(page);
14471444
};
@@ -1638,45 +1635,19 @@ export const selectDomainFromNavbar = async (
16381635
const domainDropdown = page.getByTestId('domain-dropdown');
16391636
const domainTree = page.getByTestId('domain-selectable-tree');
16401637
const searchTerm = domain.displayName ?? domain.name;
1641-
const domainOption = page.getByTestId(`tag-${domain.fullyQualifiedName}`);
1642-
1643-
const openDropdown = async () => {
1644-
await domainDropdown.click();
1645-
await domainTree.waitFor({ state: 'visible' });
1646-
};
1647-
1648-
await openDropdown();
1649-
1650-
const searchBar = domainTree.locator('input[placeholder]').first();
1651-
1652-
await expect
1653-
.poll(
1654-
async () => {
1655-
if (!(await domainTree.isVisible().catch(() => false))) {
1656-
await openDropdown();
1657-
}
16581638

1659-
const isSearchBarVisible = await searchBar
1660-
.isVisible()
1661-
.catch(() => false);
1639+
await domainDropdown.click();
1640+
await page
1641+
.getByTestId('domain-selectable-tree')
1642+
.waitFor({ state: 'visible' });
16621643

1663-
if (isSearchBarVisible) {
1664-
await searchBar.focus();
1665-
await searchBar.press('Control+a');
1666-
await searchBar.pressSequentially(searchTerm);
1667-
}
1644+
await domainTree.getByTestId('searchbar').waitFor({ state: 'visible' });
16681645

1669-
return await domainOption.isVisible().catch(() => false);
1670-
},
1671-
{
1672-
timeout: 60000,
1673-
intervals: [1000, 2000, 5000],
1674-
message: `Timed out waiting for domain ${searchTerm} to appear in navbar selector`,
1675-
}
1676-
)
1677-
.toBe(true);
1646+
await domainTree.getByTestId('searchbar').click();
1647+
await page.keyboard.press('Control+a');
1648+
await domainTree.getByTestId('searchbar').pressSequentially(searchTerm);
16781649

1679-
await domainOption.click();
1650+
await page.getByTestId(`tag-${domain.fullyQualifiedName}`).click();
16801651
await waitForAllLoadersToDisappear(page);
16811652
};
16821653

0 commit comments

Comments
 (0)