-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(advanced-search): move entityStatus to common config with hard-coded list values #27642
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
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8ad568b
fix(advanced-search): move entityStatus to common config with hard-co…
Rohit0301 e7bf702
Merge branch 'main' into fix-27570
Rohit0301 b80b63a
lint and unit test fix
Rohit0301 053d337
Merge branch 'main' into fix-27570
Rohit0301 d168c15
Merge branch 'main' into fix-27570
Rohit0301 a8f2d30
Merge branch 'main' into fix-27570
Rohit0301 524331a
addressed PR comment
Rohit0301 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,13 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { expect } from '@playwright/test'; | ||
| import { EntityStatus } from '../../../src/generated/entity/data/searchIndex'; | ||
| import { COMMON_TIER_TAG } from '../../constant/common'; | ||
| import { SidebarItem } from '../../constant/sidebar'; | ||
| import { DataProduct } from '../../support/domain/DataProduct'; | ||
| import { EntityDataClass } from '../../support/entity/EntityDataClass'; | ||
| import { MlModelClass } from '../../support/entity/MlModelClass'; | ||
| import { TableClass } from '../../support/entity/TableClass'; | ||
| import { TopicClass } from '../../support/entity/TopicClass'; | ||
| import { Glossary } from '../../support/glossary/Glossary'; | ||
|
|
@@ -22,12 +26,17 @@ import { UserClass } from '../../support/user/UserClass'; | |
| import { performAdminLogin } from '../../utils/admin'; | ||
| import { | ||
| FIELDS, | ||
| fillRule, | ||
| fillStaticListRule, | ||
| OPERATOR, | ||
| runRuleGroupTests, | ||
| runRuleGroupTestsWithNonExistingValue, | ||
| selectOption, | ||
| showAdvancedSearchDialog, | ||
| verifyAllConditions, | ||
| } from '../../utils/advancedSearch'; | ||
| import { redirectToHomePage } from '../../utils/common'; | ||
| import { waitForAllLoadersToDisappear } from '../../utils/entity'; | ||
| import { sidebarClick } from '../../utils/sidebar'; | ||
| import { test } from '../fixtures/pages'; | ||
|
|
||
|
|
@@ -285,8 +294,8 @@ test.describe('Advanced Search', { tag: ['@advanced-search'] }, () => { | |
| table2.entityResponseData.name, | ||
| ], | ||
| 'project.keyword': [ | ||
| EntityDataClass.dashboardDataModel1.entityResponseData.project, | ||
| EntityDataClass.dashboardDataModel2.entityResponseData.project, | ||
| EntityDataClass.dashboardDataModel1.entityResponseData.project || '', | ||
| EntityDataClass.dashboardDataModel2.entityResponseData.project || '', | ||
| ], | ||
| 'charts.displayName.keyword': [ | ||
| EntityDataClass.dashboard1.chartsResponseData.displayName, | ||
|
|
@@ -344,3 +353,280 @@ test.describe('Advanced Search', { tag: ['@advanced-search'] }, () => { | |
| await runRuleGroupTestsWithNonExistingValue(page); | ||
| }); | ||
| }); | ||
|
|
||
| const ENTITY_STATUSES = Object.values(EntityStatus); | ||
|
|
||
| test.describe( | ||
| 'Advanced Search - Entity Status Filter', | ||
| { tag: ['@advanced-search', '@Discovery'] }, | ||
| () => { | ||
| // One distinct entity type per status to prove the filter works across entity types | ||
| const glossaryForStatus = new Glossary(); | ||
| const glossaryTermApproved = new GlossaryTerm(glossaryForStatus); | ||
| const mlModelDraft = new MlModelClass(); | ||
| const dataProductInReview = new DataProduct(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this pattern gives 409 error, please check |
||
|
|
||
| type StatusEntry = { | ||
| status: EntityStatus; | ||
| endpoint: string; | ||
| id: () => string; | ||
| displayName: () => string; | ||
| fqn: () => string; | ||
| }; | ||
|
|
||
| let statusEntries: StatusEntry[]; | ||
|
|
||
| test.beforeAll( | ||
| 'Create mixed entity types with distinct entity statuses', | ||
| async ({ browser }) => { | ||
| const { apiContext, afterAction } = await performAdminLogin(browser); | ||
|
|
||
| await glossaryForStatus.create(apiContext); | ||
| await Promise.all([ | ||
| glossaryTermApproved.create(apiContext), | ||
| mlModelDraft.create(apiContext), | ||
| dataProductInReview.create(apiContext), | ||
| ]); | ||
|
|
||
| statusEntries = [ | ||
| { | ||
| status: EntityStatus.Approved, | ||
| endpoint: 'glossaryTerms', | ||
| id: () => glossaryTermApproved.responseData.id, | ||
| displayName: () => glossaryTermApproved.data.displayName, | ||
| fqn: () => glossaryTermApproved.responseData.fullyQualifiedName, | ||
| }, | ||
| { | ||
| status: EntityStatus.Draft, | ||
| endpoint: 'mlmodels', | ||
| id: () => mlModelDraft.entityResponseData.id, | ||
| displayName: () => mlModelDraft.entity.displayName, | ||
| fqn: () => mlModelDraft.entityResponseData.fullyQualifiedName, | ||
| }, | ||
| { | ||
| status: EntityStatus.InReview, | ||
| endpoint: 'dataProducts', | ||
| id: () => dataProductInReview.responseData.id ?? '', | ||
| displayName: () => dataProductInReview.data.displayName, | ||
| fqn: () => | ||
| dataProductInReview.responseData.fullyQualifiedName ?? '', | ||
| }, | ||
| ]; | ||
|
|
||
| // Patch entityStatus on each entity | ||
| await Promise.all( | ||
| statusEntries.map(({ id, status, endpoint }) => | ||
| apiContext.patch(`/api/v1/${endpoint}/${id()}`, { | ||
| data: [{ op: 'add', path: '/entityStatus', value: status }], | ||
| headers: { 'Content-Type': 'application/json-patch+json' }, | ||
| }) | ||
| ) | ||
| ); | ||
|
|
||
| await afterAction(); | ||
| } | ||
| ); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await redirectToHomePage(page); | ||
| await sidebarClick(page, SidebarItem.EXPLORE); | ||
| }); | ||
|
|
||
| test('All entity status options are visible in the Status dropdown', async ({ | ||
| page, | ||
| }) => { | ||
| test.slow(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need test.slow? |
||
|
|
||
| await test.step('Open advanced search dialog', async () => { | ||
| await showAdvancedSearchDialog(page); | ||
| }); | ||
|
|
||
| await test.step('Select Status field and == operator', async () => { | ||
| const ruleLocator = page.locator('.rule').nth(0); | ||
| await selectOption( | ||
| page, | ||
| ruleLocator.locator('.rule--field .ant-select'), | ||
| 'Status', | ||
| true | ||
| ); | ||
| await selectOption( | ||
| page, | ||
| ruleLocator.locator('.rule--operator .ant-select'), | ||
| '==' | ||
| ); | ||
| }); | ||
|
|
||
| await test.step('Open Status value dropdown and verify all hard-coded options appear', async () => { | ||
| const ruleLocator = page.locator('.rule').nth(0); | ||
| await ruleLocator.locator('.widget--widget > .ant-select').click(); | ||
|
|
||
| const dropdown = page | ||
| .locator('.ant-select-dropdown') | ||
| .filter({ hasText: EntityStatus.Approved }) | ||
| .last(); | ||
|
|
||
| await expect(dropdown).toBeVisible(); | ||
|
|
||
| for (const status of ENTITY_STATUSES) { | ||
| await expect( | ||
| dropdown | ||
| .locator('.ant-select-item-option') | ||
| .filter({ hasText: new RegExp(`^${status}$`, 'i') }) | ||
| .first() | ||
| ).toBeVisible(); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| test('Filtering by status "==" shows matching entity and hides others across entity types', async ({ | ||
| page, | ||
| }) => { | ||
| test.slow(); | ||
|
|
||
| for (const entry of statusEntries) { | ||
| const { status } = entry; | ||
| const matchedName = entry.displayName(); | ||
|
|
||
| await test.step(`Apply Status == "${status}" AND Name == "${matchedName}"`, async () => { | ||
| await showAdvancedSearchDialog(page); | ||
|
|
||
| await fillStaticListRule(page, { | ||
| fieldLabel: 'Status', | ||
| condition: '==', | ||
| value: status, | ||
| ruleIndex: 1, | ||
| }); | ||
|
|
||
| await page.getByTestId('advanced-search-add-rule').nth(1).click(); | ||
|
|
||
| await fillRule(page, { | ||
| condition: '==', | ||
| field: { id: 'Display Name', name: 'displayName.keyword' }, | ||
| searchCriteria: matchedName, | ||
| index: 2, | ||
| }); | ||
|
|
||
| const searchRes = page.waitForResponse( | ||
| '/api/v1/search/query?*index=dataAsset*' | ||
| ); | ||
| await page.getByTestId('apply-btn').click(); | ||
| await searchRes; | ||
| await waitForAllLoadersToDisappear(page); | ||
| }); | ||
|
|
||
| await test.step('Filter chip shows the applied status', async () => { | ||
| await expect( | ||
| page.getByTestId('advance-search-filter-container') | ||
| ).toContainText(`'${status}'`); | ||
| }); | ||
|
|
||
| await test.step(`"${matchedName}" (${entry.endpoint}) is visible`, async () => { | ||
| await expect( | ||
| page.getByTestId(`table-data-card_${entry.fqn()}`) | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Entities with other statuses are not in results', async () => { | ||
| const otherEntries = statusEntries.filter((e) => e.status !== status); | ||
|
|
||
| for (const other of otherEntries) { | ||
| await expect( | ||
| page.getByTestId(`table-data-card_${other.fqn()}`) | ||
| ).not.toBeVisible(); | ||
| } | ||
| }); | ||
|
|
||
| await page.getByTestId('clear-filters').click(); | ||
| } | ||
| }); | ||
|
|
||
| test('Filtering by status "!=" excludes matched entity but shows all other entity types', async ({ | ||
| page, | ||
| }) => { | ||
| test.slow(); | ||
|
|
||
| const targetEntry = statusEntries.find( | ||
| (e) => e.status === EntityStatus.Approved | ||
| )!; | ||
| const approvedName = targetEntry.displayName(); | ||
| const otherEntries = statusEntries.filter( | ||
| (e) => e.status !== EntityStatus.Approved | ||
| ); | ||
|
|
||
| await test.step('Apply Status != "Approved" AND Name == approved entity name', async () => { | ||
| await showAdvancedSearchDialog(page); | ||
|
|
||
| await fillStaticListRule(page, { | ||
| fieldLabel: 'Status', | ||
| condition: '!=', | ||
| value: EntityStatus.Approved, | ||
| ruleIndex: 1, | ||
| }); | ||
|
|
||
| await page.getByTestId('advanced-search-add-rule').nth(1).click(); | ||
|
|
||
| await fillRule(page, { | ||
| condition: '==', | ||
| field: { id: 'Display Name', name: 'displayName.keyword' }, | ||
| searchCriteria: approvedName, | ||
| index: 2, | ||
| }); | ||
|
|
||
| const searchRes = page.waitForResponse( | ||
| '/api/v1/search/query?*index=dataAsset*' | ||
| ); | ||
| await page.getByTestId('apply-btn').click(); | ||
| await searchRes; | ||
| await waitForAllLoadersToDisappear(page); | ||
| }); | ||
|
|
||
| await test.step('Filter chip reflects the != condition', async () => { | ||
| await expect( | ||
| page.getByTestId('advance-search-filter-container') | ||
| ).toContainText(`'${EntityStatus.Approved}'`); | ||
| }); | ||
|
|
||
| await test.step('GlossaryTerm with Approved status is not visible', async () => { | ||
| await expect( | ||
| page.getByTestId(`table-data-card_${targetEntry.fqn()}`) | ||
| ).not.toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Draft and In Review entities appear when searched by their name and non-Approved status', async () => { | ||
| for (const entry of otherEntries) { | ||
| await page.getByTestId('clear-filters').click(); | ||
| await showAdvancedSearchDialog(page); | ||
|
|
||
| await fillStaticListRule(page, { | ||
| fieldLabel: 'Status', | ||
| condition: '!=', | ||
| value: EntityStatus.Approved, | ||
| ruleIndex: 1, | ||
| }); | ||
|
|
||
| await page.getByTestId('advanced-search-add-rule').nth(1).click(); | ||
|
|
||
| await fillRule(page, { | ||
| condition: '==', | ||
| field: { id: 'Display Name', name: 'displayName.keyword' }, | ||
| searchCriteria: entry.displayName(), | ||
| index: 2, | ||
| }); | ||
|
|
||
| const searchRes = page.waitForResponse( | ||
| '/api/v1/search/query?*index=dataAsset*' | ||
| ); | ||
| await page.getByTestId('apply-btn').click(); | ||
| await searchRes; | ||
| await waitForAllLoadersToDisappear(page); | ||
|
|
||
| await expect( | ||
| page.getByTestId(`table-data-card_${entry.fqn()}`) | ||
| ).toBeVisible(); | ||
| } | ||
| }); | ||
|
|
||
| await page.getByTestId('clear-filters').click(); | ||
| }); | ||
| } | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have such tag? please validate it, and for '@discovery' use tag from Domain constant