Skip to content

Commit 4501526

Browse files
Fix flakiness in custom property playwrights (#25733)
1 parent 6f57765 commit 4501526

File tree

5 files changed

+37
-33
lines changed

5 files changed

+37
-33
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { CUSTOM_PROPERTIES_ENTITIES } from '../../constant/customProperty';
1414
import { TableClass } from '../../support/entity/TableClass';
1515
import { test } from '../../support/fixtures/userPages';
16-
import { createNewPage, redirectToHomePage, uuid } from '../../utils/common';
16+
import { createNewPage, redirectToHomePage } from '../../utils/common';
1717
import {
1818
addCustomPropertiesForEntity,
1919
deleteCreatedProperty,
@@ -57,7 +57,9 @@ test.describe('Custom properties without custom property config', () => {
5757
propertiesList.forEach((property) => {
5858
test.describe(`Add update and delete ${property} custom properties`, () => {
5959
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
60-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
60+
// Using Date.now() to generate property names in a way that new property will always be
61+
// added after existing properties to avoid conflicts due to parallel test executions
62+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
6163

6264
test(`Add ${property} custom property for ${entity.name}`, async ({
6365
page,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import { CUSTOM_PROPERTIES_ENTITIES } from '../../constant/customProperty';
1414
import { TableClass } from '../../support/entity/TableClass';
1515
import { test } from '../../support/fixtures/userPages';
16-
import { createNewPage, redirectToHomePage, uuid } from '../../utils/common';
16+
import { createNewPage, redirectToHomePage } from '../../utils/common';
1717
import {
1818
addCustomPropertiesForEntity,
1919
deleteCreatedProperty,
@@ -43,7 +43,7 @@ test.describe('Custom properties with custom property config', () => {
4343

4444
test.describe('Add update and delete Enum custom properties', () => {
4545
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
46-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
46+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
4747

4848
test(`Add Enum custom property for ${entity.name}`, async ({ page }) => {
4949
await settingClick(
@@ -100,7 +100,7 @@ test.describe('Custom properties with custom property config', () => {
100100

101101
test.describe('Add update and delete Table custom properties', () => {
102102
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
103-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
103+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
104104

105105
test(`Add Table custom property for ${entity.name}`, async ({ page }) => {
106106
await settingClick(
@@ -161,7 +161,7 @@ test.describe('Custom properties with custom property config', () => {
161161
'Add update and delete Entity Reference custom properties',
162162
() => {
163163
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
164-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
164+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
165165

166166
test(`Add Entity Reference custom property for ${entity.name}`, async ({
167167
page,
@@ -223,7 +223,7 @@ test.describe('Custom properties with custom property config', () => {
223223
'Add update and delete Entity Reference List custom properties',
224224
() => {
225225
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
226-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
226+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
227227

228228
test(`Add Entity Reference list custom property for ${entity.name}`, async ({
229229
page,
@@ -287,7 +287,7 @@ test.describe('Custom properties with custom property config', () => {
287287

288288
test.describe('Add update and delete Date custom properties', () => {
289289
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
290-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
290+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
291291

292292
test(`Add Date custom property for ${entity.name}`, async ({ page }) => {
293293
await settingClick(
@@ -338,7 +338,7 @@ test.describe('Custom properties with custom property config', () => {
338338

339339
test.describe('Add update and delete Time custom properties', () => {
340340
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
341-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
341+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
342342

343343
test(`Add Time custom property for ${entity.name}`, async ({ page }) => {
344344
await settingClick(
@@ -395,7 +395,7 @@ test.describe('Custom properties with custom property config', () => {
395395

396396
test.describe('Add update and delete DateTime custom properties', () => {
397397
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
398-
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
398+
const propertyName = `pwcp${Date.now()}test${entity.name}`;
399399

400400
test(`Add DateTime custom property for ${entity.name}`, async ({
401401
page,

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,9 +1240,22 @@ export const verifyTableColumnCustomPropertyPersistence = async ({
12401240
);
12411241

12421242
// 5. Reload Page
1243+
const getColumnDetails = page.waitForResponse(
1244+
'/api/v1/tables/name/*/columns?*fields=*extension*'
1245+
);
1246+
const getTableColumnTypes = page.waitForResponse(
1247+
'/api/v1/metadata/types/name/tableColumn*'
1248+
);
12431249
await page.reload();
1244-
await waitForAllLoadersToDisappear(page);
1245-
await expect(sidePanel).toBeVisible();
1250+
await getTableColumnTypes;
1251+
await getColumnDetails;
1252+
1253+
await page.waitForSelector(
1254+
'.column-detail-panel-container [data-testid="custom-properties-tab"]',
1255+
{
1256+
state: 'visible',
1257+
}
1258+
);
12461259
await customPropertiesTab.click();
12471260
await expect(searchbar).toBeVisible();
12481261
await searchbar.fill(propertyName);

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export interface CustomPropertyDetails {
3131
id: string;
3232
};
3333
customPropertyConfig?: {
34-
config: string | string[] | { values: string[]; multiSelect: boolean };
34+
config:
35+
| string
36+
| string[]
37+
| { values: string[]; multiSelect: boolean }
38+
| { columns: string[] };
3539
};
3640
}
3741

@@ -289,34 +293,22 @@ export const setupCustomPropertyAdvancedSearchTest = async (
289293

290294
// Map and prepare the data required for creating custom properties of different types
291295
const cpCreationData = getCustomPropertyCreationData(testData.types);
292-
let metadataTypesData;
296+
testData.createdCPData = Object.values(cpCreationData);
293297

294298
// The API calls need to be sequential as the server replaces some types with others
295299
// due to simultaneous requests causing conflicts.
296300
for (const type of testData.types) {
297301
const typeData = cpCreationData[type.name as keyof typeof cpCreationData];
298302

299303
if (!isUndefined(typeData)) {
300-
metadataTypesData = await apiContext.put(
304+
await apiContext.put(
301305
`/api/v1/metadata/types/${testData.cpMetadataType.id}`,
302306
{
303307
data: typeData,
304308
}
305309
);
306310
}
307311
}
308-
const metadataTypesJson = await metadataTypesData?.json();
309-
310-
// Get the created custom properties names list
311-
const createdCustomPropertyNamesList = new Set(
312-
Object.values(cpCreationData).map((cp) => cp.name)
313-
);
314-
// Filter out the created custom properties from the metadata type response
315-
// to only take the properties data created in this test setup
316-
testData.createdCPData =
317-
metadataTypesJson?.customProperties.filter((cp: CustomPropertyDetails) =>
318-
createdCustomPropertyNamesList.has(cp.name)
319-
) || [];
320312

321313
// Get the custom property to values mapping to add to the dashboard entity
322314
const cpValuesData = getCustomPropertyValues(

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { expect, Page } from '@playwright/test';
1414
import { redirectToExplorePage } from './common';
1515

1616
import { ENDPOINT_TO_FILTER_MAP } from '../constant/explore';
17+
import { waitForAllLoadersToDisappear } from './entity';
1718

1819
export const openEntitySummaryPanel = async (
1920
page: Page,
@@ -52,9 +53,7 @@ export const openEntitySummaryPanel = async (
5253
expect(searchResponse.status()).toBe(200);
5354

5455
await page.getByTestId('searchBox').press('Enter');
55-
await page.waitForSelector('[data-testid="loader"]', {
56-
state: 'detached',
57-
});
56+
await waitForAllLoadersToDisappear(page);
5857

5958
const entityCard = page
6059
.locator('[data-testid="table-data-card"]')
@@ -76,9 +75,7 @@ export async function navigateToExploreAndSelectTable(
7675
) {
7776
await redirectToExplorePage(page);
7877

79-
await page.waitForSelector('[data-testid="loader"]', {
80-
state: 'detached',
81-
});
78+
await waitForAllLoadersToDisappear(page);
8279

8380
const permissionsResponsePromise = page.waitForResponse((response) =>
8481
response.url().includes('/permissions')

0 commit comments

Comments
 (0)