Skip to content

Commit 46af313

Browse files
Fix explore quick filters test (#25955)
* Fix the test ExploreQuickFilters failing in AUTs * Add test setup * modify the variable name
1 parent 5edaa78 commit 46af313

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ExploreQuickFilters.spec.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
* limitations under the License.
1212
*/
1313
import test, { expect } from '@playwright/test';
14+
import { isUndefined } from 'lodash';
1415
import { SidebarItem } from '../../constant/sidebar';
1516
import { Domain } from '../../support/domain/Domain';
1617
import { TableClass } from '../../support/entity/TableClass';
18+
import { TagClass } from '../../support/tag/TagClass';
1719
import {
1820
clickOutside,
1921
createNewPage,
@@ -28,13 +30,17 @@ test.use({ storageState: 'playwright/.auth/admin.json' });
2830

2931
const domain = new Domain();
3032
const table = new TableClass();
33+
const tier = new TagClass({
34+
classification: 'Tier',
35+
});
3136

3237
test.beforeAll('Setup pre-requests', async ({ browser }) => {
3338
test.slow();
3439

3540
const { apiContext, afterAction } = await createNewPage(browser);
3641
await table.create(apiContext);
3742
await domain.create(apiContext);
43+
await tier.create(apiContext);
3844

3945
await table.patch({
4046
apiContext,
@@ -49,7 +55,7 @@ test.beforeAll('Setup pre-requests', async ({ browser }) => {
4955
{
5056
op: 'add',
5157
value: {
52-
tagFQN: 'Tier.Tier5',
58+
tagFQN: tier.responseData.fullyQualifiedName,
5359
},
5460
path: '/tags/1',
5561
},
@@ -122,27 +128,37 @@ test('should show correct count for initial options', async ({ page }) => {
122128
const aggregateAPI = page.waitForResponse(
123129
'/api/v1/search/aggregate?index=dataAsset&field=tier.tagFQN*'
124130
);
131+
const tierFetchAPI = page.waitForResponse(
132+
'/api/v1/tags?parent=Tier&limit=50'
133+
);
125134
await page.click(`[data-testid="search-dropdown-${filter.label}"]`);
126135

127136
const res = await aggregateAPI;
137+
const tierRes = await tierFetchAPI;
128138
const data = await res.json();
139+
const tierList = (await tierRes.json()).data;
129140
const buckets = data.aggregations['sterms#tier.tagFQN'].buckets;
130141

131142
await waitForAllLoadersToDisappear(page);
132143

133-
for (const bucket of buckets) {
134-
const normalizedKey = bucket.key
135-
.split('.')
136-
.map((seg: string) =>
137-
seg ? seg.charAt(0).toUpperCase() + seg.slice(1) : seg
138-
)
139-
.join('.');
140-
141-
await expect(
142-
page
143-
.locator(`[data-menu-id$="-${normalizedKey}"]`)
144-
.getByTestId('filter-count')
145-
).toHaveText(bucket.doc_count.toString());
144+
// The following logic is required due to special case for tier filter
145+
// where we are fetching the tier options from tag API and
146+
// the count from aggregation API.
147+
// So we need to match the bucket count with the corresponding tier option.
148+
for (const tierItem of tierList) {
149+
// Find the corresponding bucket for the tier
150+
const bucket = buckets.find(
151+
(item: { key: string }) =>
152+
item.key.toLowerCase() === tierItem.fullyQualifiedName?.toLowerCase()
153+
);
154+
// Check if the tier in the dropdown has a corresponding bucket in elastic search response
155+
if (!isUndefined(bucket)) {
156+
await expect(
157+
page
158+
.locator(`[data-menu-id$="-${tierItem.fullyQualifiedName}"]`)
159+
.getByTestId('filter-count')
160+
).toHaveText(bucket.doc_count.toString());
161+
}
146162
}
147163

148164
await clickOutside(page);

0 commit comments

Comments
 (0)