cypress: work on advance search skip test (#14074)

This commit is contained in:
Shailesh Parmar 2023-11-24 09:45:07 +05:30 committed by GitHub
parent 1bb687d557
commit 50e00ea670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 506 additions and 409 deletions

View File

@ -10,13 +10,81 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { SEARCH_ENTITY_TABLE } from '../constants/constants'; import { SEARCH_ENTITY_TABLE } from '../constants/constants';
import { MYSQL } from '../constants/service.constants'; import {
DATABASE_DETAILS,
DATABASE_SERVICE_DETAILS,
SCHEMA_DETAILS,
TABLE_DETAILS,
} from '../constants/entityConstant';
import { USER_CREDENTIALS } from '../constants/SearchIndexDetails.constants';
import { import {
interceptURL, interceptURL,
uuid,
verifyResponseStatusCode, verifyResponseStatusCode,
visitEntityDetailsPage, visitEntityDetailsPage,
} from './common'; } from './common';
import { createEntityTable } from './entityUtils';
export const ADVANCE_SEARCH_TABLES = {
table1: TABLE_DETAILS,
table2: {
name: `cy-table2-${uuid()}`,
description: 'description',
columns: [
{
name: 'cypress_first_name',
dataType: 'VARCHAR',
dataLength: 100,
dataTypeDisplay: 'varchar',
description: 'First name of the staff member.',
},
{
name: 'cypress_last_name',
dataType: 'VARCHAR',
dataLength: 100,
dataTypeDisplay: 'varchar',
},
{
name: 'cypress_email',
dataType: 'VARCHAR',
dataLength: 100,
dataTypeDisplay: 'varchar',
description: 'Email address of the staff member.',
},
],
databaseSchema: `${DATABASE_SERVICE_DETAILS.name}.${DATABASE_DETAILS.name}.${SCHEMA_DETAILS.name}`,
},
table3: {
name: `cy-table3-${uuid()}`,
description: 'description',
columns: [
{
name: 'cypress_user_id',
dataType: 'NUMERIC',
dataTypeDisplay: 'numeric',
description:
'Unique identifier for the user of your Shopify POS or your Shopify admin.',
},
{
name: 'cypress_shop_id',
dataType: 'NUMERIC',
dataTypeDisplay: 'numeric',
description:
'The ID of the store. This column is a foreign key reference to the shop_id column in the dim.shop table.',
},
],
databaseSchema: `${DATABASE_SERVICE_DETAILS.name}.${DATABASE_DETAILS.name}.${SCHEMA_DETAILS.name}`,
},
};
export const ADVANCE_SEARCH_DATABASE_SERVICE = {
service: DATABASE_SERVICE_DETAILS,
database: DATABASE_DETAILS,
schema: SCHEMA_DETAILS,
tables: Object.values(ADVANCE_SEARCH_TABLES),
};
export const CONDITIONS_MUST = { export const CONDITIONS_MUST = {
equalTo: { equalTo: {
@ -47,14 +115,15 @@ export const CONDITIONS_MUST_NOT = {
filter: 'must_not', filter: 'must_not',
}, },
}; };
const ownerFullName = `${USER_CREDENTIALS.firstName}${USER_CREDENTIALS.lastName}`;
export const FIELDS = { export const FIELDS = {
Owner: { Owner: {
name: 'Owner', name: 'Owner',
testid: '[title="Owner"]', testid: '[title="Owner"]',
searchTerm1: 'Aaron Johnson', searchTerm1: ownerFullName,
searchCriteriaFirstGroup: 'Aaron Johnson', searchCriteriaFirstGroup: ownerFullName,
responseValueFirstGroup: `"displayName":"Aaron Johnson"`, responseValueFirstGroup: `"displayName":"${ownerFullName}"`,
searchCriteriaSecondGroup: 'Aaron Singh', searchCriteriaSecondGroup: 'Aaron Singh',
owner: true, owner: true,
responseValueSecondGroup: 'Aaron Singh', responseValueSecondGroup: 'Aaron Singh',
@ -81,32 +150,32 @@ export const FIELDS = {
testid: '[title="Service"]', testid: '[title="Service"]',
searchCriteriaFirstGroup: 'sample_data', searchCriteriaFirstGroup: 'sample_data',
responseValueFirstGroup: `"name":"sample_data"`, responseValueFirstGroup: `"name":"sample_data"`,
searchCriteriaSecondGroup: MYSQL.serviceName, searchCriteriaSecondGroup: DATABASE_SERVICE_DETAILS.name,
responseValueSecondGroup: `"name":"${MYSQL.serviceName}"`, responseValueSecondGroup: `"name":"${DATABASE_SERVICE_DETAILS.name}"`,
}, },
Database: { Database: {
name: 'Database', name: 'Database',
testid: '[title="Database"]', testid: '[title="Database"]',
searchCriteriaFirstGroup: 'default', searchCriteriaFirstGroup: 'ecommerce_db',
responseValueFirstGroup: `"name":"default"`, responseValueFirstGroup: `"name":"ecommerce_db"`,
searchCriteriaSecondGroup: 'ecommerce_db', searchCriteriaSecondGroup: DATABASE_DETAILS.name,
responseValueSecondGroup: `"name":"ecommerce_db"`, responseValueSecondGroup: `"name":"${DATABASE_DETAILS.name}"`,
}, },
Database_Schema: { Database_Schema: {
name: 'Database Schema', name: 'Database Schema',
testid: '[title="Database Schema"]', testid: '[title="Database Schema"]',
searchCriteriaFirstGroup: 'shopify', searchCriteriaFirstGroup: 'shopify',
responseValueFirstGroup: `"name":"shopify"`, responseValueFirstGroup: `"name":"shopify"`,
searchCriteriaSecondGroup: 'cypress_integrations_test_db', searchCriteriaSecondGroup: SCHEMA_DETAILS.name,
responseValueSecondGroup: `"name":"cypress_integrations_test_db"`, responseValueSecondGroup: `"name":"${SCHEMA_DETAILS.name}"`,
}, },
Column: { Column: {
name: 'Column', name: 'Column',
testid: '[title="Column"]', testid: '[title="Column"]',
searchCriteriaFirstGroup: 'SKU', searchCriteriaFirstGroup: 'cypress_first_name',
responseValueFirstGroup: '"name":"SKU"', responseValueFirstGroup: '"name":"cypress_first_name"',
searchCriteriaSecondGroup: 'api_client_id', searchCriteriaSecondGroup: 'cypress_user_id',
responseValueSecondGroup: '"name":"api_client_id"', responseValueSecondGroup: '"name":"cypress_user_id"',
}, },
}; };
@ -122,42 +191,34 @@ export const OPERATOR = {
}; };
export const searchForField = (condition, fieldid, searchCriteria, index) => { export const searchForField = (condition, fieldid, searchCriteria, index) => {
interceptURL('GET', '/api/v1/search/suggest?q=*', 'suggestApi'); interceptURL('GET', '/api/v1/search/aggregate?*', 'suggestApi');
// Click on field dropdown // Click on field dropdown
cy.get('.rule--field > .ant-select > .ant-select-selector') cy.get('.rule--field > .ant-select > .ant-select-selector').eq(index).click();
.eq(index)
.should('be.visible')
.click();
// Select owner fields // Select owner fields
cy.get(`${fieldid}`).eq(index).should('be.visible').click(); cy.get(`${fieldid}`).eq(index).click();
// Select the condition // Select the condition
cy.get('.rule--operator > .ant-select > .ant-select-selector') cy.get('.rule--operator > .ant-select > .ant-select-selector')
.eq(index) .eq(index)
.should('be.visible')
.click(); .click();
cy.get(`[title="${condition}"]`).eq(index).should('be.visible').click(); cy.get(`[title="${condition}"]`).eq(index).click();
// Verify the condition // Verify the condition
cy.get('.rule--operator .ant-select-selection-item') cy.get('.rule--operator .ant-select-selection-item').should(
.should('be.visible') 'contain',
.should('contain', `${condition}`); `${condition}`
);
// Verify the search criteria for the condition // Verify the search criteria for the condition
cy.get('body').then(($body) => { cy.get('body').then(($body) => {
if ($body.find('.ant-col > .ant-input').length) { if ($body.find('.ant-col > .ant-input').length) {
cy.get('.ant-col > .ant-input') cy.get('.ant-col > .ant-input').eq(index).type(searchCriteria);
.eq(index)
.should('be.visible')
.type(searchCriteria);
} else { } else {
cy.get('.widget--widget > .ant-select > .ant-select-selector') cy.get('.widget--widget > .ant-select > .ant-select-selector')
.eq(index) .eq(index)
.should('be.visible')
.type(searchCriteria); .type(searchCriteria);
// select value from dropdown // select value from dropdown
verifyResponseStatusCode('@suggestApi', 200); verifyResponseStatusCode('@suggestApi', 200);
cy.get(`.ant-select-dropdown [title = '${searchCriteria}']`) cy.get(`.ant-select-dropdown [title = '${searchCriteria}']`)
.should('be.visible')
.trigger('mouseover') .trigger('mouseover')
.trigger('click'); .trigger('click');
} }
@ -165,34 +226,10 @@ export const searchForField = (condition, fieldid, searchCriteria, index) => {
}; };
export const goToAdvanceSearch = () => { export const goToAdvanceSearch = () => {
interceptURL(
'GET',
'/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*&sort_field=_score&sort_order=desc',
'explorePage'
);
// Navigate to explore page // Navigate to explore page
cy.get('[data-testid="app-bar-item-explore"]') cy.get('[data-testid="app-bar-item-explore"]').click();
.should('exist') cy.get('[data-testid="advance-search-button"]').click();
.and('be.visible') cy.get('[data-testid="reset-btn"]').click();
.click();
cy.get('[data-testid="tables-tab"]')
.scrollIntoView()
.should('exist')
.and('be.visible');
cy.wait('@explorePage').then(() => {
// Click on advance search button
cy.get('[data-testid="advance-search-button"]')
.should('be.visible')
.click();
cy.get('.ant-btn')
.contains('Reset')
.scrollIntoView()
.should('be.visible')
.click();
});
}; };
export const checkmustPaths = ( export const checkmustPaths = (
@ -211,10 +248,11 @@ export const checkmustPaths = (
'GET', 'GET',
`/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*must*${encodeURI( `/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*must*${encodeURI(
searchCriteria searchCriteria
)}*&sort_field=_score&sort_order=desc`, )}*`,
'search' 'search'
); );
// //Click on apply filter
// Click on apply filter
cy.get('.ant-btn-primary').contains('Apply').click(); cy.get('.ant-btn-primary').contains('Apply').click();
cy.wait('@search').should(({ request, response }) => { cy.wait('@search').should(({ request, response }) => {
@ -240,7 +278,7 @@ export const checkmust_notPaths = (
'GET', 'GET',
`/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*must_not*${encodeURI( `/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*must_not*${encodeURI(
searchCriteria searchCriteria
)}*&sort_field=_score&sort_order=desc`, )}*`,
'search_must_not' 'search_must_not'
); );
// Click on apply filter // Click on apply filter
@ -271,11 +309,11 @@ export const removeOwner = () => {
cy.get('[data-testid="owner-link"]').should('contain', 'No Owner'); cy.get('[data-testid="owner-link"]').should('contain', 'No Owner');
}; };
export const addOwner = (ownerName) => { export const addOwner = ({ ownerName, term, serviceName, entity }) => {
visitEntityDetailsPage({ visitEntityDetailsPage({
term: SEARCH_ENTITY_TABLE.table_1.term, term,
serviceName: SEARCH_ENTITY_TABLE.table_1.serviceName, serviceName,
entity: SEARCH_ENTITY_TABLE.table_1.entity, entity,
}); });
interceptURL( interceptURL(
@ -321,11 +359,11 @@ export const addOwner = (ownerName) => {
}); });
}; };
export const addTier = () => { export const addTier = ({ term, serviceName, entity }) => {
visitEntityDetailsPage({ visitEntityDetailsPage({
term: SEARCH_ENTITY_TABLE.table_2.term, term,
serviceName: SEARCH_ENTITY_TABLE.table_2.serviceName, serviceName,
entity: SEARCH_ENTITY_TABLE.table_2.entity, entity,
}); });
cy.get('[data-testid="edit-tier"]') cy.get('[data-testid="edit-tier"]')
@ -343,11 +381,11 @@ export const addTier = () => {
cy.get('[data-testid="tier-dropdown"]').should('contain', 'Tier1'); cy.get('[data-testid="tier-dropdown"]').should('contain', 'Tier1');
}; };
export const addTag = (tag) => { export const addTag = ({ tag, term, serviceName, entity }) => {
visitEntityDetailsPage({ visitEntityDetailsPage({
term: SEARCH_ENTITY_TABLE.table_3.term, term,
serviceName: SEARCH_ENTITY_TABLE.table_3.serviceName, serviceName,
entity: SEARCH_ENTITY_TABLE.table_3.entity, entity,
}); });
cy.get('[data-testid="entity-right-panel"] [data-testid="entity-tags"]') cy.get('[data-testid="entity-right-panel"] [data-testid="entity-tags"]')
@ -415,7 +453,7 @@ export const checkAddGroupWithOperator = (
.should('be.visible') .should('be.visible')
.type(searchCriteria_1); .type(searchCriteria_1);
} else { } else {
interceptURL('GET', '/api/v1/search/suggest?q=*', 'suggestApi'); interceptURL('GET', '/api/v1/search/aggregate?*', 'suggestApi');
cy.get('.widget--widget > .ant-select > .ant-select-selector') cy.get('.widget--widget > .ant-select > .ant-select-selector')
.eq(index_1) .eq(index_1)
.should('be.visible') .should('be.visible')
@ -468,7 +506,7 @@ export const checkAddGroupWithOperator = (
.should('be.visible') .should('be.visible')
.type(searchCriteria_2); .type(searchCriteria_2);
} else { } else {
interceptURL('GET', '/api/v1/search/suggest?q=*', 'suggestApi'); interceptURL('GET', '/api/v1/search/aggregate?*', 'suggestApi');
cy.get('.widget--widget > .ant-select > .ant-select-selector') cy.get('.widget--widget > .ant-select > .ant-select-selector')
.eq(index_2) .eq(index_2)
.should('be.visible') .should('be.visible')
@ -488,14 +526,14 @@ export const checkAddGroupWithOperator = (
'GET', 'GET',
`/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*${encodeURI( `/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*${encodeURI(
searchCriteria_1 searchCriteria_1
)}*&sort_field=_score&sort_order=desc`, )}*`,
'search' `search${searchCriteria_1}`
); );
// Click on apply filter // Click on apply filter
cy.get('.ant-btn-primary').contains('Apply').click(); cy.get('.ant-btn-primary').contains('Apply').click();
cy.wait('@search').should(({ request, response }) => { cy.wait(`@search${searchCriteria_1}`).should(({ request, response }) => {
const resBody = JSON.stringify(response.body); const resBody = JSON.stringify(response.body);
expect(request.url).to.contain(encodeURI(searchCriteria_1)); expect(request.url).to.contain(encodeURI(searchCriteria_1));
@ -539,7 +577,7 @@ export const checkAddRuleWithOperator = (
.should('be.visible') .should('be.visible')
.type(searchCriteria_1); .type(searchCriteria_1);
} else { } else {
interceptURL('GET', '/api/v1/search/suggest?q=*', 'suggestApi'); interceptURL('GET', '/api/v1/search/aggregate?*', 'suggestApi');
cy.get('.widget--widget > .ant-select > .ant-select-selector') cy.get('.widget--widget > .ant-select > .ant-select-selector')
.eq(index_1) .eq(index_1)
@ -588,7 +626,7 @@ export const checkAddRuleWithOperator = (
.should('be.visible') .should('be.visible')
.type(searchCriteria_2); .type(searchCriteria_2);
} else { } else {
interceptURL('GET', '/api/v1/search/suggest?q=*', 'suggestApi'); interceptURL('GET', '/api/v1/search/aggregate?*', 'suggestApi');
cy.get('.widget--widget > .ant-select > .ant-select-selector') cy.get('.widget--widget > .ant-select > .ant-select-selector')
.eq(index_2) .eq(index_2)
.should('be.visible') .should('be.visible')
@ -609,17 +647,141 @@ export const checkAddRuleWithOperator = (
'GET', 'GET',
`/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*${filter_1}*${encodeURI( `/api/v1/search/query?q=&index=*&from=0&size=10&deleted=false&query_filter=*${filter_1}*${encodeURI(
searchCriteria_1 searchCriteria_1
)}*${filter_2}*${encodeURI(response_2)}*&sort_field=_score&sort_order=desc`, )}*${filter_2}*${encodeURI(response_2)}*`,
'search' `search${searchCriteria_1}`
); );
// Click on apply filter // Click on apply filter
cy.get('.ant-btn-primary').contains('Apply').click(); cy.get('.ant-btn-primary').contains('Apply').click();
cy.wait('@search').should(({ request, response }) => { cy.wait(`@search${searchCriteria_1}`).should(({ request, response }) => {
const resBody = JSON.stringify(response.body); const resBody = JSON.stringify(response.body);
expect(request.url).to.contain(encodeURI(searchCriteria_1)); expect(request.url).to.contain(encodeURI(searchCriteria_1));
expect(resBody).to.not.include(response_2); expect(resBody).to.not.include(response_2);
}); });
}; };
export const advanceSearchPreRequests = (token) => {
// Create Table hierarchy
createEntityTable({
token,
...ADVANCE_SEARCH_DATABASE_SERVICE,
});
// Create a new user
cy.request({
method: 'POST',
url: `/api/v1/users/signup`,
headers: { Authorization: `Bearer ${token}` },
body: USER_CREDENTIALS,
}).then((response) => {
USER_CREDENTIALS.id = response.body.id;
});
// Add owner to table 1
cy.request({
method: 'GET',
url: `/api/v1/tables/name/${ADVANCE_SEARCH_TABLES.table1.databaseSchema}.${ADVANCE_SEARCH_TABLES.table1.name}`,
headers: { Authorization: `Bearer ${token}` },
}).then((response) => {
cy.request({
method: 'PATCH',
url: `/api/v1/tables/${response.body.id}`,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json-patch+json',
},
body: [
{
op: 'add',
path: '/owner',
value: {
id: USER_CREDENTIALS.id,
type: 'user',
},
},
],
});
});
// Add Tier to table 2
cy.request({
method: 'GET',
url: `/api/v1/tables/name/${ADVANCE_SEARCH_TABLES.table2.databaseSchema}.${ADVANCE_SEARCH_TABLES.table2.name}`,
headers: { Authorization: `Bearer ${token}` },
}).then((response) => {
cy.request({
method: 'PATCH',
url: `/api/v1/tables/${response.body.id}`,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json-patch+json',
},
body: [
{
op: 'add',
path: '/tags/0',
value: {
name: 'Tier1',
tagFQN: 'Tier.Tier1',
labelType: 'Manual',
state: 'Confirmed',
},
},
{
op: 'add',
path: '/tags/1',
value: {
name: 'SpecialCategory',
tagFQN: 'PersonalData.SpecialCategory',
labelType: 'Manual',
state: 'Confirmed',
},
},
],
});
});
// Add Tag to table 3
cy.request({
method: 'GET',
url: `/api/v1/tables/name/${ADVANCE_SEARCH_TABLES.table3.databaseSchema}.${ADVANCE_SEARCH_TABLES.table3.name}`,
headers: { Authorization: `Bearer ${token}` },
}).then((response) => {
cy.request({
method: 'PATCH',
url: `/api/v1/tables/${response.body.id}`,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json-patch+json',
},
body: [
{
op: 'add',
path: '/tags/0',
value: {
tagFQN: 'PersonalData.Personal',
source: 'Classification',
name: 'Personal',
description:
'Data that can be used to directly or indirectly identify a person.',
labelType: 'Manual',
state: 'Confirmed',
},
},
{
op: 'add',
path: '/tags/1',
value: {
name: 'Tier2',
tagFQN: 'Tier.Tier2',
labelType: 'Manual',
state: 'Confirmed',
},
},
],
});
});
};

View File

@ -908,20 +908,17 @@ export const editCreatedProperty = (propertyName) => {
// Fetching for edit button // Fetching for edit button
cy.get(`[data-row-key="${propertyName}"]`) cy.get(`[data-row-key="${propertyName}"]`)
.find('[data-testid="edit-button"]') .find('[data-testid="edit-button"]')
.as('editbutton'); .as('editButton');
cy.get('@editbutton').click(); cy.get('@editButton').click();
cy.get(descriptionBox) cy.get(descriptionBox).clear().type('This is new description');
.should('be.visible')
.clear()
.type('This is new description');
interceptURL('PATCH', '/api/v1/metadata/types/*', 'checkPatchForDescription'); interceptURL('PATCH', '/api/v1/metadata/types/*', 'checkPatchForDescription');
cy.get('[data-testid="save"]').should('be.visible').click(); cy.get('[data-testid="save"]').click();
verifyResponseStatusCode('@checkPatchForDescription', 200); cy.wait('@checkPatchForDescription', { timeout: 10000 });
cy.get('.ant-modal-wrap').should('not.exist'); cy.get('.ant-modal-wrap').should('not.exist');
@ -934,10 +931,9 @@ export const editCreatedProperty = (propertyName) => {
export const deleteCreatedProperty = (propertyName) => { export const deleteCreatedProperty = (propertyName) => {
// Fetching for delete button // Fetching for delete button
cy.get(`[data-row-key="${propertyName}"]`) cy.get(`[data-row-key="${propertyName}"]`)
.scrollIntoView()
.find('[data-testid="delete-button"]') .find('[data-testid="delete-button"]')
.as('deletebutton'); .click();
cy.get('@deletebutton').click();
// Checking property name is present on the delete pop-up // Checking property name is present on the delete pop-up
cy.get('[data-testid="body-text"]').should('contain', propertyName); cy.get('[data-testid="body-text"]').should('contain', propertyName);
@ -1189,7 +1185,7 @@ export const addOwner = (
isGlossaryPage, isGlossaryPage,
isOwnerEmpty = false isOwnerEmpty = false
) => { ) => {
interceptURL('GET', '/api/v1/users?limit=*&isBot=false', 'getUsers'); interceptURL('GET', '/api/v1/users?limit=*&isBot=false*', 'getUsers');
if (isGlossaryPage && isOwnerEmpty) { if (isGlossaryPage && isOwnerEmpty) {
cy.get('[data-testid="glossary-owner-name"] > [data-testid="Add"]').click(); cy.get('[data-testid="glossary-owner-name"] > [data-testid="Add"]').click();
} else { } else {
@ -1221,10 +1217,11 @@ export const addOwner = (
}; };
export const removeOwner = (entity, isGlossaryPage) => { export const removeOwner = (entity, isGlossaryPage) => {
interceptURL('GET', '/api/v1/users?limit=*&isBot=false*', 'getUsers');
interceptURL('PATCH', `/api/v1/${entity}/*`, 'patchOwner'); interceptURL('PATCH', `/api/v1/${entity}/*`, 'patchOwner');
cy.get('[data-testid="edit-owner"]').click(); cy.get('[data-testid="edit-owner"]').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get('[data-testid="remove-owner"]').click(); cy.get('[data-testid="remove-owner"]').click();
verifyResponseStatusCode('@patchOwner', 200); verifyResponseStatusCode('@patchOwner', 200);
if (isGlossaryPage) { if (isGlossaryPage) {

View File

@ -11,22 +11,24 @@
* limitations under the License. * limitations under the License.
*/ */
import { addOwner, FIELDS, removeOwner } from '../../common/advancedSearch'; import { addOwner, removeOwner } from '../../common/advancedSearch';
import { searchAndClickOnOption } from '../../common/advancedSearchQuickFilters'; import { searchAndClickOnOption } from '../../common/advancedSearchQuickFilters';
import { interceptURL, verifyResponseStatusCode } from '../../common/common'; import { interceptURL, verifyResponseStatusCode } from '../../common/common';
import { QUICK_FILTERS_BY_ASSETS } from '../../constants/advancedSearchQuickFilters.constants'; import { QUICK_FILTERS_BY_ASSETS } from '../../constants/advancedSearchQuickFilters.constants';
import { SEARCH_ENTITY_TABLE } from '../../constants/constants';
describe('Initial Setup for Advanced Search Quick Filters', () => { const ownerName = 'Aaron Johnson';
beforeEach(() => {
cy.login();
});
it('Pre-requisite for advance search', () => {
addOwner(FIELDS.Owner.searchCriteriaFirstGroup);
});
});
describe(`Advanced search quick filters should work properly for assets`, () => { describe(`Advanced search quick filters should work properly for assets`, () => {
before(() => {
cy.login();
addOwner({ ownerName, ...SEARCH_ENTITY_TABLE.table_1 });
});
after(() => {
cy.login();
removeOwner();
});
beforeEach(() => { beforeEach(() => {
cy.login(); cy.login();
}); });
@ -76,13 +78,3 @@ describe(`Advanced search quick filters should work properly for assets`, () =>
}); });
}); });
}); });
describe('Cleanup for Advanced Search Quick Filters', () => {
beforeEach(() => {
cy.login();
});
it('Cleanup of owners', () => {
removeOwner(FIELDS.Owner.searchCriteriaFirstGroup);
});
});

View File

@ -14,9 +14,8 @@
// The spec is related to advance search feature // The spec is related to advance search feature
import { import {
addOwner, advanceSearchPreRequests,
addTag, ADVANCE_SEARCH_DATABASE_SERVICE,
addTier,
checkAddGroupWithOperator, checkAddGroupWithOperator,
checkAddRuleWithOperator, checkAddRuleWithOperator,
checkmustPaths, checkmustPaths,
@ -26,271 +25,229 @@ import {
FIELDS, FIELDS,
OPERATOR, OPERATOR,
} from '../../common/advancedSearch'; } from '../../common/advancedSearch';
import { import { hardDeleteService } from '../../common/entityUtils';
deleteCreatedService, import { USER_CREDENTIALS } from '../../constants/SearchIndexDetails.constants';
interceptURL, import { SERVICE_CATEGORIES } from '../../constants/service.constants';
mySqlConnectionInput,
testServiceCreationAndIngestion,
verifyResponseStatusCode,
} from '../../common/common';
import { API_SERVICE, SERVICE_TYPE } from '../../constants/constants';
import { MYSQL } from '../../constants/service.constants';
const service_name = MYSQL.serviceName; describe('Advance search', () => {
before(() => {
describe.skip('pre-requests for test case', () => {
beforeEach(() => {
cy.login(); cy.login();
}); cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;
it('Pre-requisite for advance search', () => { advanceSearchPreRequests(token);
addOwner(FIELDS.Owner.searchCriteriaFirstGroup);
addTier(FIELDS.Tiers.searchCriteriaFirstGroup);
addTag(FIELDS.Tags.createTagName);
});
it('Mysql ingestion', () => {
interceptURL(
'GET',
'api/v1/teams/name/Organization?fields=*',
'getSettingsPage'
);
cy.get('[data-testid="app-bar-item-settings"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@getSettingsPage', 200);
// Services page
interceptURL('GET', '/api/v1/services/*', 'getServiceList');
cy.get('[data-testid="global-setting-left-panel"]')
.contains(MYSQL.database)
.should('be.visible')
.click();
verifyResponseStatusCode('@getServiceList', 200);
cy.get('[data-testid="add-service-button"]').should('be.visible').click();
// Add new service page
cy.url().should('include', '/add-service');
cy.get('[data-testid="header"]').should('be.visible');
cy.contains('Add New Service').should('be.visible');
cy.get('[data-testid="service-category"]').should('be.visible');
const addIngestionInput = () => {
cy.get('[data-testid="schema-filter-pattern-checkbox"]')
.invoke('show')
.trigger('mouseover')
.check();
cy.get('[data-testid="filter-pattern-includes-schema"]')
.scrollIntoView()
.should('be.visible')
.type(Cypress.env('mysqlDatabaseSchema'));
};
testServiceCreationAndIngestion({
serviceType: MYSQL.serviceType,
connectionInput: mySqlConnectionInput,
addIngestionInput,
serviceName: service_name,
serviceCategory: SERVICE_TYPE.Database,
});
});
});
describe.skip('Single filed search', () => {
beforeEach(() => {
cy.login();
});
Object.values(FIELDS).forEach((field) => {
it(`Verify advance search results for ${field.name} field and all condition`, () => {
Object.values(CONDITIONS_MUST).forEach((condition) => {
checkmustPaths(
condition.name,
field.testid,
field.searchCriteriaFirstGroup,
0,
field.responseValueFirstGroup
);
});
Object.values(CONDITIONS_MUST_NOT).forEach((condition) => {
checkmust_notPaths(
condition.name,
field.testid,
field.searchCriteriaFirstGroup,
0,
field.responseValueFirstGroup
);
});
}); });
}); });
after(() => { after(() => {
Cypress.session.clearAllSavedSessions();
});
});
describe.skip('Group search', () => {
beforeEach(() => {
cy.login(); cy.login();
}); cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;
Object.values(OPERATOR).forEach((operator) => { hardDeleteService({
it(`Verify Add group functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.equalTo.name} and ${CONDITIONS_MUST_NOT.notEqualTo.name} `, () => { token,
Object.values(FIELDS).forEach((field) => { serviceFqn: ADVANCE_SEARCH_DATABASE_SERVICE.service.name,
let val = field.searchCriteriaSecondGroup; serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES,
if (field.owner) {
val = field.responseValueSecondGroup;
}
checkAddGroupWithOperator(
CONDITIONS_MUST.equalTo.name,
CONDITIONS_MUST_NOT.notEqualTo.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.equalTo.filter,
CONDITIONS_MUST_NOT.notEqualTo.filter,
field.responseValueFirstGroup,
val
);
}); });
}); // Delete created user
cy.request({
it(`Verify Add group functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.anyIn.name} and ${CONDITIONS_MUST_NOT.notIn.name} `, () => { method: 'DELETE',
Object.values(FIELDS).forEach((field) => { url: `/api/v1/users/${USER_CREDENTIALS.id}?hardDelete=true&recursive=false`,
let val = field.searchCriteriaSecondGroup; headers: { Authorization: `Bearer ${token}` },
if (field.owner) {
val = field.responseValueSecondGroup;
}
checkAddGroupWithOperator(
CONDITIONS_MUST.anyIn.name,
CONDITIONS_MUST_NOT.notIn.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.anyIn.filter,
CONDITIONS_MUST_NOT.notIn.filter,
field.responseValueFirstGroup,
val
);
});
});
it(`Verify Add group functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.contains.name} and ${CONDITIONS_MUST_NOT.notContains.name} `, () => {
Object.values(FIELDS).forEach((field) => {
let val = field.searchCriteriaSecondGroup;
checkAddGroupWithOperator(
CONDITIONS_MUST.contains.name,
CONDITIONS_MUST_NOT.notContains.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.contains.filter,
CONDITIONS_MUST_NOT.notContains.filter,
field.responseValueFirstGroup,
val
);
}); });
}); });
}); });
after(() => {
Cypress.session.clearAllSavedSessions(); describe('Single filed search', () => {
}); beforeEach(() => {
}); cy.login();
});
describe.skip('Search with additional rule', () => {
beforeEach(() => { Object.values(FIELDS).forEach((field) => {
cy.login(); it(`Verify advance search results for ${field.name} field and all condition`, () => {
}); Object.values(CONDITIONS_MUST).forEach((condition) => {
checkmustPaths(
Object.values(OPERATOR).forEach((operator) => { condition.name,
it(`Verify Add Rule functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.equalTo.name} and ${CONDITIONS_MUST_NOT.notEqualTo.name} `, () => { field.testid,
Object.values(FIELDS).forEach((field) => { field.searchCriteriaFirstGroup,
let val = field.searchCriteriaSecondGroup; 0,
if (field.owner) { field.responseValueFirstGroup
val = field.responseValueSecondGroup; );
} });
checkAddRuleWithOperator(
CONDITIONS_MUST.equalTo.name, Object.values(CONDITIONS_MUST_NOT).forEach((condition) => {
CONDITIONS_MUST_NOT.notEqualTo.name, checkmust_notPaths(
field.testid, condition.name,
field.searchCriteriaFirstGroup, field.testid,
field.searchCriteriaSecondGroup, field.searchCriteriaFirstGroup,
0, 0,
1, field.responseValueFirstGroup
operator.index, );
CONDITIONS_MUST.equalTo.filter, });
CONDITIONS_MUST_NOT.notEqualTo.filter, });
field.responseValueFirstGroup, });
val
); after(() => {
}); cy.logout();
}); Cypress.session.clearAllSavedSessions();
});
it(`Verify Add Rule functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.anyIn.name} and ${CONDITIONS_MUST_NOT.notIn.name} `, () => { });
Object.values(FIELDS).forEach((field) => {
let val = field.searchCriteriaSecondGroup; describe('Group search', () => {
if (field.owner) { beforeEach(() => {
val = field.responseValueSecondGroup; cy.login();
} });
checkAddRuleWithOperator(
CONDITIONS_MUST.anyIn.name, Object.values(OPERATOR).forEach((operator) => {
CONDITIONS_MUST_NOT.notIn.name, it(`Verify Add group functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.equalTo.name} and ${CONDITIONS_MUST_NOT.notEqualTo.name} `, () => {
field.testid, Object.values(FIELDS).forEach((field) => {
field.searchCriteriaFirstGroup, let val = field.searchCriteriaSecondGroup;
field.searchCriteriaSecondGroup, if (field.owner) {
0, val = field.responseValueSecondGroup;
1, }
operator.index, checkAddGroupWithOperator(
CONDITIONS_MUST.anyIn.filter, CONDITIONS_MUST.equalTo.name,
CONDITIONS_MUST_NOT.notIn.filter, CONDITIONS_MUST_NOT.notEqualTo.name,
field.responseValueFirstGroup, field.testid,
val field.searchCriteriaFirstGroup,
); field.searchCriteriaSecondGroup,
}); 0,
}); 1,
operator.index,
it(`Verify Add Rule functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.contains.name} and ${CONDITIONS_MUST_NOT.notContains.name} `, () => { CONDITIONS_MUST.equalTo.filter,
Object.values(FIELDS).forEach((field) => { CONDITIONS_MUST_NOT.notEqualTo.filter,
let val = field.searchCriteriaSecondGroup; field.responseValueFirstGroup,
checkAddRuleWithOperator( val
CONDITIONS_MUST.contains.name, );
CONDITIONS_MUST_NOT.notContains.name, });
field.testid, });
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup, it(`Verify Add group functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.anyIn.name} and ${CONDITIONS_MUST_NOT.notIn.name} `, () => {
0, Object.values(FIELDS).forEach((field) => {
1, let val = field.searchCriteriaSecondGroup;
operator.index, if (field.owner) {
CONDITIONS_MUST.contains.filter, val = field.responseValueSecondGroup;
CONDITIONS_MUST_NOT.notContains.filter, }
field.responseValueFirstGroup, checkAddGroupWithOperator(
val CONDITIONS_MUST.anyIn.name,
); CONDITIONS_MUST_NOT.notIn.name,
}); field.testid,
}); field.searchCriteriaFirstGroup,
}); field.searchCriteriaSecondGroup,
0,
it('Delete Created Service', () => { 1,
deleteCreatedService( operator.index,
MYSQL.database, CONDITIONS_MUST.anyIn.filter,
service_name, CONDITIONS_MUST_NOT.notIn.filter,
API_SERVICE.databaseServices field.responseValueFirstGroup,
); val
}); );
});
after(() => { });
Cypress.session.clearAllSavedSessions();
it(`Verify Add group functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.contains.name} and ${CONDITIONS_MUST_NOT.notContains.name} `, () => {
Object.values(FIELDS).forEach((field) => {
let val = field.searchCriteriaSecondGroup;
checkAddGroupWithOperator(
CONDITIONS_MUST.contains.name,
CONDITIONS_MUST_NOT.notContains.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.contains.filter,
CONDITIONS_MUST_NOT.notContains.filter,
field.responseValueFirstGroup,
val
);
});
});
});
after(() => {
cy.logout();
Cypress.session.clearAllSavedSessions();
});
});
describe('Search with additional rule', () => {
beforeEach(() => {
cy.login();
});
Object.values(OPERATOR).forEach((operator) => {
it(`Verify Add Rule functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.equalTo.name} and ${CONDITIONS_MUST_NOT.notEqualTo.name} `, () => {
Object.values(FIELDS).forEach((field) => {
let val = field.searchCriteriaSecondGroup;
if (field.owner) {
val = field.responseValueSecondGroup;
}
checkAddRuleWithOperator(
CONDITIONS_MUST.equalTo.name,
CONDITIONS_MUST_NOT.notEqualTo.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.equalTo.filter,
CONDITIONS_MUST_NOT.notEqualTo.filter,
field.responseValueFirstGroup,
val
);
});
});
it(`Verify Add Rule functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.anyIn.name} and ${CONDITIONS_MUST_NOT.notIn.name} `, () => {
Object.values(FIELDS).forEach((field) => {
let val = field.searchCriteriaSecondGroup;
if (field.owner) {
val = field.responseValueSecondGroup;
}
checkAddRuleWithOperator(
CONDITIONS_MUST.anyIn.name,
CONDITIONS_MUST_NOT.notIn.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.anyIn.filter,
CONDITIONS_MUST_NOT.notIn.filter,
field.responseValueFirstGroup,
val
);
});
});
it(`Verify Add Rule functionality for All with ${operator.name} operator & condition ${CONDITIONS_MUST.contains.name} and ${CONDITIONS_MUST_NOT.notContains.name} `, () => {
Object.values(FIELDS).forEach((field) => {
let val = field.searchCriteriaSecondGroup;
checkAddRuleWithOperator(
CONDITIONS_MUST.contains.name,
CONDITIONS_MUST_NOT.notContains.name,
field.testid,
field.searchCriteriaFirstGroup,
field.searchCriteriaSecondGroup,
0,
1,
operator.index,
CONDITIONS_MUST.contains.filter,
CONDITIONS_MUST_NOT.notContains.filter,
field.responseValueFirstGroup,
val
);
});
});
});
after(() => {
cy.logout();
Cypress.session.clearAllSavedSessions();
});
}); });
}); });

View File

@ -210,18 +210,14 @@ describe('SearchIndexDetails page should work properly for data consumer role',
}); });
// Edit domain option should not be available // Edit domain option should not be available
cy.get(`[data-testid="entity-page-header"]`).then(($body) => { cy.get(
const editDomain = $body.find(`[data-testid="add-domain"]`); `[data-testid="entity-page-header"] [data-testid="add-domain"]`
).should('not.exist');
expect(editDomain.length).to.equal(0);
});
// Manage button should not be visible on service page // Manage button should not be visible on service page
cy.get('[data-testid="asset-header-btn-group"]').then(($body) => { cy.get(
const manageButton = $body.find(`[data-testid="manage-button"]`); '[data-testid="asset-header-btn-group"] [data-testid="manage-button"]'
).should('not.exist');
expect(manageButton.length).to.equal(0);
});
performCommonOperations(); performCommonOperations();
}); });
@ -376,31 +372,17 @@ describe('SearchIndexDetails page should work properly for admin role', () => {
cy.get('[data-testid="deleted-badge"]').should('be.visible'); cy.get('[data-testid="deleted-badge"]').should('be.visible');
// Edit options for domain owner and tier should not be visible // Edit options for domain owner and tier should not be visible
cy.get(`[data-testid="entity-page-header"]`).then(($body) => { cy.get('[data-testid="add-domain"]').should('not.exist');
const editDomain = $body.find(`[data-testid="add-domain"]`); cy.get('[data-testid="edit-owner"]').should('not.exist');
const editOwner = $body.find(`[data-testid="edit-owner"]`); cy.get('[data-testid="edit-tier"]').should('not.exist');
const editTier = $body.find(`[data-testid="edit-tier"]`);
expect(editDomain.length).to.equal(0);
expect(editOwner.length).to.equal(0);
expect(editTier.length).to.equal(0);
});
// Edit description button should not be visible // Edit description button should not be visible
cy.get(`[data-testid="asset-description-container"]`).then(($body) => { cy.get('[data-testid="edit-description"]').should('not.exist');
const editDescription = $body.find(`[data-testid="edit-description"]`);
expect(editDescription.length).to.equal(0);
});
// Edit tags button should not be visible // Edit tags button should not be visible
cy.get( cy.get(
`[data-testid="entity-right-panel"] [data-testid="tags-container"]` `[data-testid="entity-right-panel"] [data-testid="tags-container"] [data-testid="add-tag"]`
).then(($body) => { ).should('not.exist');
const addTag = $body.find(`[data-testid="add-tag"]`);
expect(addTag.length).to.equal(0);
});
// Edit description and tags button for fields should not be visible // Edit description and tags button for fields should not be visible
cy.get( cy.get(

View File

@ -91,14 +91,21 @@ export const AdvancedSearchModal: FunctionComponent<Props> = ({
destroyOnClose destroyOnClose
className="advanced-search-modal" className="advanced-search-modal"
closeIcon={null} closeIcon={null}
data-testid="advanced-search-modal"
footer={ footer={
<Space className="justify-between w-full"> <Space className="justify-between w-full">
<Button className="float-right" size="small" onClick={onReset}> <Button
className="float-right"
data-testid="reset-btn"
size="small"
onClick={onReset}>
{t('label.reset')} {t('label.reset')}
</Button> </Button>
<div> <div>
<Button onClick={onCancel}>{t('label.cancel')}</Button> <Button data-testid="cancel-btn" onClick={onCancel}>
<Button type="primary" onClick={onSubmit}> {t('label.cancel')}
</Button>
<Button data-testid="apply-btn" type="primary" onClick={onSubmit}>
{t('label.apply')} {t('label.apply')}
</Button> </Button>
</div> </div>