Add Is Null and Not Null filters for Owners and other fields (#14762)

* add is null and is not null operation

* cypress

---------

Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
Karan Hotchandani 2024-01-18 10:39:43 +05:30 committed by GitHub
parent c4b9d1bd21
commit 29901045ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 76 additions and 3 deletions

View File

@ -75,3 +75,78 @@ describe(`Advanced search quick filters should work properly for assets`, () =>
});
});
});
const testIsNullAndIsNotNullFilters = (operatorTitle, queryFilter, alias) => {
cy.sidebarClick('app-bar-item-explore');
const asset = QUICK_FILTERS_BY_ASSETS[0];
cy.get(`[data-testid="${asset.tab}"]`).scrollIntoView().click();
cy.get('[data-testid="advance-search-button"]').click();
// Check Is Null or Is Not Null
cy.get('.rule--operator > .ant-select > .ant-select-selector').eq(0).click();
cy.get(`[title="${operatorTitle}"]`).click();
cy.intercept('GET', '/api/v1/search/query?*', (req) => {
req.alias = alias;
}).as(alias);
cy.get('[data-testid="apply-btn"]').click();
cy.wait(`@${alias}`).then((xhr) => {
const actualQueryFilter = JSON.parse(xhr.request.query['query_filter']);
expect(actualQueryFilter).to.deep.equal(queryFilter);
});
};
describe(`Advanced Search Modal`, () => {
beforeEach(() => {
cy.login();
});
it('should check isNull and isNotNull filters', () => {
// Check Is Null
const isNullQuery = {
query: {
bool: {
must: [
{
bool: {
must: [
{
bool: {
must_not: {
exists: { field: 'owner.displayName.keyword' },
},
},
},
],
},
},
],
},
},
};
testIsNullAndIsNotNullFilters('Is null', isNullQuery, 'searchAPI');
// Check Is Not Null
const isNotNullQuery = {
query: {
bool: {
must: [
{
bool: {
must: [{ exists: { field: 'owner.displayName.keyword' } }],
},
},
],
},
},
};
testIsNullAndIsNotNullFilters(
'Is not null',
isNotNullQuery,
'newSearchAPI'
);
});
});

View File

@ -287,6 +287,7 @@ const ExploreV1: React.FC<ExploreProps> = ({
{(quickFilters || sqlQuery) && (
<Typography.Text
className="text-primary self-center cursor-pointer"
data-testid="clear-filters"
onClick={() => clearFilters()}>
{t('label.clear-entity', {
entity: '',

View File

@ -458,8 +458,6 @@ const getInitialConfigWithoutFields = () => {
operators: ['like', 'not_like'],
},
},
// Removes NULL check operators
excludeOperators: ['is_null', 'is_not_null'],
// Limits source to user input values, not other fields
valueSources: ['value'],
},
@ -471,7 +469,6 @@ const getInitialConfigWithoutFields = () => {
operators: ['like', 'not_like'],
},
},
excludeOperators: ['is_null', 'is_not_null'],
valueSources: ['value'],
},
text: {