Skip to content

Commit 494d0f7

Browse files
shrabantipaul-collateShrabanti Paul
andauthored
Fix restrore entity inherited fields specs (#27414)
* increase data contracts test timeout * fix failure in restroreEntityInheritedFields * fix restrore entity inheritance specs * remove unnecessary multiple domains check --------- Co-authored-by: Shrabanti Paul <shrabantipaul@Shrabantis-MacBook-Pro.local>
1 parent 6261dd5 commit 494d0f7

2 files changed

Lines changed: 64 additions & 16 deletions

File tree

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/RestoreEntityInheritedFields.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ entities.forEach((EntityClass) => {
105105

106106
await entity.visitEntityPage(page);
107107

108-
await assignDataProduct(page, domain.responseData, [
109-
dataProduct.responseData,
110-
]);
108+
await assignDataProduct(
109+
page,
110+
domain.responseData,
111+
[dataProduct.responseData],
112+
'Add',
113+
'KnowledgePanel.DataProducts',
114+
true
115+
);
111116

112117
// This will delete and restore and ensure both operation are successful
113118
await softDeleteEntity(

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

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,31 @@ export const assignDataProduct = async (
430430
fullyQualifiedName?: string;
431431
}[],
432432
action: 'Add' | 'Edit' = 'Add',
433-
parentId = 'KnowledgePanel.DataProducts'
433+
parentId = 'KnowledgePanel.DataProducts',
434+
// Set true when the domain is inherited from a parent entity. The search
435+
// index is updated asynchronously, so a page reload is needed on each poll
436+
// to fetch the current state directly from the entity API.
437+
pollForInheritance = false
434438
) => {
435-
const hasMultipleDomains = await page
436-
.getByTestId('domain-count-button')
437-
.isVisible();
438-
if (hasMultipleDomains) {
439-
await expect(page.getByTestId('domain-count-button')).toBeVisible();
439+
if (pollForInheritance) {
440+
await expect
441+
.poll(
442+
async () => {
443+
await page.reload();
444+
await waitForAllLoadersToDisappear(page);
445+
446+
return page
447+
.getByTestId('domain-link')
448+
.textContent()
449+
.catch(() => null);
450+
},
451+
{
452+
message: `Waiting for inherited domain "${domain.displayName}" to appear on the entity page`,
453+
timeout: 60_000,
454+
intervals: [2_000, 3_000, 5_000],
455+
}
456+
)
457+
.toContain(domain.displayName);
440458
} else {
441459
await expect(page.getByTestId('domain-link')).toContainText(
442460
domain.displayName
@@ -487,13 +505,38 @@ export const assignDataProduct = async (
487505
.click();
488506
await patchReq;
489507

490-
for (const dataProduct of dataProducts) {
491-
await expect(
492-
page
493-
.getByTestId(parentId)
494-
.getByTestId('data-products-list')
495-
.getByTestId(`data-product-${dataProduct.fullyQualifiedName}`)
496-
).toBeVisible();
508+
if (pollForInheritance) {
509+
for (const dataProduct of dataProducts) {
510+
await expect
511+
.poll(
512+
async () => {
513+
await page.reload();
514+
await waitForAllLoadersToDisappear(page);
515+
516+
return page
517+
.getByTestId(parentId)
518+
.getByTestId('data-products-list')
519+
.getByTestId(`data-product-${dataProduct.fullyQualifiedName}`)
520+
.isVisible()
521+
.catch(() => false);
522+
},
523+
{
524+
message: `Waiting for data product "${dataProduct.displayName}" to appear after save`,
525+
timeout: 60_000,
526+
intervals: [2_000, 3_000, 5_000],
527+
}
528+
)
529+
.toBe(true);
530+
}
531+
} else {
532+
for (const dataProduct of dataProducts) {
533+
await expect(
534+
page
535+
.getByTestId(parentId)
536+
.getByTestId('data-products-list')
537+
.getByTestId(`data-product-${dataProduct.fullyQualifiedName}`)
538+
).toBeVisible();
539+
}
497540
}
498541
};
499542

0 commit comments

Comments
 (0)