Skip to content

Commit dd73bd9

Browse files
siddhant1Siddhantclaude
authored
test(glossary): make selectActiveGlossary selector robust (#27566)
* test(glossary): make selectActiveGlossary selector robust Scope the menuitem lookup to [data-testid="glossary-left-panel"] and require an exact name match so the helper can no longer pick up an element from another dropdown (e.g. the Add-button glossary picker) or silently mis-click via .first() when many glossaries share the "PW % " prefix. The label argument is documented as the rendered label (displayName ?? name). Update createGlossaryTerms and the six Glossary.spec.ts callers that were passing glossary.data.name (which never matches the rendered displayName) to pass the displayName instead. This is the underlying cause of the flakiness in "Approve and reject glossary term from Glossary Listing". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(glossary): fill displayName in createGlossary so UI-created glossaries match strict sidebar lookup The previous commit made selectActiveGlossary match the sidebar menuitem by displayName with exact: true. That assumed every glossary in a test had its displayName rendered in the sidebar. UI-created glossaries (via the createGlossary helper) only filled the name field, so the server had no displayName and the sidebar rendered the raw name — the exact-match lookup then hung until the 180s test timeout. Fill the display-name field in createGlossary, and look up the menuitem in verifyGlossaryDetails by displayName as well. This aligns UI-created glossaries with API-created ones and unblocks the three tests that were failing on this PR: - Glossary & terms creation for reviewer as user - Glossary & terms creation for reviewer as team - Approve and reject glossary term from Glossary Listing Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Siddhant <siddhant@MacBook-Pro-621.local> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0deb78b commit dd73bd9

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ test.describe('Glossary tests', () => {
153153
await test.step('Approve Glossary Term from Glossary Listing for reviewer user', async () => {
154154
await redirectToHomePage(page1);
155155
await sidebarClick(page1, SidebarItem.GLOSSARY);
156-
await selectActiveGlossary(page1, glossary1.data.name);
156+
await selectActiveGlossary(page1, glossary1.data.displayName);
157157
await verifyTaskCreated(
158158
page1,
159159
glossary1.data.fullyQualifiedName,
@@ -179,7 +179,7 @@ test.describe('Glossary tests', () => {
179179
await approveGlossaryTermTask(page1, glossary1.data.terms[0].data);
180180
await redirectToHomePage(page1);
181181
await sidebarClick(page1, SidebarItem.GLOSSARY);
182-
await selectActiveGlossary(page1, glossary1.data.name);
182+
await selectActiveGlossary(page1, glossary1.data.displayName);
183183
await validateGlossaryTerm(
184184
page1,
185185
glossary1.data.terms[0].data,
@@ -222,7 +222,7 @@ test.describe('Glossary tests', () => {
222222
await test.step('Approve Glossary Term from Glossary Listing for reviewer team', async () => {
223223
await redirectToHomePage(page1);
224224
await sidebarClick(page1, SidebarItem.GLOSSARY);
225-
await selectActiveGlossary(page1, glossary2.data.name);
225+
await selectActiveGlossary(page1, glossary2.data.displayName);
226226

227227
await verifyTaskCreated(
228228
page1,
@@ -234,7 +234,7 @@ test.describe('Glossary tests', () => {
234234

235235
await redirectToHomePage(page1);
236236
await sidebarClick(page1, SidebarItem.GLOSSARY);
237-
await selectActiveGlossary(page1, glossary2.data.name);
237+
await selectActiveGlossary(page1, glossary2.data.displayName);
238238
await validateGlossaryTerm(
239239
page1,
240240
glossary2.data.terms[0].data,
@@ -441,7 +441,7 @@ test.describe('Glossary tests', () => {
441441
await test.step('Approve and Reject Glossary Term', async () => {
442442
await redirectToHomePage(page1);
443443
await sidebarClick(page1, SidebarItem.GLOSSARY);
444-
await selectActiveGlossary(page1, glossary1.data.name);
444+
await selectActiveGlossary(page1, glossary1.data.displayName);
445445
await verifyTaskCreated(
446446
page1,
447447
glossary1.data.fullyQualifiedName,
@@ -454,7 +454,7 @@ test.describe('Glossary tests', () => {
454454
);
455455
await redirectToHomePage(page1);
456456
await sidebarClick(page1, SidebarItem.GLOSSARY);
457-
await selectActiveGlossary(page1, glossary1.data.name);
457+
await selectActiveGlossary(page1, glossary1.data.displayName);
458458

459459
const taskResolve = page1.waitForResponse('/api/v1/feed/tasks/*/resolve');
460460
await page1

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ export const checkName = async (page: Page, name: string) => {
6363

6464
export const selectActiveGlossary = async (
6565
page: Page,
66-
glossaryName: string,
66+
glossaryLabel: string,
6767
bWaitForResponse = true
6868
) => {
69-
const menuItem = page.getByRole('menuitem', { name: glossaryName }).first();
69+
const sidebar = page.getByTestId('glossary-left-panel');
70+
await sidebar.locator('[role="menuitem"]').first().waitFor();
71+
72+
const menuItem = sidebar.getByRole('menuitem', {
73+
name: glossaryLabel,
74+
exact: true,
75+
});
76+
await menuItem.waitFor({ state: 'visible' });
77+
7078
const isSelected = await menuItem.evaluate((element) => {
7179
return element.classList.contains('ant-menu-item-selected');
7280
});
@@ -259,6 +267,8 @@ export const createGlossary = async (
259267

260268
await page.fill('[data-testid="name"]', glossaryData.name);
261269

270+
await page.fill('[data-testid="display-name"]', glossaryData.displayName);
271+
262272
await page.locator(descriptionBox).fill(glossaryData.description);
263273

264274
await expect(
@@ -322,7 +332,7 @@ export const verifyGlossaryDetails = async (
322332
glossaryDetails: GlossaryData
323333
) => {
324334
await page
325-
.getByRole('menuitem', { name: glossaryDetails.name })
335+
.getByRole('menuitem', { name: glossaryDetails.displayName, exact: true })
326336
.locator('span')
327337
.click();
328338

@@ -761,7 +771,7 @@ export const createGlossaryTerms = async (
761771
page: Page,
762772
glossary: GlossaryData
763773
) => {
764-
await selectActiveGlossary(page, glossary.name);
774+
await selectActiveGlossary(page, glossary.displayName ?? glossary.name);
765775

766776
const termStatus = glossary.reviewers.length > 0 ? 'Draft' : 'Approved';
767777

0 commit comments

Comments
 (0)