Fixed: Custom property failing cypress test (#8460)

* Custom property cypress

* testing out entity topic name

* Fixed Custom property topic search issue

* removed import of deleted file
This commit is contained in:
Shailesh Parmar 2022-11-01 09:46:01 +05:30 committed by GitHub
parent e7a4a7a3e5
commit e68f35ec85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 45 deletions

View File

@ -683,8 +683,7 @@ export const addCustomPropertiesForEntity = (
entityType, entityType,
customType, customType,
value, value,
entityObj, entityObj
entityName
) => { ) => {
const propertyName = `entity${entityType.name}test${uuid()}`; const propertyName = `entity${entityType.name}test${uuid()}`;
@ -713,7 +712,7 @@ export const addCustomPropertiesForEntity = (
//Checking the added property in Entity //Checking the added property in Entity
visitEntityDetailsPage( visitEntityDetailsPage(
entityName || entityObj.term, entityObj.term,
entityObj.serviceName, entityObj.serviceName,
entityObj.entity entityObj.entity
); );

View File

@ -11,7 +11,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { addCustomPropertiesForEntity, deleteCreatedProperty, editCreatedProperty, interceptURL, login, verifyResponseStatusCode } from '../../common/common'; import {
addCustomPropertiesForEntity,
deleteCreatedProperty,
editCreatedProperty,
interceptURL,
login,
verifyResponseStatusCode
} from '../../common/common';
import { ENTITIES, LOGIN } from '../../constants/constants'; import { ENTITIES, LOGIN } from '../../constants/constants';
describe('Custom Properties should work properly', () => { describe('Custom Properties should work properly', () => {
@ -33,8 +40,6 @@ describe('Custom Properties should work properly', () => {
Object.values(ENTITIES).forEach((entity) => { Object.values(ENTITIES).forEach((entity) => {
it(`Add Integer custom property for ${entity.name} Entities`, () => { it(`Add Integer custom property for ${entity.name} Entities`, () => {
cy.getSearchQueryName(entity.name).then((entityName) => {
interceptURL( interceptURL(
'GET', 'GET',
`/api/v1/metadata/types/name/${entity.name}*`, `/api/v1/metadata/types/name/${entity.name}*`,
@ -54,8 +59,7 @@ describe('Custom Properties should work properly', () => {
entity, entity,
'integer', 'integer',
entity.integerValue, entity.integerValue,
entity.entityObj, entity.entityObj
entityName
); );
//Navigating back to custom properties page //Navigating back to custom properties page
cy.get('[data-testid="appbar-item-settings"]') cy.get('[data-testid="appbar-item-settings"]')
@ -72,10 +76,8 @@ describe('Custom Properties should work properly', () => {
deleteCreatedProperty(propertyName); deleteCreatedProperty(propertyName);
}); });
})
}); });
Object.values(ENTITIES).forEach((entity) => { Object.values(ENTITIES).forEach((entity) => {
it(`Add String custom property for ${entity.name} Entities`, () => { it(`Add String custom property for ${entity.name} Entities`, () => {
interceptURL( interceptURL(

View File

@ -16,7 +16,6 @@
// Import commands.js using ES2015 syntax: // Import commands.js using ES2015 syntax:
import 'cypress-localstorage-commands'; import 'cypress-localstorage-commands';
import './commands'; import './commands';
import './get-search-query.command';
// Alternatively you can use CommonJS syntax: // Alternatively you can use CommonJS syntax:
// require('./commands') // require('./commands')

View File

@ -1,33 +0,0 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Cypress.Commands.add('getSearchQueryName', (entityName) => {
cy.getLocalStorage("oidcIdToken").then((token) => {
cy.request({
method: 'GET',
url: `/api/v1/search/query?q=*&from=0&size=10&sort_field=updatedAt&sort_order=desc&index=${entityName}_search_index`,
headers: {
Authorization: `Bearer ${token}`
}
}).then((response) => {
if (response && response.body && response.body.hits) {
const entitySource = response.body.hits.hits[0]._source;
const name = entitySource.name || entitySource.displayName;
return name;
}
})
});
});