Skip to content

Commit 48a7de3

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 e23dff8 commit 48a7de3

6 files changed

Lines changed: 20 additions & 106 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
@@ -64,7 +64,7 @@ import { DataProduct } from '../domain/DataProduct';
6464
import { Domain } from '../domain/Domain';
6565
import { GlossaryTerm } from '../glossary/GlossaryTerm';
6666
import { TagClass } from '../tag/TagClass';
67-
import { EntityTypeEndpoint, ENTITY_PATH } from './Entity.interface';
67+
import { EntityTypeEndpoint } from './Entity.interface';
6868

6969
export class EntityClass {
7070
type = '';
@@ -114,30 +114,6 @@ export class EntityClass {
114114
}
115115
}
116116

117-
async cleanupCustomProperty(apiContext: APIRequestContext) {
118-
// Delete custom property only for supported entities
119-
if (CustomPropertySupportedEntityList.includes(this.endpoint)) {
120-
await this.cleanupUser?.(apiContext);
121-
const entitySchemaResponse = await apiContext.get(
122-
`/api/v1/metadata/types/name/${
123-
ENTITY_PATH[this.endpoint as keyof typeof ENTITY_PATH]
124-
}`
125-
);
126-
const entitySchema = await entitySchemaResponse.json();
127-
await apiContext.patch(`/api/v1/metadata/types/${entitySchema.id}`, {
128-
data: [
129-
{
130-
op: 'remove',
131-
path: '/customProperties',
132-
},
133-
],
134-
headers: {
135-
'Content-Type': 'application/json-patch+json',
136-
},
137-
});
138-
}
139-
}
140-
141117
async domain(
142118
page: Page,
143119
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
@@ -208,27 +208,6 @@ export class EntityDataClass {
208208
}
209209
}
210210

211-
static async cleanupCustomPropertyData(
212-
apiContext: APIRequestContext,
213-
entityType: string
214-
) {
215-
const entitySchemaResponse = await apiContext.get(
216-
`/api/v1/metadata/types/name/${entityType}`
217-
);
218-
const entitySchema = await entitySchemaResponse.json();
219-
await apiContext.patch(`/api/v1/metadata/types/${entitySchema.id}`, {
220-
data: [
221-
{
222-
op: 'remove',
223-
path: '/customProperties',
224-
},
225-
],
226-
headers: {
227-
'Content-Type': 'application/json-patch+json',
228-
},
229-
});
230-
}
231-
232211
static async preRequisitesForTests(apiContext: APIRequestContext) {
233212
// Add pre-requisites for tests
234213
const promises = [
@@ -375,12 +354,6 @@ export class EntityDataClass {
375354
this.worksheet2.delete(apiContext),
376355
];
377356

378-
for (const entityType of Object.values(CUSTOM_PROPERTIES_ENTITIES).map(
379-
(entity) => entity.name
380-
)) {
381-
await this.cleanupCustomPropertyData(apiContext, entityType);
382-
}
383-
384357
return await Promise.allSettled(promises);
385358
}
386359

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: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,45 +1647,19 @@ export const selectDomainFromNavbar = async (
16471647
const domainDropdown = page.getByTestId('domain-dropdown');
16481648
const domainTree = page.getByTestId('domain-selectable-tree');
16491649
const searchTerm = domain.displayName ?? domain.name;
1650-
const domainOption = page.getByTestId(`tag-${domain.fullyQualifiedName}`);
16511650

1652-
const openDropdown = async () => {
1653-
await domainDropdown.click();
1654-
await domainTree.waitFor({ state: 'visible' });
1655-
};
1656-
1657-
await openDropdown();
1658-
1659-
const searchBar = domainTree.locator('input[placeholder]').first();
1660-
1661-
await expect
1662-
.poll(
1663-
async () => {
1664-
if (!(await domainTree.isVisible().catch(() => false))) {
1665-
await openDropdown();
1666-
}
1667-
1668-
const isSearchBarVisible = await searchBar
1669-
.isVisible()
1670-
.catch(() => false);
1651+
await domainDropdown.click();
1652+
await page
1653+
.getByTestId('domain-selectable-tree')
1654+
.waitFor({ state: 'visible' });
16711655

1672-
if (isSearchBarVisible) {
1673-
await searchBar.focus();
1674-
await searchBar.press('Control+a');
1675-
await searchBar.pressSequentially(searchTerm);
1676-
}
1656+
await domainTree.getByTestId('searchbar').waitFor({ state: 'visible' });
16771657

1678-
return await domainOption.isVisible().catch(() => false);
1679-
},
1680-
{
1681-
timeout: 60000,
1682-
intervals: [1000, 2000, 5000],
1683-
message: `Timed out waiting for domain ${searchTerm} to appear in navbar selector`,
1684-
}
1685-
)
1686-
.toBe(true);
1658+
await domainTree.getByTestId('searchbar').click();
1659+
await page.keyboard.press('Control+a');
1660+
await domainTree.getByTestId('searchbar').pressSequentially(searchTerm);
16871661

1688-
await domainOption.click();
1662+
await page.getByTestId(`tag-${domain.fullyQualifiedName}`).click();
16891663
await waitForAllLoadersToDisappear(page);
16901664
};
16911665

0 commit comments

Comments
 (0)