Minor: fixed failing query entity cypress (#17261)

* Minor: fixed failing query entity cypress

* fixed failing cypress
This commit is contained in:
Shailesh Parmar 2024-08-05 19:06:39 +05:30 committed by GitHub
parent 9fcbf6a5b9
commit 1b6b48e7be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 9 deletions

View File

@ -61,6 +61,7 @@ import {
updateQueryVote, updateQueryVote,
} from '../../../rest/queryAPI'; } from '../../../rest/queryAPI';
import { searchQuery } from '../../../rest/searchAPI'; import { searchQuery } from '../../../rest/searchAPI';
import { getEntityName } from '../../../utils/EntityUtils';
import { DEFAULT_ENTITY_PERMISSION } from '../../../utils/PermissionsUtils'; import { DEFAULT_ENTITY_PERMISSION } from '../../../utils/PermissionsUtils';
import { import {
createQueryFilter, createQueryFilter,
@ -288,11 +289,16 @@ const TableQueries: FC<TableQueriesProp> = ({
}; };
const fetchTags = async (searchText = WILD_CARD_CHAR) => { const fetchTags = async (searchText = WILD_CARD_CHAR) => {
return fetchFilterOptions( const data = await fetchFilterOptions(
searchText, searchText,
'disabled:false AND !classification.name:Tier', 'disabled:false AND !classification.name:Tier',
SearchIndex.TAG SearchIndex.TAG
); );
return data.hits.hits.map((hit) => ({
key: hit._source.fullyQualifiedName ?? hit._source.name,
label: getEntityName(hit._source),
}));
}; };
const setTagsDefaultOption = () => { const setTagsDefaultOption = () => {
@ -343,10 +349,15 @@ const TableQueries: FC<TableQueriesProp> = ({
}; };
const fetchOwner = async (searchText = WILD_CARD_CHAR) => { const fetchOwner = async (searchText = WILD_CARD_CHAR) => {
return fetchFilterOptions(searchText, 'isBot:false', [ const data = await fetchFilterOptions(searchText, 'isBot:false', [
SearchIndex.USER, SearchIndex.USER,
SearchIndex.TEAM, SearchIndex.TEAM,
]); ]);
return data.hits.hits.map((hit) => ({
key: hit._source.name,
label: getEntityName(hit._source),
}));
}; };
const setOwnerDefaultOption = () => { const setOwnerDefaultOption = () => {

View File

@ -17,7 +17,6 @@ import { SearchDropdownOption } from '../../components/SearchDropdown/SearchDrop
import { PAGE_SIZE_BASE } from '../../constants/constants'; import { PAGE_SIZE_BASE } from '../../constants/constants';
import { SearchIndex } from '../../enums/search.enum'; import { SearchIndex } from '../../enums/search.enum';
import { searchQuery } from '../../rest/searchAPI'; import { searchQuery } from '../../rest/searchAPI';
import { getEntityName } from '../EntityUtils';
export const createQueryFilter = ({ export const createQueryFilter = ({
tableId, tableId,
@ -46,7 +45,9 @@ export const createQueryFilter = ({
{ {
bool: { bool: {
should: owners.map((data) => ({ should: owners.map((data) => ({
term: { 'owners.displayName.keyword': data.key }, term: {
'owners.name': data.key,
},
})), })),
}, },
}, },
@ -102,10 +103,6 @@ export const fetchFilterOptions = async (
pageSize: PAGE_SIZE_BASE, pageSize: PAGE_SIZE_BASE,
searchIndex, searchIndex,
}); });
const options = response.hits.hits.map((hit) => ({
key: hit._source.fullyQualifiedName ?? hit._source.name,
label: getEntityName(hit._source),
}));
return options; return response;
}; };