Cypress: E2E test for glossary page (#5232)

This commit is contained in:
Shailesh Parmar 2022-06-01 11:36:36 +05:30 committed by GitHub
parent 987ea13c2a
commit e51b50825f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 514 additions and 58 deletions

View File

@ -284,3 +284,54 @@ export const testSampleData = (entity) => {
cy.get('[data-testid="Sample Data"]').should('be.visible').click();
cy.contains('No sample data available').should('not.exist');
};
// add new tag to entity and its table
export const addNewTagToEntity = (entity, term) => {
searchEntity(entity);
cy.wait(500);
cy.get('[data-testid="table-link"]').first().contains(entity).click();
cy.get(
'[data-testid="tags-wrapper"] > [data-testid="tag-container"] > .tw-flex > :nth-child(1) > [data-testid="tags"] > .tw-no-underline'
)
.should('be.visible')
.scrollIntoView()
.click();
cy.get('[data-testid="tags-wrapper"] > [data-testid="tag-container"]').should(
'be.visible'
);
cy.get('[data-testid="associatedTagName"]').should('be.visible').type(term);
cy.get('[data-testid="list-item"] > .tw-truncate')
.should('be.visible')
.click();
cy.get(
'[data-testid="tags-wrapper"] > [data-testid="tag-container"]'
).contains(term);
cy.get('[data-testid="saveAssociatedTag"]').should('be.visible').click();
cy.get('[data-testid="entity-tags"]')
.scrollIntoView()
.should('be.visible')
.contains(term);
cy.get('[data-testid="table-body"] > :nth-child(1) > :nth-child(5)')
.contains('Add tag')
.should('be.visible')
.click();
cy.get(
':nth-child(1) > :nth-child(5) > [data-testid="tags-wrapper"] > :nth-child(1) > :nth-child(1) > [data-testid="tag-container"]'
).should('be.visible');
cy.get('[data-testid="associatedTagName"]')
.scrollIntoView()
.should('be.visible')
.type(term);
cy.get('#menu-item-0 > .tw-truncate').should('be.visible').click();
cy.get('[data-testid="saveAssociatedTag"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="table-body"] > :nth-child(1) > :nth-child(5)')
.scrollIntoView()
.contains(term)
.should('exist');
};

View File

@ -161,3 +161,20 @@ export const NEW_TAG = {
name: 'test',
description: 'This is the Test tag',
};
export const NEW_GLOSSARY = {
name: 'Business Glossary',
description: 'This is the Business glossary',
};
export const NEW_GLOSSARY_TERMS = {
term_1: {
name: 'Purchase',
description: 'This is the Purchase',
synonyms: 'buy,collect,acquire',
},
term_2: {
name: 'Sales',
description: 'This is the Sales',
synonyms: 'give,disposal,deal',
},
};

View File

@ -0,0 +1,428 @@
/*
* 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.
*/
import { addNewTagToEntity } from '../../common/common';
import { DELETE_TERM, NEW_GLOSSARY, NEW_GLOSSARY_TERMS, SEARCH_ENTITY_TABLE } from '../../constants/constants';
const createGlossaryTerm = (term) => {
cy.get('[data-testid="header"]')
.should('be.visible')
.contains(NEW_GLOSSARY.name)
.should('exist');
cy.get('[data-testid="add-new-tag-button"]').should('be.visible').click();
cy.contains('Add Glossary Term').should('be.visible');
cy.get('[data-testid="name"]')
.scrollIntoView()
.should('be.visible')
.type(term.name);
cy.get('.toastui-editor-md-container > .toastui-editor > .ProseMirror')
.scrollIntoView()
.should('be.visible')
.type(term.description);
cy.get('[data-testid="synonyms"]')
.scrollIntoView()
.should('be.visible')
.type(term.synonyms);
cy.get('[data-testid="references"] > .tw-flex > .button-comp')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('#name-0').scrollIntoView().should('be.visible').type('test');
cy.get('#url-0')
.scrollIntoView()
.should('be.visible')
.type('https://test.com');
cy.get('[data-testid="save-glossary-term"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.wait(200);
cy.get('#left-panel').contains(term.name).should('be.visible');
};
const deleteGlossaryTerm = ({ name }) => {
cy.get('#left-panel').contains(name).should('be.visible').click();
cy.wait(500);
cy.get('[data-testid="inactive-link"]').contains(name).should('be.visible');
cy.get('[data-testid="Manage"]').should('be.visible').click();
cy.get('[data-testid="delete-button"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.get('[data-testid="confirmation-text-input"]')
.should('be.visible')
.type(DELETE_TERM);
cy.get('[data-testid="confirm-button"]')
.should('be.visible')
.should('not.disabled')
.click();
cy.get('.Toastify__toast-body')
.contains('Glossary Term deleted successfully!')
.should('be.visible');
cy.get('.Toastify__close-button > svg > path').should('be.visible').click();
cy.wait(500);
};
const goToAssetsTab = (term) => {
cy.get('#left-panel').should('be.visible').contains(term).click();
cy.wait(500);
cy.get('[data-testid="inactive-link"]').contains(term).should('be.visible');
cy.get('[data-testid="Assets"]').should('be.visible').click();
cy.get('[data-testid="Assets"]').should('have.class', 'active');
};
describe('Glossary page should work properly', () => {
beforeEach(() => {
cy.goToHomePage();
// redirecting to glossary page
cy.get(
'.tw-ml-5 > [data-testid="dropdown-item"] > div > [data-testid="menu-button"]'
)
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="menu-item-Glossaries"]').should('be.visible').click();
// Todo: need to remove below uncaught exception once tree-view error resolves
cy.on('uncaught:exception', () => {
// return false to prevent the error from
// failing this test
return false;
});
});
it('Create new glossary flow should work properly', () => {
// check for no data placeholder
cy.contains('No glossaries found').should('be.visible');
// Redirecting to add glossary page
cy.get('[data-testid="add-webhook-button"]').should('be.visible').click();
cy.get('#center > .tw-heading')
.contains('Add Glossary')
.should('be.visible');
cy.get('[data-testid="name"]')
.scrollIntoView()
.should('be.visible')
.type(NEW_GLOSSARY.name);
cy.get('.toastui-editor-md-container > .toastui-editor > .ProseMirror')
.scrollIntoView()
.should('be.visible')
.type(NEW_GLOSSARY.description);
cy.get('[data-testid="add-reviewers"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.get('.tw-grid > [data-testid="user-card-container"]')
.first()
.should('be.visible')
.as('reviewer');
cy.get('@reviewer')
.find('[data-testid="checkboxAddUser"]')
.should('be.visible')
.check();
cy.get('[data-testid="saveButton"]').should('be.visible').click();
cy.get('.tw-modal-container').should('not.exist');
cy.get('[data-testid="reviewers-container"]')
.children()
.should('have.length', 1);
cy.get('[data-testid="save-glossary"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="inactive-link"]')
.should('be.visible')
.invoke('text')
.then((text) => {
expect(text).to.equal(NEW_GLOSSARY.name);
});
});
it('Create glossary term should work properly', () => {
const terms = Object.values(NEW_GLOSSARY_TERMS);
terms.forEach(createGlossaryTerm);
});
it('Updating data of glossary should work properly', () => {
const newDescription = 'Updated description';
// updating tags
cy.get('[data-testid="tag-container"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="associatedTagName"]')
.scrollIntoView()
.should('be.visible')
.type('personal');
cy.get('[data-testid="dropdown-list"] > .tw-py-1')
.scrollIntoView()
.should('be.visible');
cy.get('#menu-item-0').scrollIntoView().click();
cy.get('[data-testid="saveAssociatedTag"]').scrollIntoView().click();
cy.get('[data-testid="glossary-details"]')
.scrollIntoView()
.contains('PersonalData.Personal')
.should('be.visible');
// updating description
cy.get('[data-testid="edit-description"] > [data-testid="image"]')
.should('be.visible')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.get('.toastui-editor-md-container > .toastui-editor > .ProseMirror')
.should('be.visible')
.as('description');
cy.get('@description').clear();
cy.get('@description').type(newDescription);
cy.get('[data-testid="save"]').click();
cy.get('.tw-modal-container').should('not.exist');
cy.get('[data-testid="viewer-container"]')
.contains(newDescription)
.should('be.visible');
});
it('Updating data of glossary term should work properly', () => {
const term = NEW_GLOSSARY_TERMS.term_1.name;
const uSynonyms = 'pick up,take,obtain';
const newRef = { name: 'take', url: 'https://take.com' };
const newDescription = 'Updated description';
cy.get('#left-panel').should('be.visible').contains(term).click();
cy.wait(500);
cy.get('[data-testid="inactive-link"]').contains(term).should('be.visible');
// updating synonyms
cy.get('[data-testid="edit-synonyms"] > [data-testid="image"]')
.should('exist')
.click();
cy.get('[data-testid="synonyms"]')
.scrollIntoView()
.should('be.visible')
.as('synonyms');
cy.get('@synonyms').clear();
cy.get('@synonyms').type(uSynonyms);
cy.get('[data-testid="saveAssociatedTag"]').should('be.visible').click();
cy.get('[data-testid="glossary-term"] > :nth-child(1)')
.contains(uSynonyms)
.should('be.visible');
// updating References
cy.get('[data-testid="edit-reference"] > [data-testid="image"]')
.should('exist')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.get('[data-testid="references"] > :nth-child(1) > .button-comp')
.should('be.visible')
.click();
cy.get('#name-1').should('be.visible').type(newRef.name);
cy.get('#url-1').should('be.visible').type(newRef.url);
cy.get('[data-testid="saveButton"]').should('be.visible').click();
cy.get('[data-testid="glossary-term"] > :nth-child(2)')
.contains(newRef.name)
.should('be.visible')
.invoke('attr', 'href')
.should('eq', newRef.url);
// updating tags
cy.get('[data-testid="tag-container"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="associatedTagName"]')
.scrollIntoView()
.should('be.visible')
.type('personal');
cy.get('[data-testid="dropdown-list"] > .tw-py-1')
.scrollIntoView()
.should('be.visible');
cy.get('#menu-item-0').scrollIntoView().click();
cy.get('[data-testid="saveAssociatedTag"]').scrollIntoView().click();
cy.get('[data-testid="glossary-term"]')
.scrollIntoView()
.contains('PersonalData.Personal')
.should('be.visible');
// updating description
cy.get('[data-testid="edit-description"] > [data-testid="image"]')
.should('be.visible')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.get('.toastui-editor-md-container > .toastui-editor > .ProseMirror')
.should('be.visible')
.as('description');
cy.get('@description').clear();
cy.get('@description').type(newDescription);
cy.get('[data-testid="save"]').click();
cy.get('.tw-modal-container').should('not.exist');
cy.get('[data-testid="viewer-container"]')
.contains(newDescription)
.should('be.visible');
});
it('Releted Terms should work properly', () => {
const term = NEW_GLOSSARY_TERMS.term_1.name;
const term2 = NEW_GLOSSARY_TERMS.term_2.name;
cy.get('#left-panel').should('be.visible').contains(term).click();
cy.wait(500);
cy.get('[data-testid="inactive-link"]').contains(term).should('be.visible');
// add releted term
cy.get('[data-testid="add-related-term-button"]')
.should('be.visible')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.wait(500);
cy.get('[data-testid="user-card-container"]')
.should('be.visible')
.find('[data-testid="checkboxAddUser"]')
.check();
cy.get('[data-testid="saveButton"]').should('be.visible').click();
cy.get('.tw-modal-container').should('not.exist');
cy.get('.tableBody-row > :nth-child(1)')
.contains(term2)
.should('be.visible');
});
it('Assets Tab should work properly', () => {
const term = NEW_GLOSSARY_TERMS.term_1.name;
const entity = SEARCH_ENTITY_TABLE.table_3.term;
goToAssetsTab(term);
cy.get('.tableBody-cell')
.contains('No assets available.')
.should('be.visible');
addNewTagToEntity(entity, term);
cy.get(
'.tw-ml-5 > [data-testid="dropdown-item"] > div > [data-testid="menu-button"]'
)
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="menu-item-Glossaries"]').should('be.visible').click();
goToAssetsTab(term);
cy.get('[data-testid="column"] > :nth-child(1)')
.contains(entity)
.should('be.visible');
});
it('Remove Glossary term from entity should work properly', () => {
const term = NEW_GLOSSARY_TERMS.term_1.name;
const entity = SEARCH_ENTITY_TABLE.table_3.term;
// go assets tab
goToAssetsTab(term);
cy.get('[data-testid="column"] > :nth-child(1) > a')
.contains(entity)
.should('be.visible')
.click();
cy.wait(500);
// redirect to entity detail page
cy.get(
'[data-testid="tags-wrapper"] > [data-testid="tag-container"] > .tw-flex > .tw-ml-1 > [data-testid="image"]'
)
.scrollIntoView()
.should('be.visible')
.click();
cy.get(':nth-child(1) > [data-testid="remove"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get(':nth-child(1) > [data-testid="remove"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="saveAssociatedTag"]').scrollIntoView().click();
cy.get(
'[data-testid="tag-container"] > .tw-flex > .tw-opacity-0 > [data-testid="image"]'
)
.scrollIntoView()
.should('exist')
.click();
cy.get(':nth-child(1) > [data-testid="remove"]')
.scrollIntoView()
.should('exist')
.click();
cy.get(':nth-child(1) > [data-testid="remove"]')
.scrollIntoView()
.should('exist')
.click();
cy.get('[data-testid="saveAssociatedTag"]').scrollIntoView().click();
cy.get(
'.tw-ml-5 > [data-testid="dropdown-item"] > div > [data-testid="menu-button"]'
)
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="menu-item-Glossaries"]').should('be.visible').click();
cy.wait(500);
goToAssetsTab(term);
cy.get('.tableBody-cell')
.contains('No assets available.')
.should('be.visible');
});
it('Delete glossary term should work properly', () => {
const terms = Object.values(NEW_GLOSSARY_TERMS);
terms.forEach(deleteGlossaryTerm);
});
it('Delete glossary should work properly', () => {
cy.get('[data-testid="header"]')
.should('be.visible')
.contains(NEW_GLOSSARY.name)
.should('exist');
cy.get('[data-testid="delete-button"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('.tw-modal-container').should('be.visible');
cy.get('[data-testid="confirmation-text-input"]')
.should('be.visible')
.type(DELETE_TERM);
cy.get('[data-testid="confirm-button"]')
.should('be.visible')
.should('not.disabled')
.click();
cy.get('.Toastify__toast-body')
.contains('Glossary deleted successfully!')
.should('be.visible');
cy.get('.Toastify__close-button > svg > path').should('be.visible').click();
cy.wait(500);
cy.contains('No glossaries found').should('be.visible');
});
});

View File

@ -11,7 +11,7 @@
* limitations under the License.
*/
import { searchEntity } from '../../common/common';
import { addNewTagToEntity } from '../../common/common';
import { NEW_TAG, NEW_TAG_CATEGORY, SEARCH_ENTITY_TABLE } from '../../constants/constants';
describe('Tags page should work', () => {
@ -91,56 +91,8 @@ describe('Tags page should work', () => {
});
it('Use newly created tag to any entity should work', () => {
const term = SEARCH_ENTITY_TABLE.table_2.term;
searchEntity(term);
cy.wait(500);
cy.get('[data-testid="table-link"]').first().contains(term).click();
cy.get(
'[data-testid="tags-wrapper"] > [data-testid="tag-container"] > .tw-flex > :nth-child(1) > [data-testid="tags"] > .tw-no-underline'
)
.should('be.visible')
.scrollIntoView()
.click();
cy.get(
'[data-testid="tags-wrapper"] > [data-testid="tag-container"]'
).should('be.visible');
cy.get('[data-testid="associatedTagName"]')
.should('be.visible')
.type(`${NEW_TAG_CATEGORY.name}.${NEW_TAG.name}`);
cy.get('[data-testid="list-item"] > .tw-truncate')
.should('be.visible')
.click();
cy.get(
'[data-testid="tags-wrapper"] > [data-testid="tag-container"]'
).contains(`${NEW_TAG_CATEGORY.name}.${NEW_TAG.name}`);
cy.get('[data-testid="saveAssociatedTag"]').should('be.visible').click();
cy.get('[data-testid="entity-tags"]')
.scrollIntoView()
.should('be.visible')
.contains(`#${NEW_TAG_CATEGORY.name}.${NEW_TAG.name}`);
cy.get('[data-testid="table-body"] > :nth-child(1) > :nth-child(5)')
.contains('Add tag')
.should('be.visible')
.click();
cy.get(
':nth-child(1) > :nth-child(5) > [data-testid="tags-wrapper"] > :nth-child(1) > :nth-child(1) > [data-testid="tag-container"]'
).should('be.visible');
cy.get('[data-testid="associatedTagName"]')
.scrollIntoView()
.should('be.visible')
.type(`${NEW_TAG_CATEGORY.name}.${NEW_TAG.name}`);
cy.get('#menu-item-0 > .tw-truncate').should('be.visible').click();
cy.get('[data-testid="saveAssociatedTag"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="table-body"] > :nth-child(1) > :nth-child(5)')
.scrollIntoView()
.contains(`#${NEW_TAG_CATEGORY.name}.${NEW_TAG.name}`)
.should('exist');
const entity = SEARCH_ENTITY_TABLE.table_2.term;
addNewTagToEntity(entity, `${NEW_TAG_CATEGORY.name}.${NEW_TAG.name}`);
});
it('Check Usage of tag and it should redirect to explore page with tags filter', () => {

View File

@ -151,6 +151,7 @@ describe('TeamsAndUsers page', () => {
cy.get(
'.tw-modal-body > [data-testid="search-bar-container"] > .tw-flex > [data-testid="searchbar"]'
)
.scrollIntoView()
.should('be.visible')
.type(searchString);
@ -204,7 +205,10 @@ describe('TeamsAndUsers page', () => {
.invoke('text')
.then((name) => {
cy.get('[data-testid="dropdown-item"] > .tw-z-10').click();
cy.get('[data-testid="searchbar"]').should('be.visible').type(name);
cy.get('[data-testid="searchbar"]')
.scrollIntoView()
.should('be.visible')
.type(name);
cy.get('.tw-grid > [data-testid="user-card-container"]')
.should('be.visible')
.contains(name)
@ -285,7 +289,7 @@ describe('TeamsAndUsers page', () => {
cy.get('[data-testid="Manage"]').should('be.visible').click();
cy.get('[data-testid="owner-dropdown"]').should('be.visible').click();
cy.get('[data-testid="dropdown-tab"]').eq(0).should('exist').click();
cy.get('[data-testid="list-item"] > .tw-truncate')
@ -422,7 +426,9 @@ describe('TeamsAndUsers page', () => {
cy.get('[data-testid="save-user"]').should('be.visible').click();
cy.get('[data-testid="searchbar"]')
.scrollIntoView()
.should('be.visible')
.click()
.type(NEW_USER.display_name);
cy.wait(500);
@ -448,6 +454,7 @@ describe('TeamsAndUsers page', () => {
'activeCategory'
);
cy.get('[data-testid="searchbar"]')
.scrollIntoView()
.should('be.visible')
.type(NEW_USER.display_name);
@ -465,13 +472,14 @@ describe('TeamsAndUsers page', () => {
cy.get('.tw-modal-container').should('be.visible');
cy.contains('Are you sure you want to delete').should('be.visible');
cy.get('[data-testid="save-button"]').should('be.visible').click();
cy.get('.tw-modal-container').should('not.exist');
cy.reload();
cy.get('[data-testid="searchbar"]')
.scrollIntoView()
.should('be.visible')
.type(NEW_USER.display_name);
cy.wait(500);
cy.get('[data-testid="no-data-image"]').should('be.visible');
cy.contains('No user available').should('be.visible');
});

View File

@ -240,7 +240,7 @@ const AddGlossary = ({
<FontAwesomeIcon icon="plus" />
</Button>
</div>
<div className="tw-my-4">
<div className="tw-my-4" data-testid="reviewers-container">
{Boolean(reviewer.length) &&
reviewer.map((d, index) => {
return (

View File

@ -336,7 +336,7 @@ const GlossaryTermsV1 = ({
className={classNames('tw-h-8 tw-rounded', {
'tw-opacity-40': isHasAccess,
})}
data-testid="add-new-tag-button"
data-testid="add-related-term-button"
size="small"
theme="primary"
variant="contained"
@ -500,7 +500,7 @@ const GlossaryTermsV1 = ({
<NonAdminAction position="right" title={TITLE_FOR_NON_ADMIN_ACTION}>
<button
className="tw-opacity-0 tw-ml-2 group-hover:tw-opacity-100 focus:tw-outline-none"
data-testid="edit-synonyms"
data-testid="edit-reference"
onClick={() => setIsReferencesEditing(true)}>
<SVGIcons
alt="edit"