feat: added cypress flow of add and remove owner and tier (#11419)

* feat: added cypress flow of add and remove owner and tier

* fixed failing cypress for service page

* fixed entitydetails spec failure

* addressing comment
This commit is contained in:
Shailesh Parmar 2023-05-04 17:36:24 +05:30 committed by GitHub
parent 6ddf7034ae
commit 4bcc7d9eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 440 additions and 76 deletions

View File

@ -137,7 +137,7 @@ export const SEARCH_ENTITY_MLMODEL = {
export const DELETE_ENTITY = {
table: {
term: 'fact_sale',
term: 'dim.shop',
entity: MYDATA_SUMMARY_OPTIONS.tables,
serviceName: 'sample_data',
},

View File

@ -0,0 +1,405 @@
/*
* Copyright 2023 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.
*/
// / <reference types="Cypress" />
import {
descriptionBox,
interceptURL,
verifyResponseStatusCode,
visitEntityDetailsPage,
} from '../../common/common';
import {
DELETE_TERM,
SEARCH_ENTITY_DASHBOARD,
SEARCH_ENTITY_MLMODEL,
SEARCH_ENTITY_PIPELINE,
SEARCH_ENTITY_TABLE,
SEARCH_ENTITY_TOPIC,
} from '../../constants/constants';
const ENTITIES = {
table: {
...SEARCH_ENTITY_TABLE.table_4,
schema: 'shopify',
database: 'ecommerce_db',
},
topic: SEARCH_ENTITY_TOPIC.topic_2,
dashboard: SEARCH_ENTITY_DASHBOARD.dashboard_2,
pipeline: SEARCH_ENTITY_PIPELINE.pipeline_2,
mlmodel: SEARCH_ENTITY_MLMODEL.mlmodel_2,
};
const glossary = 'GlossaryOwnerTest';
const glossaryTerm = 'GlossaryTermOwnerTest';
const OWNER = 'Aaron Johnson';
const TIER = 'Tier1';
const addRemoveOwner = () => {
cy.get('[data-testid="edit-owner"]').should('be.visible').click();
verifyResponseStatusCode('@getTeams', 200);
cy.get('.ant-tabs [id*=tab-users]').should('be.visible').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get(`.ant-tabs [title="${OWNER}"]`).should('be.visible').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="Owner"]').should('be.visible').should('contain', OWNER);
cy.get('[data-testid="edit-owner"]').should('be.visible').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get('[data-testid="remove-owner"]').should('be.visible').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="Owner"]')
.should('be.visible')
.should('contain', 'No Owner');
};
const addRemoveTier = () => {
cy.get('[data-testid="edit-Tier-icon"]').should('be.visible').click();
cy.get('[data-testid="card-list"]').first().should('be.visible').as('tier1');
cy.get('@tier1')
.find('[data-testid="icon"] > [data-testid="select-tier-button"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="Tier"]').should('be.visible').should('contain', TIER);
cy.get('[data-testid="edit-Tier-icon"]').should('be.visible').click();
cy.get('[data-testid="card-list"]').first().should('be.visible').as('tier1');
cy.get('@tier1')
.find('[data-testid="icon"] > [data-testid="remove-tier"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="Tier"]')
.should('be.visible')
.should('contain', 'No Tier');
};
describe('Add and Remove Owner and Tier', () => {
beforeEach(() => {
interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission');
interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'activityFeed');
interceptURL(
'GET',
'/api/v1/search/query?q=**teamType:Group&from=0&size=15&index=team_search_index',
'getTeams'
);
interceptURL('GET', '/api/v1/users?&isBot=false&limit=15', 'getUsers');
cy.login();
});
Object.entries(ENTITIES).map(([key, value]) => {
it(`${key} details page`, () => {
interceptURL('PATCH', `/api/v1/${value.entity}/*`, 'patchOwner');
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@activityFeed', 200);
addRemoveOwner();
});
});
it('databaseSchema details page', () => {
interceptURL('PATCH', '/api/v1/databaseSchemas/*', 'patchOwner');
interceptURL('GET', '/api/v1/*/name/*', 'schemaDetails');
const value = ENTITIES.table;
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@activityFeed', 200);
cy.get('[data-testid="breadcrumb"]')
.should('be.visible')
.contains(value.schema)
.click();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@schemaDetails', 200);
verifyResponseStatusCode('@activityFeed', 200);
addRemoveOwner();
});
it('database details page', () => {
interceptURL('PATCH', '/api/v1/databases/*', 'patchOwner');
interceptURL('GET', '/api/v1/databases/name/*', 'databaseDetails');
const value = ENTITIES.table;
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@activityFeed', 200);
cy.get('[data-testid="breadcrumb"]')
.should('be.visible')
.contains(value.database)
.click();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@databaseDetails', 200);
verifyResponseStatusCode('@activityFeed', 200);
addRemoveOwner();
});
it('service details page', () => {
interceptURL('PATCH', '/api/v1/services/databaseServices/*', 'patchOwner');
interceptURL(
'GET',
'/api/v1/services/databaseServices/name/*',
'serviceDetails'
);
interceptURL(
'GET',
'/api/v1/services/ingestionPipelines/status',
'ingestionPipelines'
);
interceptURL('GET', '/api/v1/databases?service=*', 'databases');
const value = ENTITIES.table;
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@activityFeed', 200);
cy.get('[data-testid="breadcrumb"]')
.should('be.visible')
.contains(value.serviceName)
.click();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@ingestionPipelines', 200);
verifyResponseStatusCode('@serviceDetails', 200);
verifyResponseStatusCode('@databases', 200);
addRemoveOwner();
});
it('Test suite details page', () => {
interceptURL('PATCH', '/api/v1/dataQuality/testSuites/*', 'patchOwner');
interceptURL('GET', '/api/v1/dataQuality/testSuites?*', 'testSuites');
interceptURL(
'GET',
'/api/v1/dataQuality/testSuites/name/critical_metrics_suite?fields=*',
'testSuiteDetails'
);
interceptURL('GET', '/api/v1/dataQuality/testCases?*', 'testCases');
cy.get('[data-testid="appbar-item-data-quality"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@testSuites', 200);
cy.get('[data-testid="test-suite-critical_metrics_suite"]')
.should('be.visible')
.click();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@testSuiteDetails', 200);
verifyResponseStatusCode('@testCases', 200);
addRemoveOwner();
});
it('Teams details page', () => {
interceptURL('PATCH', '/api/v1/teams/*', 'patchOwner');
interceptURL('GET', '/api/v1/permissions/team/*', 'teamPermission');
interceptURL(
'GET',
'/api/v1/teams/name/Organization?fields=*',
'getOrganization'
);
cy.get('[data-testid="appbar-item-settings"]').should('be.visible').click();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@getOrganization', 200);
verifyResponseStatusCode('@teamPermission', 200);
cy.get('[data-testid="add-user"]').should('be.visible').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get(`.ant-popover [title="${OWNER}"]`).should('be.visible').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="entity-summary-details"]')
.should('be.visible')
.should('contain', OWNER);
cy.get('[data-testid="add-user"]').should('be.visible').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get('[data-testid="remove-owner"]').should('be.visible').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="entity-summary-details"]')
.should('be.visible')
.should('contain', 'No Owner');
});
it('Glossary details page', () => {
interceptURL('PATCH', '/api/v1/glossaries/*', 'patchOwner');
interceptURL('POST', '/api/v1/glossaries', 'createGlossary');
interceptURL('GET', '/api/v1/permissions/glossary/*', 'glossaryPermission');
interceptURL('GET', '/api/v1/glossaries?*', 'getGlossaries');
cy.get('[data-testid="governance"]').should('be.visible').click();
cy.get('[data-testid="appbar-item-glossary"]')
.should('be.visible')
.click({ waitForAnimations: true });
cy.get('[data-testid="add-placeholder-button"]')
.should('be.visible')
.click();
cy.get('[data-testid="name"]').should('be.visible').type(glossary);
cy.get(descriptionBox).scrollIntoView().should('be.visible').type(glossary);
cy.get('[data-testid="save-glossary"]')
.scrollIntoView()
.should('be.visible')
.click();
verifyResponseStatusCode('@createGlossary', 201);
verifyResponseStatusCode('@getGlossaries', 200);
verifyResponseStatusCode('@glossaryPermission', 200);
cy.get('[data-testid="edit-owner-button"]').should('be.visible').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get(`[title="${OWNER}"]`).should('be.visible').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="glossary-owner-name"]')
.should('be.visible')
.should('contain', OWNER);
// Todo: uncomment once remove owner functionality will be added in glossary
// cy.get('[data-testid="edit-owner-button"]').should('be.visible').click();
// verifyResponseStatusCode('@getUsers', 200);
// cy.get('[data-testid="remove-owner"]').should('be.visible').click();
// verifyResponseStatusCode('@patchOwner', 200);
// cy.get('[data-testid="glossary-owner-name"]')
// .should('be.visible')
// .should('contain', 'No Owner');
});
it('GlossaryTerm details page', () => {
interceptURL('PATCH', '/api/v1/glossaryTerms/*', 'patchOwner');
interceptURL('POST', '/api/v1/glossaryTerms', 'createGlossaryTerm');
interceptURL('GET', '/api/v1/permissions/glossary/*', 'glossaryPermission');
interceptURL(
'GET',
'/api/v1/permissions/glossaryTerm/*',
'glossaryTermPermission'
);
interceptURL('GET', '/api/v1/glossaries?*', 'getGlossaries');
interceptURL('GET', '/api/v1/glossaryTerms?*', 'getGlossaryTerms');
interceptURL(
'GET',
'/api/v1/glossaryTerms/name/*',
'getGlossaryTermDetails'
);
cy.get('[data-testid="governance"]').should('be.visible').click();
cy.get('[data-testid="appbar-item-glossary"]')
.should('be.visible')
.click({ waitForAnimations: true });
verifyResponseStatusCode('@getGlossaries', 200);
verifyResponseStatusCode('@glossaryPermission', 200);
cy.get('[data-testid="add-new-tag-button-header"]')
.should('be.visible')
.click();
cy.get('[data-testid="name"]').should('be.visible').type(glossaryTerm);
cy.get(descriptionBox)
.scrollIntoView()
.should('be.visible')
.type(glossaryTerm);
cy.get('[data-testid="save-glossary-term"]')
.scrollIntoView()
.should('be.visible')
.click();
verifyResponseStatusCode('@createGlossaryTerm', 201);
verifyResponseStatusCode('@getGlossaryTerms', 200);
cy.get(`[data-testid="${glossaryTerm}"]`).should('be.visible').click();
verifyResponseStatusCode('@getGlossaryTermDetails', 200);
verifyResponseStatusCode('@glossaryTermPermission', 200);
verifyResponseStatusCode('@getGlossaryTerms', 200);
cy.get('[data-testid="edit-owner-button"]').should('be.visible').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get(`[title="${OWNER}"]`).should('be.visible').click();
verifyResponseStatusCode('@patchOwner', 200);
cy.get('[data-testid="glossary-owner-name"]')
.should('be.visible')
.should('contain', OWNER);
// Todo: uncomment once remove owner functionality will be added in glossaryTerm
// cy.get('[data-testid="edit-owner-button"]').should('be.visible').click();
// verifyResponseStatusCode('@getUsers', 200);
// cy.get('[data-testid="remove-owner"]').should('be.visible').click();
// verifyResponseStatusCode('@patchOwner', 200);
// cy.get('[data-testid="glossary-owner-name"]')
// .should('be.visible')
// .should('contain', 'No Owner');
});
it('Delete glossary and glossaryTerm', () => {
interceptURL('GET', '/api/v1/permissions/glossary/*', 'glossaryPermission');
interceptURL('GET', '/api/v1/glossaries?*', 'getGlossaries');
cy.get('[data-testid="governance"]').should('be.visible').click();
cy.get('[data-testid="appbar-item-glossary"]')
.should('be.visible')
.click({ waitForAnimations: true });
verifyResponseStatusCode('@getGlossaries', 200);
verifyResponseStatusCode('@glossaryPermission', 200);
cy.get('[data-testid="manage-button"]').should('be.visible').click();
cy.get('[data-testid="delete-button"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="delete-confirmation-modal"]')
.should('exist')
.then(() => {
cy.get('[role="dialog"]').should('be.visible');
cy.get('[data-testid="modal-header"]').should('be.visible');
});
cy.get('[data-testid="modal-header"]')
.should('be.visible')
.should('contain', `Delete ${glossary}`);
cy.get('[data-testid="confirmation-text-input"]')
.should('be.visible')
.type(DELETE_TERM);
interceptURL('DELETE', '/api/v1/glossaries/*', 'getGlossary');
cy.get('[data-testid="confirm-button"]')
.should('be.visible')
.should('not.disabled')
.click();
verifyResponseStatusCode('@getGlossary', 200);
});
});
describe('Add and Remove Tier', () => {
beforeEach(() => {
interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission');
interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'activityFeed');
interceptURL(
'GET',
'/api/v1/search/query?q=**teamType:Group&from=0&size=15&index=team_search_index',
'getTeams'
);
interceptURL('GET', '/api/v1/users?&isBot=false&limit=15', 'getUsers');
cy.login();
});
Object.entries(ENTITIES).map(([key, value]) => {
it(`${key} details page`, () => {
interceptURL('PATCH', `/api/v1/${value.entity}/*`, 'patchOwner');
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@activityFeed', 200);
addRemoveTier();
});
});
it('database details page', () => {
interceptURL('PATCH', '/api/v1/databases/*', 'patchOwner');
interceptURL('GET', '/api/v1/databases/name/*', 'databaseDetails');
const value = ENTITIES.table;
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@activityFeed', 200);
cy.get('[data-testid="breadcrumb"]')
.should('be.visible')
.contains(value.database)
.click();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@databaseDetails', 200);
verifyResponseStatusCode('@activityFeed', 200);
addRemoveTier();
});
});

View File

@ -81,19 +81,16 @@ describe('Entity Details Page', () => {
.should('be.visible')
.click();
cy.get('[data-testid="message-container"]')
.first()
.scrollIntoView()
.contains(`Deleted ${singular}`)
.should('be.visible');
// data not found should be visible while redirecting to the deleted entity details page
cy.get(`[title="${value.term}"]`).should('be.visible').click();
cy.location('pathname').then((loc) => {
const fqn = loc.split('/').pop();
cy.get('.Toastify__toast-body > :nth-child(2)')
.should('be.visible')
.should('contain', `${singular} instance for ${fqn} not found`);
.should(
'contain',
`${singular} instance for ${decodeURI(fqn)} not found`
);
cy.get('.Toastify__close-button > svg')
.first()
@ -101,7 +98,9 @@ describe('Entity Details Page', () => {
.click();
cy.get('[data-testid="no-data-image"]').should('be.visible');
cy.contains(
`${Cypress._.startCase(singular)} instance for ${fqn} not found`
`${Cypress._.startCase(singular)} instance for ${decodeURI(
fqn
)} not found`
).should('be.visible');
});
cy.clickOnLogo();

View File

@ -91,7 +91,11 @@ describe('Services page should work properly', () => {
.should('be.visible')
.click();
interceptURL('PUT', '/api/v1/services/databaseServices', 'updateService');
interceptURL(
'PATCH',
'/api/v1/services/databaseServices/*',
'updateService'
);
cy.get('[data-testid="selectable-list"]')
.contains(service.Owner)

View File

@ -84,13 +84,18 @@ const GlossaryTermTab = ({
dataIndex: 'name',
key: 'name',
className: 'glossary-name-column',
render: (_, record) => (
<Link
className="hover:tw-underline tw-cursor-pointer help-text"
to={getGlossaryPath(record.fullyQualifiedName || record.name)}>
{getEntityName(record)}
</Link>
),
render: (_, record) => {
const name = getEntityName(record);
return (
<Link
className="hover:tw-underline tw-cursor-pointer help-text"
data-testid={name}
to={getGlossaryPath(record.fullyQualifiedName || record.name)}>
{name}
</Link>
);
},
},
{
title: t('label.description'),

View File

@ -95,11 +95,9 @@ const GlossaryDetailsRightPanel = ({
return (
<Card>
<Row gutter={[0, 40]}>
<Col span="24">
<Col data-testid="glossary-owner-name" span="24">
<div className="d-flex items-center m-b-xss">
<Typography.Text
className="right-panel-label"
data-testid="glossary-owner-name">
<Typography.Text className="right-panel-label">
{t('label.owner')}
</Typography.Text>
{(permissions.EditOwner || permissions.EditAll) && (

View File

@ -80,8 +80,8 @@ const TestSuiteDetails = ({
</Space>
<div className="tw-flex tw-gap-1 tw-mb-2 tw-mt-1 tw-flex-wrap">
{extraInfo.map((info, index) => (
<span className="tw-flex" key={index}>
{extraInfo.map((info) => (
<span className="tw-flex" data-testid={info.key} key={info.key}>
<EntitySummaryDetails
currentOwner={testSuite?.owner}
data={info}

View File

@ -26,6 +26,7 @@ import {
import TestCasesTab from 'components/TestCasesTab/TestCasesTab.component';
import TestSuiteDetails from 'components/TestSuiteDetails/TestSuiteDetails.component';
import TestSuitePipelineTab from 'components/TestSuitePipelineTab/TestSuitePipelineTab.component';
import { EntityInfo } from 'enums/entity.enum';
import { compare } from 'fast-json-patch';
import { camelCase, startCase } from 'lodash';
import { ExtraInfo } from 'Models';
@ -287,7 +288,7 @@ const TestSuiteDetailsPage = () => {
const extraInfo: Array<ExtraInfo> = useMemo(
() => [
{
key: 'owner',
key: EntityInfo.OWNER,
value:
testOwner?.type === 'team'
? getTeamAndUserDetailsPath(testOwner?.name || '')

View File

@ -62,11 +62,7 @@ import {
import { fetchAirflowConfig } from 'rest/miscAPI';
import { getMlModels } from 'rest/mlModelAPI';
import { getPipelines } from 'rest/pipelineAPI';
import {
getServiceByFQN,
updateOwnerService,
updateService,
} from 'rest/serviceAPI';
import { getServiceByFQN, updateOwnerService } from 'rest/serviceAPI';
import { getContainers } from 'rest/storageAPI';
import { getTopics } from 'rest/topicsAPI';
import { getEntityName } from 'utils/EntityUtils';
@ -775,10 +771,10 @@ const ServicePage: FunctionComponent = () => {
}
};
const handleRemoveOwner = async () => {
const handleUpdateOwner = async (owner: ServicesType['owner']) => {
const updatedData = {
...serviceDetails,
owner: undefined,
owner,
} as ServicesUpdateRequest;
const jsonPatch = compare(serviceDetails || {}, updatedData);
@ -799,50 +795,6 @@ const ServicePage: FunctionComponent = () => {
}
};
const handleUpdateOwner = (owner: ServicesType['owner']) => {
if (isUndefined(owner)) {
handleRemoveOwner();
return;
}
const updatedData = {
connection: serviceDetails?.connection,
name: serviceDetails?.name,
serviceType: serviceDetails?.serviceType,
owner,
description: serviceDetails?.description,
} as ServicesUpdateRequest;
return new Promise<void>((resolve, reject) => {
updateService(serviceName, serviceDetails?.id ?? '', updatedData)
.then((res) => {
if (res) {
setServiceDetails(res);
return resolve();
} else {
showErrorToast(
t('server.entity-updating-error', {
entity: t('label.owner-lowercase'),
})
);
}
return reject();
})
.catch((error: AxiosError) => {
showErrorToast(
error,
t('server.entity-updating-error', {
entity: t('label.owner-lowercase'),
})
);
return reject();
});
});
};
const onDescriptionEdit = (): void => {
setIsEdit(true);
};
@ -1158,7 +1110,7 @@ const ServicePage: FunctionComponent = () => {
<Col span={24}>
<Space>
{extraInfo.map((info) => (
<Space key={info.id}>
<Space data-testid={info.key} key={info.id}>
<EntitySummaryDetails
currentOwner={serviceDetails?.owner}
data={info}