Skip to content

Commit aaeab9e

Browse files
authored
Fix PR playwright failures (#27701)
* Fix PR playwright failures * fix lint check
1 parent 88c4450 commit aaeab9e

5 files changed

Lines changed: 70 additions & 50 deletions

File tree

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

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,12 @@ import { selectActiveGlossaryTerm } from '../../utils/glossary';
8181
import { sidebarClick } from '../../utils/sidebar';
8282
import { selectTagInTagSuggestion } from '../../utils/tag';
8383
import { performUserLogin, visitUserProfilePage } from '../../utils/user';
84-
const user = new UserClass();
85-
86-
const domain = new Domain();
87-
88-
const classification = new ClassificationClass({
89-
provider: 'system',
90-
mutuallyExclusive: true,
91-
});
92-
const tag = new TagClass({
93-
classification: classification.data.name,
94-
});
95-
96-
const glossary = new Glossary();
97-
const glossaryTerm = new GlossaryTerm(glossary);
84+
let user: UserClass;
85+
let domain: Domain;
86+
let classification: ClassificationClass;
87+
let tag: TagClass;
88+
let glossary: Glossary;
89+
let glossaryTerm: GlossaryTerm;
9890

9991
const test = base.extend<{
10092
page: Page;
@@ -119,6 +111,16 @@ test.describe('Domains', () => {
119111
test.beforeAll('Setup pre-requests', async ({ browser }) => {
120112
test.slow(true);
121113

114+
user = new UserClass();
115+
domain = new Domain();
116+
classification = new ClassificationClass({
117+
provider: 'system',
118+
mutuallyExclusive: true,
119+
});
120+
tag = new TagClass({ classification: classification.data.name });
121+
glossary = new Glossary();
122+
glossaryTerm = new GlossaryTerm(glossary);
123+
122124
const { apiContext, afterAction } = await performAdminLogin(browser);
123125
await user.create(apiContext);
124126
await classification.create(apiContext);
@@ -2669,12 +2671,16 @@ test.describe('Domain Rename Comprehensive Tests', () => {
26692671
test.describe('Domains Rbac', () => {
26702672
test.slow(true);
26712673

2672-
const domain1 = new Domain();
2673-
const domain2 = new Domain();
2674-
const domain3 = new Domain();
2675-
const user1 = new UserClass();
2674+
let domain1: Domain;
2675+
let domain2: Domain;
2676+
let domain3: Domain;
2677+
let user1: UserClass;
26762678

26772679
test.beforeAll('Setup pre-requests', async ({ browser }) => {
2680+
domain1 = new Domain();
2681+
domain2 = new Domain();
2682+
domain3 = new Domain();
2683+
user1 = new UserClass();
26782684
test.slow();
26792685

26802686
const { apiContext, afterAction, page } = await performAdminLogin(browser);
@@ -2815,15 +2821,10 @@ test.describe('Domains Rbac', () => {
28152821
test.describe('Data Consumer Domain Ownership', () => {
28162822
test.slow(true);
28172823

2818-
const classification = new ClassificationClass({
2819-
provider: 'system',
2820-
mutuallyExclusive: true,
2821-
});
2822-
const tag = new TagClass({
2823-
classification: classification.data.name,
2824-
});
2825-
const glossary = new Glossary();
2826-
const glossaryTerm = new GlossaryTerm(glossary);
2824+
let classification: ClassificationClass;
2825+
let tag: TagClass;
2826+
let glossary: Glossary;
2827+
let glossaryTerm: GlossaryTerm;
28272828

28282829
let testResources: {
28292830
dataConsumerUser: UserClass;
@@ -2833,6 +2834,14 @@ test.describe('Data Consumer Domain Ownership', () => {
28332834
};
28342835

28352836
test.beforeAll('Setup pre-requests', async ({ browser }) => {
2837+
classification = new ClassificationClass({
2838+
provider: 'system',
2839+
mutuallyExclusive: true,
2840+
});
2841+
tag = new TagClass({ classification: classification.data.name });
2842+
glossary = new Glossary();
2843+
glossaryTerm = new GlossaryTerm(glossary);
2844+
28362845
const { apiContext, afterAction } = await performAdminLogin(browser);
28372846
await classification.create(apiContext);
28382847
await tag.create(apiContext);

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ test.describe('Glossary tests', () => {
532532
const glossaryRequest = page.waitForResponse(
533533
`/api/v1/search/query?q=*&index=glossaryTerm&from=0&size=25&deleted=false&track_total_hits=true&getHierarchy=true`
534534
);
535-
await page.type(
535+
await page.fill(
536536
'[data-testid="tag-selector"] #tagsForm_tags',
537-
glossaryTerm1.data.name
537+
glossary1.data.name
538538
);
539539
await glossaryRequest;
540540

@@ -551,9 +551,9 @@ test.describe('Glossary tests', () => {
551551
const glossaryRequest2 = page.waitForResponse(
552552
`/api/v1/search/query?q=*&index=glossaryTerm&from=0&size=25&deleted=false&track_total_hits=true&getHierarchy=true`
553553
);
554-
await page.type(
554+
await page.fill(
555555
'[data-testid="tag-selector"] #tagsForm_tags',
556-
glossaryTerm2.data.name
556+
glossary1.data.name
557557
);
558558
await glossaryRequest2;
559559

@@ -578,7 +578,7 @@ test.describe('Glossary tests', () => {
578578

579579
// Add non mutually exclusive tags
580580
await page.click(
581-
'[data-testid="KnowledgePanel.GlossaryTerms"] [data-testid="glossary-container"] [data-testid="add-tag"]'
581+
'[data-testid="KnowledgePanel.GlossaryTerms"] [data-testid="glossary-container"] [data-testid="edit-button"]'
582582
);
583583

584584
// Select 1st term
@@ -587,9 +587,9 @@ test.describe('Glossary tests', () => {
587587
const glossaryRequest3 = page.waitForResponse(
588588
`/api/v1/search/query?q=*&index=glossaryTerm&from=0&size=25&deleted=false&track_total_hits=true&getHierarchy=true`
589589
);
590-
await page.type(
590+
await page.fill(
591591
'[data-testid="tag-selector"] #tagsForm_tags',
592-
glossaryTerm3.data.name
592+
glossary2.data.name
593593
);
594594
await glossaryRequest3;
595595

@@ -606,9 +606,9 @@ test.describe('Glossary tests', () => {
606606
const glossaryRequest4 = page.waitForResponse(
607607
`/api/v1/search/query?q=*&index=glossaryTerm&from=0&size=25&deleted=false&track_total_hits=true&getHierarchy=true`
608608
);
609-
await page.type(
609+
await page.fill(
610610
'[data-testid="tag-selector"] #tagsForm_tags',
611-
glossaryTerm4.data.name
611+
glossary2.data.name
612612
);
613613
await glossaryRequest4;
614614

@@ -648,7 +648,7 @@ test.describe('Glossary tests', () => {
648648
'[data-testid="KnowledgePanel.GlossaryTerms"] [data-testid="glossary-container"] [data-testid="glossary-icon"]'
649649
);
650650

651-
expect(await icons.count()).toBe(2);
651+
expect(await icons.count()).toBe(3);
652652

653653
// Add Glossary to Dashboard Charts
654654
await page.click(
@@ -660,7 +660,7 @@ test.describe('Glossary tests', () => {
660660
const glossaryRequest5 = page.waitForResponse(
661661
`/api/v1/search/query?q=*&index=glossaryTerm&from=0&size=25&deleted=false&track_total_hits=true&getHierarchy=true`
662662
);
663-
await page.type(
663+
await page.fill(
664664
'[data-testid="tag-selector"] #tagsForm_tags',
665665
glossaryTerm3.data.name
666666
);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { TeamClass } from '../../support/team/TeamClass';
3333
import { UserClass } from '../../support/user/UserClass';
3434
import { createAdminApiContext, performAdminLogin } from '../../utils/admin';
3535
import {
36+
getApiContext,
3637
redirectToHomePage,
3738
toastNotification,
3839
uuid,

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

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,34 +1644,43 @@ export const selectDomainFromNavbar = async (
16441644
page: Page,
16451645
domain: Domain['responseData']
16461646
) => {
1647-
await page.getByTestId('domain-dropdown').click();
1647+
const domainDropdown = page.getByTestId('domain-dropdown');
16481648
const domainTree = page.getByTestId('domain-selectable-tree');
1649-
await domainTree.waitFor({
1650-
state: 'visible',
1651-
});
1652-
const searchBar = domainTree.getByTestId('searchbar');
16531649
const searchTerm = domain.displayName ?? domain.name;
16541650
const domainOption = page.getByTestId(`tag-${domain.fullyQualifiedName}`);
16551651

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+
16561661
await expect
16571662
.poll(
16581663
async () => {
16591664
if (!(await domainTree.isVisible().catch(() => false))) {
1660-
await page.getByTestId('domain-dropdown').click();
1661-
await domainTree.waitFor({ state: 'visible' });
1665+
await openDropdown();
16621666
}
16631667

1664-
await searchBar.fill('');
1665-
await searchBar.fill(searchTerm);
1668+
const isSearchBarVisible = await searchBar
1669+
.isVisible()
1670+
.catch(() => false);
1671+
1672+
if (isSearchBarVisible) {
1673+
await searchBar.focus();
1674+
await searchBar.press('Control+a');
1675+
await searchBar.pressSequentially(searchTerm);
1676+
}
16661677

16671678
return await domainOption.isVisible().catch(() => false);
16681679
},
16691680
{
16701681
timeout: 60000,
16711682
intervals: [1000, 2000, 5000],
1672-
message: `Timed out waiting for domain ${
1673-
domain.displayName ?? domain.name
1674-
} to appear in navbar selector`,
1683+
message: `Timed out waiting for domain ${searchTerm} to appear in navbar selector`,
16751684
}
16761685
)
16771686
.toBe(true);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const mockEntitySearchConfig = {
2929
assetType: 'table',
3030
searchFields: [
3131
{ field: 'displayName.keyword', boost: 20, matchType: 'exact' },
32+
{ field: 'name.keyword', boost: 20, matchType: 'exact' },
3233
{ field: 'name', boost: 10, matchType: 'phrase' },
3334
{ field: 'name.ngram', boost: 1, matchType: 'fuzzy' },
3435
{ field: 'name.compound', boost: 8, matchType: 'standard' },

0 commit comments

Comments
 (0)