Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/playwright/impact-map.generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -7452,14 +7452,6 @@
"playwright/e2e/Features/Glossary/GlossaryTermRelatedTerms.spec.ts"
]
},
{
"sources": [
"openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/TermsRowEditor.component.tsx"
],
"specs": [
"playwright/e2e/Features/Glossary/GlossaryTermRelatedTerms.spec.ts"
]
},
{
"sources": [
"openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTerms/tabs/WorkFlowTab/WorkflowHistory.component.tsx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,18 +735,23 @@ public Pair<String, TagLabel> map(ResultSet r, StatementContext ctx) throws SQLE
.withAppliedBy(r.getString("appliedBy"))
.withMetadata(JsonUtils.readValue(r.getString("metadata"), TagLabelMetadata.class));
TagLabel.TagSource source = TagLabel.TagSource.values()[r.getInt("source")];
// json is null when the tag/term was deleted (orphan tag_usage row); keep the label as-is.
if (source == TagLabel.TagSource.CLASSIFICATION) {
Tag tag = JsonUtils.readValue(r.getString("json"), Tag.class);
label.setName(tag.getName());
label.setDisplayName(tag.getDisplayName());
label.setDescription(tag.getDescription());
label.setStyle(tag.getStyle());
if (tag != null) {
label.setName(tag.getName());
label.setDisplayName(tag.getDisplayName());
label.setDescription(tag.getDescription());
label.setStyle(tag.getStyle());
}
} else if (source == TagLabel.TagSource.GLOSSARY) {
GlossaryTerm glossaryTerm = JsonUtils.readValue(r.getString("json"), GlossaryTerm.class);
label.setName(glossaryTerm.getName());
label.setDisplayName(glossaryTerm.getDisplayName());
label.setDescription(glossaryTerm.getDescription());
label.setStyle(glossaryTerm.getStyle());
if (glossaryTerm != null) {
label.setName(glossaryTerm.getName());
label.setDisplayName(glossaryTerm.getDisplayName());
label.setDescription(glossaryTerm.getDescription());
label.setStyle(glossaryTerm.getStyle());
}
} else {
throw new IllegalArgumentException("Invalid source type " + source);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.openmetadata.service.jdbi3;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Test;
import org.openmetadata.schema.type.TagLabel;
import org.openmetadata.service.jdbi3.ClassificationTagDAOs.TagUsageDAO.TagLabelRowMapperWithTargetFqnHash;

class TagLabelRowMapperWithTargetFqnHashTest {

private static ResultSet orphanRow(TagLabel.TagSource source) throws SQLException {
ResultSet rs = mock(ResultSet.class);
when(rs.getInt("source")).thenReturn(source.ordinal());
when(rs.getInt("labelType")).thenReturn(TagLabel.LabelType.MANUAL.ordinal());
when(rs.getInt("state")).thenReturn(TagLabel.State.CONFIRMED.ordinal());
when(rs.getString("tagFQN")).thenReturn("g.deletedTerm");
when(rs.getString("targetFQNHash")).thenReturn("hash");
when(rs.getString("json")).thenReturn(null);
return rs;
}

@Test
void orphanGlossaryUsageMapsToUnenrichedLabel() throws SQLException {
Pair<String, TagLabel> row =
new TagLabelRowMapperWithTargetFqnHash().map(orphanRow(TagLabel.TagSource.GLOSSARY), null);

assertEquals("hash", row.getLeft());
assertEquals("g.deletedTerm", row.getRight().getTagFQN());
assertNull(row.getRight().getName());
}

@Test
void orphanClassificationUsageMapsToUnenrichedLabel() throws SQLException {
Pair<String, TagLabel> row =
new TagLabelRowMapperWithTargetFqnHash()
.map(orphanRow(TagLabel.TagSource.CLASSIFICATION), null);

assertEquals("g.deletedTerm", row.getRight().getTagFQN());
assertNull(row.getRight().getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@
"count": 3
}
},
"playwright/e2e/Features/Glossary/GlossaryTermRelatedTerms.spec.ts": {
"om-playwright/no-positional-locator": {
"count": 5
}
},
"playwright/e2e/Features/Glossary/GlossaryWorkflow.spec.ts": {
"om-playwright/no-positional-locator": {
"count": 1
Expand Down Expand Up @@ -714,7 +709,7 @@
},
"playwright/utils/glossary.ts": {
"om-playwright/no-positional-locator": {
"count": 11
"count": 8
},
"playwright/no-wait-for-selector": {
"count": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,11 @@ test.describe('Bulk Edit Entity', { tag: '@quarantine' }, () => {
}
});

await glossary.delete(apiContext);
await afterAction();
// Fresh context: the setup one idled past the server keep-alive and its DELETE hangs up.
const cleanup = await getApiContext(page);
await glossary.delete(cleanup.apiContext);
await cleanup.afterAction();
});

test('Glossary Term (Nested)', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import { GlossaryTerm } from '../../../support/glossary/GlossaryTerm';
import { getApiContext, redirectToHomePage } from '../../../utils/common';
import {
addRelatedTermsByRelationType,
addRelationRow,
getOnlyRelationRow,
getRelationRows,
selectActiveGlossary,
selectActiveGlossaryTerm,
selectRelationType,
} from '../../../utils/glossary';
import { pickGlossaryTermInField } from '../../../utils/glossaryPicker';
import { sidebarClick } from '../../../utils/sidebar';
Expand Down Expand Up @@ -52,7 +56,7 @@ test.describe('Glossary Term — Related Terms', () => {
await selectActiveGlossaryTerm(page, termA.data.displayName);
await page.getByTestId('related-term-add-button').click();

const firstRow = page.locator('[data-testid^="relation-row-"]').first();
const firstRow = await getOnlyRelationRow(page);

const termBName =
termB.responseData?.displayName ?? termB.data.displayName;
Expand All @@ -66,8 +70,7 @@ test.describe('Glossary Term — Related Terms', () => {
}
);

await page.getByTestId('add-row-button').click();
const secondRow = page.locator('[data-testid^="relation-row-"]').last();
const secondRow = await addRelationRow(page);

const termCName =
termC.responseData?.displayName ?? termC.data.displayName;
Expand Down Expand Up @@ -130,14 +133,11 @@ test.describe('Glossary Term — Related Terms', () => {
.getByTestId('edit-button')
.click();

const row = page.locator('[data-testid^="relation-row-"]').first();
await row.getByRole('button').first().click();
const seeAlsoOption = page.getByRole('option', {
exact: true,
name: 'See Also',
});
await expect(seeAlsoOption).toBeVisible();
await seeAlsoOption.click();
await selectRelationType(
page,
await getOnlyRelationRow(page),
'See Also'
);

const saveRes = page.waitForResponse('/api/v1/glossaryTerms/*');
await page.getByTestId('save-related-terms').click();
Expand Down Expand Up @@ -200,7 +200,15 @@ test.describe('Glossary Term — Related Terms', () => {
.getByTestId('edit-button')
.click();

await page.locator('[data-testid^="remove-row-"]').first().click();
// Match on the trigger: each row's hidden native <select> lists every type.
await getRelationRows(page)
.filter({
has: page.locator('button[aria-haspopup="listbox"]', {
hasText: 'Related To',
}),
})
.locator('[data-testid^="remove-row-"]')
.click();

const saveRes = page.waitForResponse('/api/v1/glossaryTerms/*');
await page.getByTestId('save-related-terms').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1306,8 +1306,14 @@
const glossary1 = new Glossary();
try {
await glossary1.create(apiContext);
await page.goto(GLOSSARY_ROUTE, { waitUntil: 'commit' });
await selectActiveGlossary(page, glossary1.data.displayName);
// Open by FQN so the /glossary auto-select redirect cannot replace the request-tags navigation.
await page.goto(
`/glossary/${encodeURIComponent(
glossary1.responseData.fullyQualifiedName
)}`,
{ waitUntil: 'domcontentloaded' }
);
await waitForAllLoadersToDisappear(page);

const value: TaskDetails = {
term: glossary1.data.name,
Expand Down Expand Up @@ -1380,7 +1386,7 @@
browser,
}) => {
// Create page and set up mocked WebSocket BEFORE navigation
const page = await browser.newPage();

Check warning on line 1389 in openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts

View workflow job for this annotation

GitHub Actions / checkstyle

Prefer the `page` fixture (test.use({ storageState })) over browser.newPage() + manual login for single-user admin tests. For multi-user tests that need a second non-admin page, this warning is expected — no action needed
await setupMockedWebSocket(page);

// Login on this page (WebSocket is fully mocked, no real server connection)
Expand Down Expand Up @@ -1474,7 +1480,7 @@
test.slow(true);

// Create page and set up mocked WebSocket BEFORE navigation
const page = await browser.newPage();

Check warning on line 1483 in openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Glossary.spec.ts

View workflow job for this annotation

GitHub Actions / checkstyle

Prefer the `page` fixture (test.use({ storageState })) over browser.newPage() + manual login for single-user admin tests. For multi-user tests that need a second non-admin page, this warning is expected — no action needed
await setupMockedWebSocket(page);

// Login on this page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
fetchCompletedCsvAsyncJobResult,
getApiContext,
redirectToHomePage,
toastNotification,
uuid,
} from '../../utils/common';
import {
Expand All @@ -45,6 +44,7 @@ import { selectActiveGlossary } from '../../utils/glossary';
import {
createGlossaryTermRowDetails,
fillGlossaryRowDetails,
saveBulkImport,
startCsvPreviewAndWaitForGrid,
validateImportStatus,
} from '../../utils/importUtils';
Expand Down Expand Up @@ -254,13 +254,9 @@ test.describe('Glossary Bulk Import Export', { tag: '@import-export' }, () => {

await expect(page.locator('.rdg-cell-details')).toHaveText(rowStatus);

await page.getByRole('button', { name: 'Update' }).click();
await page
.locator('.inovua-react-toolkit-load-mask__background-layer')
.waitFor({ state: 'detached' });

await toastNotification(
await saveBulkImport(
page,
'glossaries',
`Glossary ${glossary1.responseData.fullyQualifiedName} details updated successfully`
);
});
Expand Down Expand Up @@ -370,13 +366,9 @@ ${circularRefGlossary.data.name}.parent,child,child,<p>child</p>,,,,,,user:admin
failed: '0',
});

await page.getByRole('button', { name: 'Update' }).click();
await page
.locator('.inovua-react-toolkit-load-mask__background-layer')
.waitFor({ state: 'detached' });

await toastNotification(
await saveBulkImport(
page,
'glossaries',
`Glossary ${circularRefGlossary.responseData.fullyQualifiedName} details updated successfully`
);
});
Expand Down Expand Up @@ -784,10 +776,9 @@ ${partialGlossary.data.name}.selfRef,selfRef,selfRef,<p>Self-referential term</p
failed: '0',
});

await page.getByRole('button', { name: 'Update' }).click();
await loader.waitFor({ state: 'detached' });
await toastNotification(
await saveBulkImport(
page,
'glossaries',
`Glossary ${relGlossary.responseData.fullyQualifiedName} details updated successfully`
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test('the suppressions baseline matches its recorded state exactly', () => {
// customize-navigation switches to their tree rows removes four more, and
// the Data Marketplace announcements carousel spec dropped its `.first()`
// item lookup.
'om-playwright/no-positional-locator': 552,
'om-playwright/no-positional-locator': 544,
'om-playwright/require-assertion-per-test': 1,
'playwright/no-skipped-test': 1,
'playwright/no-wait-for-selector': 14,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
getApiContext,
INVALID_NAMES,
redirectToHomePage,
selectOptionWithRetry,
toastNotification,
uuid,
} from './common';
Expand Down Expand Up @@ -770,7 +771,15 @@ export const addAssetToGlossaryTerm = async (
).toContainText(visibleName);
}

// Wait for the add so callers' teardown cannot delete the term mid-request.
const addAssetsResponse = page.waitForResponse(
(response) =>
response.url().includes('/assets/add') &&
response.request().method() === 'PUT'
);
await page.click('[data-testid="save-btn"]');

expect((await addAssetsResponse).status()).toBe(200);
};

const testFilterWithSpecificOption = async (
Expand Down Expand Up @@ -1187,6 +1196,52 @@ export const addRelatedTerms = async (
}
};

export const getRelationRows = (page: Page) =>
page.locator('[data-testid^="relation-row-"]');

export const getOnlyRelationRow = async (page: Page) => {
const rows = getRelationRows(page);
await expect(rows).toHaveCount(1);

return rows;
};

// Row ids are Date.now() values, so the added row is the one with a new id.
export const addRelationRow = async (page: Page) => {
const rows = getRelationRows(page);
const readIds = () =>
rows.evaluateAll((nodes) =>
nodes.map((node) => node.getAttribute('data-testid') ?? '')
);
const before = await readIds();

await page.getByTestId('add-row-button').click();
await expect(rows).toHaveCount(before.length + 1);

const added = (await readIds()).find((id) => !before.includes(id)) ?? '';

return page.getByTestId(added);
};

// Re-pick until the trigger shows the label: the non-modal popover closes on scroll or misclicks a neighbour.
export const selectRelationType = async (
page: Page,
row: Locator,
relationTypeLabel: string
) => {
const relationTypeTrigger = row.locator('button[aria-haspopup="listbox"]');

await expect(async () => {
await selectOptionWithRetry(
relationTypeTrigger,
page.getByRole('option', { exact: true, name: relationTypeLabel })
);
await expect(relationTypeTrigger).toHaveText(relationTypeLabel, {
timeout: 2000,
});
}).toPass({ timeout: 30000 });
};

export const addRelatedTermsByRelationType = async (
page: Page,
rows: Array<{ relationTypeLabel: string; terms: GlossaryTerm[] }>
Expand All @@ -1195,25 +1250,10 @@ export const addRelatedTermsByRelationType = async (

for (let i = 0; i < rows.length; i++) {
const row = rows[i];

if (i > 0) {
await page.getByTestId('add-row-button').click();
}

// Row ids are non-deterministic (Date.now() in handleStartAdding/handleAddRow),
// so identify rows by position — first when i=0, otherwise last.
const rowLocator =
i === 0
? page.locator('[data-testid^="relation-row-"]').first()
: page.locator('[data-testid^="relation-row-"]').last();

await rowLocator.getByRole('button').first().click();
const option = page.getByRole('option', {
exact: true,
name: row.relationTypeLabel,
});
await expect(option).toBeVisible();
await option.click();
i === 0 ? await getOnlyRelationRow(page) : await addRelationRow(page);

await selectRelationType(page, rowLocator, row.relationTypeLabel);

const trigger = rowLocator.locator('[data-testid^="term-picker-"]');

Expand Down
Loading
Loading