mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-29 09:06:13 +00:00
fix explore sort test (#23414)
(cherry picked from commit 97da6e28ad841855eab8c58de2b7944b917dad44)
This commit is contained in:
parent
cee4556598
commit
f3e6a9b95a
@ -94,7 +94,6 @@ test.describe('Explore Sort Order Filter', () => {
|
|||||||
await page.getByTestId('update-btn').click();
|
await page.getByTestId('update-btn').click();
|
||||||
|
|
||||||
await selectSortOrder(page, 'Name');
|
await selectSortOrder(page, 'Name');
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
await verifyEntitiesAreSorted(page);
|
await verifyEntitiesAreSorted(page);
|
||||||
|
|
||||||
const clearFilters = page.getByTestId('clear-filters');
|
const clearFilters = page.getByTestId('clear-filters');
|
||||||
|
|||||||
@ -257,31 +257,42 @@ export const selectSortOrder = async (page: Page, sortOrder: string) => {
|
|||||||
await page.waitForSelector(`role=menuitem[name="${sortOrder}"]`, {
|
await page.waitForSelector(`role=menuitem[name="${sortOrder}"]`, {
|
||||||
state: 'visible',
|
state: 'visible',
|
||||||
});
|
});
|
||||||
|
const nameFilter = page.waitForResponse(
|
||||||
|
`/api/v1/search/query?q=&index=dataAsset&*sort_field=displayName.keyword&sort_order=desc*`
|
||||||
|
);
|
||||||
await page.getByRole('menuitem', { name: sortOrder }).click();
|
await page.getByRole('menuitem', { name: sortOrder }).click();
|
||||||
|
await nameFilter;
|
||||||
|
|
||||||
await expect(page.getByTestId('sorting-dropdown-label')).toHaveText(
|
await expect(page.getByTestId('sorting-dropdown-label')).toHaveText(
|
||||||
sortOrder
|
sortOrder
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const ascSortOrder = page.waitForResponse(
|
||||||
|
`/api/v1/search/query?q=&index=dataAsset&*sort_field=displayName.keyword&sort_order=asc*`
|
||||||
|
);
|
||||||
await page.getByTestId('sort-order-button').click();
|
await page.getByTestId('sort-order-button').click();
|
||||||
|
await ascSortOrder;
|
||||||
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const verifyEntitiesAreSorted = async (page: Page) => {
|
export const verifyEntitiesAreSorted = async (page: Page) => {
|
||||||
|
// Wait for search results to be stable after sort
|
||||||
|
await page.waitForSelector('[data-testid="search-results"]', {
|
||||||
|
state: 'visible',
|
||||||
|
});
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
const entityNames = await page.$$eval(
|
const entityNames = await page.$$eval(
|
||||||
'[data-testid="search-results"] .explore-search-card [data-testid="entity-link"]',
|
'[data-testid="search-results"] .explore-search-card [data-testid="entity-link"]',
|
||||||
(elements) => elements.map((el) => el.textContent?.trim() ?? '')
|
(elements) => elements.map((el) => el.textContent?.trim() ?? '')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Normalize for case insensitivity, but retain punctuation
|
// Elasticsearch keyword field with case-insensitive sorting
|
||||||
const normalize = (str: string) => str.toLowerCase().trim();
|
|
||||||
|
|
||||||
// Sort using ASCII-based string comparison (ES behavior)
|
|
||||||
const sortedEntityNames = [...entityNames].sort((a, b) => {
|
const sortedEntityNames = [...entityNames].sort((a, b) => {
|
||||||
const normA = normalize(a);
|
const aLower = a.toLowerCase();
|
||||||
const normB = normalize(b);
|
const bLower = b.toLowerCase();
|
||||||
|
|
||||||
return normA < normB ? -1 : normA > normB ? 1 : 0;
|
return aLower < bLower ? -1 : aLower > bLower ? 1 : 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(entityNames).toEqual(sortedEntityNames);
|
expect(entityNames).toEqual(sortedEntityNames);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user