Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #18007: Disabled Classifications or Tags shouldn't be visible in UI #18242

Merged
merged 6 commits into from
Oct 19, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
uuid,
} from '../../utils/common';
import { sidebarClick } from '../../utils/sidebar';
import { submitForm, validateForm } from '../../utils/tag';
import { addTagToTableColumn, submitForm, validateForm } from '../../utils/tag';

const NEW_CLASSIFICATION = {
name: `PlaywrightClassification-${uuid()}`,
Expand Down Expand Up @@ -190,9 +190,19 @@ test('Classification Page', async ({ page }) => {

await expect(
page.locator(
'[data-testid="classification-PII"] [data-testid="disabled"]'
`[data-testid="classification-${classification.responseData.name}"] [data-testid="disabled"]`
)
).not.toBeVisible();

await table.visitEntityPage(page);

await addTagToTableColumn(page, {
tagName: tag.responseData.name,
tagFqn: tag.responseData.fullyQualifiedName,
tagDisplayName: tag.responseData.displayName,
tableId: table.entityResponseData?.['id'],
columnNumber: 1,
});
});

await test.step('Create classification with validation checks', async () => {
Expand Down Expand Up @@ -263,41 +273,13 @@ test('Classification Page', async ({ page }) => {
await table.visitEntityPage(page);
const { name, displayName } = NEW_TAG;

await page.click(
'[data-testid="classification-tags-0"] [data-testid="entity-tags"] [data-testid="add-tag"]'
);
await page.fill('[data-testid="tag-selector"] input', name);
await page.click(`[data-testid="tag-${tagFqn}"]`);

await expect(
page.locator('[data-testid="tag-selector"] > .ant-select-selector')
).toContainText(displayName);

const saveAssociatedTag = page.waitForResponse(
(response) =>
response.request().method() === 'PATCH' &&
response
.url()
.includes(`/api/v1/tables/${table.entityResponseData?.['id']}`)
);
await page.click('[data-testid="saveAssociatedTag"]');
await saveAssociatedTag;

await page.waitForSelector('.ant-select-dropdown', {
state: 'detached',
await addTagToTableColumn(page, {
tagName: name,
tagFqn,
tagDisplayName: displayName,
tableId: table.entityResponseData?.['id'],
columnNumber: 0,
});

await expect(
page
.getByRole('row', { name: 'user_id numeric Unique' })
.getByTestId('tags-container')
).toContainText(displayName);

await expect(
page.locator(
'[data-testid="classification-tags-0"] [data-testid="tags-container"] [data-testid="icon"]'
)
).toBeVisible();
});

await test.step(
Expand Down
51 changes: 51 additions & 0 deletions openmetadata-ui/src/main/resources/ui/playwright/utils/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,54 @@ export async function validateForm(page: Page) {

await expect(page.getByText(NAME_VALIDATION_ERROR)).toBeVisible();
}

export const addTagToTableColumn = async (
page: Page,
{
tagName,
tagFqn,
tagDisplayName,
tableId,
columnNumber,
}: {
tagName: string;
tagFqn: string;
tagDisplayName: string;
tableId: string;
columnNumber: number;
}
) => {
await page.click(
`[data-testid="classification-tags-${columnNumber}"] [data-testid="entity-tags"] [data-testid="add-tag"]`
);
await page.fill('[data-testid="tag-selector"] input', tagName);
await page.click(`[data-testid="tag-${tagFqn}"]`);

await expect(
page.locator('[data-testid="tag-selector"] > .ant-select-selector')
).toContainText(tagDisplayName);

const saveAssociatedTag = page.waitForResponse(
(response) =>
response.request().method() === 'PATCH' &&
response.url().includes(`/api/v1/tables/${tableId}`)
);
await page.click('[data-testid="saveAssociatedTag"]');
await saveAssociatedTag;

await page.waitForSelector('.ant-select-dropdown', {
state: 'detached',
});

await expect(
page
.getByRole('row', { name: 'user_id numeric Unique' })
.getByTestId('tags-container')
).toContainText(tagDisplayName);
Ashish8689 marked this conversation as resolved.
Show resolved Hide resolved

await expect(
page.locator(
`[data-testid="classification-tags-${columnNumber}"] [data-testid="tags-container"] [data-testid="icon"]`
)
).toBeVisible();
};
Loading