cypress: work on e2e cypress part 1 (#12606)

* cypress: work on e2e cypress part 1

* updated Announcement cypress
This commit is contained in:
Shailesh Parmar 2023-07-26 23:53:47 +05:30 committed by GitHub
parent c71cf0ce35
commit 7be72a13f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 157 additions and 164 deletions

View File

@ -35,45 +35,32 @@ describe('Test Add role and assign it to the user', () => {
cy.get('[data-menu-id*="roles"]').should('be.visible').click(); cy.get('[data-menu-id*="roles"]').should('be.visible').click();
verifyResponseStatusCode('@getRoles', 200); verifyResponseStatusCode('@getRoles', 200);
cy.get('[data-testid="add-role"]') cy.get('[data-testid="add-role"]').contains('Add Role').click();
.contains('Add Role')
.should('be.visible')
.click();
// Asserting navigation // Asserting navigation
cy.get('[data-testid="inactive-link"]') cy.get('[data-testid="inactive-link"]').should('contain', 'Add New Role');
.should('contain', 'Add New Role')
.should('be.visible');
// Entering name // Entering name
cy.get('#name').should('be.visible').type(roleName); cy.get('#name').type(roleName);
// Entering descrription // Entering descrription
cy.get(descriptionBox).type('description'); cy.get(descriptionBox).type('description');
// Select the policies // Select the policies
cy.get('[data-testid="policies"]').should('be.visible').click(); cy.get('[data-testid="policies"]').click();
cy.get('[title="Data Consumer Policy"]') cy.get('[title="Data Consumer Policy"]').scrollIntoView().click();
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[title="Data Steward Policy"]') cy.get('[title="Data Steward Policy"]').scrollIntoView().click();
.scrollIntoView()
.should('be.visible')
.click();
// Save the role // Save the role
cy.get('[data-testid="submit-btn"]') cy.get('[data-testid="submit-btn"]').scrollIntoView().click();
.scrollIntoView()
.should('be.visible')
.click();
// Verify the role is added successfully // Verify the role is added successfully
cy.url().should('eq', `${BASE_URL}/settings/access/roles/${roleName}`); cy.url().should('eq', `${BASE_URL}/settings/access/roles/${roleName}`);
cy.get('[data-testid="inactive-link"]').should('contain', roleName); cy.get('[data-testid="inactive-link"]').should('contain', roleName);
// Verify added description // Verify added description
cy.get('[data-testid="description"] > [data-testid="viewer-container"]') cy.get(
.should('be.visible') '[data-testid="description"] > [data-testid="viewer-container"]'
.should('contain', 'description'); ).should('contain', 'description');
}); });
it('Create new user and assign new role to him', () => { it('Create new user and assign new role to him', () => {
@ -83,41 +70,23 @@ describe('Test Add role and assign it to the user', () => {
cy.get('[data-testid="add-user"]').contains('Add User').click(); cy.get('[data-testid="add-user"]').contains('Add User').click();
cy.get('[data-testid="email"]') cy.get('[data-testid="email"]').scrollIntoView().type(userEmail);
.scrollIntoView()
.should('exist')
.should('be.visible')
.type(userEmail);
cy.get('[data-testid="displayName"]') cy.get('[data-testid="displayName"]').type(userName);
.should('exist')
.should('be.visible')
.type(userName);
cy.get(descriptionBox) cy.get(descriptionBox).type('Adding user');
.should('exist')
.should('be.visible')
.type('Adding user');
interceptURL('GET', '/api/v1/users/generateRandomPwd', 'generatePassword'); interceptURL('GET', '/api/v1/users/generateRandomPwd', 'generatePassword');
cy.get('[data-testid="password-generator"]') cy.get('[data-testid="password-generator"]').scrollIntoView().click();
.scrollIntoView()
.should('be.visible')
.click();
verifyResponseStatusCode('@generatePassword', 200); verifyResponseStatusCode('@generatePassword', 200);
cy.get(`[data-testid="roles-dropdown"]`) cy.get(`[data-testid="roles-dropdown"]`).type(roleName);
.scrollIntoView() cy.get(`.ant-select-dropdown [title="${roleName}"]`).click();
.should('be.visible');
cy.get(`[data-testid="roles-dropdown"]`).click(); cy.clickOutside();
interceptURL('POST', '/api/v1/users', 'createUser');
cy.get(`[title="${roleName}"]`).scrollIntoView().should('be.visible');
cy.get(`[title="${roleName}"]`).click();
cy.get('[data-testid="roles-dropdown"]').click();
cy.get('[data-testid="save-user"]').scrollIntoView().click(); cy.get('[data-testid="save-user"]').scrollIntoView().click();
verifyResponseStatusCode('@createUser', 201);
}); });
it('Verify assigned role to new user', () => { it('Verify assigned role to new user', () => {
@ -130,13 +99,10 @@ describe('Test Add role and assign it to the user', () => {
'searchUser' 'searchUser'
); );
interceptURL('GET', '/api/v1/users/*', 'userDetailsPage'); interceptURL('GET', '/api/v1/users/*', 'userDetailsPage');
cy.get('[data-testid="searchbar"]') cy.get('[data-testid="searchbar"]').type(userName);
.should('exist')
.should('be.visible')
.type(userName);
verifyResponseStatusCode('@searchUser', 200); verifyResponseStatusCode('@searchUser', 200);
cy.get(`[data-testid="${userName}"]`).should('be.visible').click(); cy.get(`[data-testid="${userName}"]`).click();
verifyResponseStatusCode('@userDetailsPage', 200); verifyResponseStatusCode('@userDetailsPage', 200);
cy.get( cy.get(

View File

@ -50,56 +50,84 @@ describe('Entity Announcement', () => {
interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission'); interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission');
interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'entityFeed'); interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'entityFeed');
interceptURL('GET', `/api/v1/${value.entity}/name/*`, 'getEntityDetails'); interceptURL('GET', `/api/v1/${value.entity}/name/*`, 'getEntityDetails');
const startDate = getCurrentLocaleDate();
const endDate = getFutureLocaleDateFromCurrentDate(5);
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
cy.get('[data-testid="manage-button"]').should('be.visible').click();
cy.get('[data-testid="announcement-button"]').should('be.visible').click();
cy.get('[data-testid="announcement-error"]')
.should('be.visible')
.contains('No Announcements, Click on add announcement to add one.');
interceptURL('POST', '/api/v1/feed', 'waitForAnnouncement'); interceptURL('POST', '/api/v1/feed', 'waitForAnnouncement');
// Create Active Announcement interceptURL(
createAnnouncement( 'GET',
'Announcement Title', '/api/v1/feed?entityLink=*type=Announcement',
startDate, 'announcementFeed'
endDate,
'Announcement Description'
); );
// wait time for success toast message visitEntityDetailsPage(value.term, value.serviceName, value.entity);
verifyResponseStatusCode('@waitForAnnouncement', 201); cy.get('[data-testid="manage-button"]').click();
cy.get('.Toastify__close-button >').should('be.visible').click(); cy.get('[data-testid="announcement-button"]').click();
// Create InActive Announcement
const InActiveStartDate = getFutureLocaleDateFromCurrentDate(6);
const InActiveEndDate = getFutureLocaleDateFromCurrentDate(11);
createAnnouncement( cy.wait('@announcementFeed').then((res) => {
'InActive Announcement Title', const data = res.response.body.data;
InActiveStartDate,
InActiveEndDate,
'InActive Announcement Description'
);
// wait time for success toast message if (data.length > 0) {
verifyResponseStatusCode('@waitForAnnouncement', 201); const token = localStorage.getItem('oidcIdToken');
cy.get('.Toastify__close-button >').should('be.visible').click(); data.map((feed) => {
// check for inActive-announcement cy.request({
cy.get('[data-testid="inActive-announcements"]').should('be.visible'); method: 'DELETE',
url: `/api/v1/feed/${feed.id}`,
headers: { Authorization: `Bearer ${token}` },
}).then((response) => {
expect(response.status).to.eq(200);
});
});
cy.reload();
cy.get('[data-testid="manage-button"]').click();
cy.get('[data-testid="announcement-button"]').click();
}
const startDate = getCurrentLocaleDate();
const endDate = getFutureLocaleDateFromCurrentDate(5);
// close announcement drawer cy.get('[data-testid="announcement-error"]')
cy.get('[data-testid="title"] .anticon-close').should('be.visible').click(); .should('be.visible')
.contains('No Announcements, Click on add announcement to add one.');
// reload page to get the active announcement card // Create Active Announcement
cy.reload(); createAnnouncement(
verifyResponseStatusCode('@entityPermission', 200); 'Announcement Title',
verifyResponseStatusCode('@getEntityDetails', 200); startDate,
verifyResponseStatusCode('@entityFeed', 200); endDate,
'Announcement Description'
);
// check for announcement card on entity page // wait time for success toast message
cy.get('[data-testid="announcement-card"]').should('be.visible'); verifyResponseStatusCode('@waitForAnnouncement', 201);
cy.get('.Toastify__close-button >').should('be.visible').click();
// Create InActive Announcement
const InActiveStartDate = getFutureLocaleDateFromCurrentDate(6);
const InActiveEndDate = getFutureLocaleDateFromCurrentDate(11);
createAnnouncement(
'InActive Announcement Title',
InActiveStartDate,
InActiveEndDate,
'InActive Announcement Description'
);
// wait time for success toast message
verifyResponseStatusCode('@waitForAnnouncement', 201);
cy.get('.Toastify__close-button >').should('be.visible').click();
// check for inActive-announcement
cy.get('[data-testid="inActive-announcements"]').should('be.visible');
// close announcement drawer
cy.get('[data-testid="title"] .anticon-close')
.should('be.visible')
.click();
// reload page to get the active announcement card
cy.reload();
verifyResponseStatusCode('@entityPermission', 200);
verifyResponseStatusCode('@getEntityDetails', 200);
verifyResponseStatusCode('@entityFeed', 200);
// check for announcement card on entity page
cy.get('[data-testid="announcement-card"]').should('be.visible');
});
}; };
ANNOUNCEMENT_ENTITIES.forEach((entity) => { ANNOUNCEMENT_ENTITIES.forEach((entity) => {
@ -107,4 +135,29 @@ describe('Entity Announcement', () => {
addAnnouncement(entity); addAnnouncement(entity);
}); });
}); });
ANNOUNCEMENT_ENTITIES.forEach((value) => {
it(`Delete announcement ${value.entity}`, () => {
interceptURL(
'GET',
'/api/v1/feed?entityLink=*type=Announcement',
'announcementFeed'
);
interceptURL('DELETE', '/api/v1/feed/*', 'deleteFeed');
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
cy.get('[data-testid="manage-button"]').click();
cy.get('[data-testid="announcement-button"]').click();
verifyResponseStatusCode('@announcementFeed', 200);
cy.get('[data-testid="main-message"]').each(($message) => {
cy.wrap($message).trigger('mouseover');
cy.get('[data-testid="delete-message"]').click();
cy.get('.ant-modal-body').should(
'contain',
'Are you sure you want to permanently delete this message?'
);
cy.get('[data-testid="save-button"]').click();
verifyResponseStatusCode('@deleteFeed', 200);
});
});
});
}); });

View File

@ -51,21 +51,11 @@ describe('Data Insight Alert', () => {
verifyResponseStatusCode('@dataInsightReport', 200); verifyResponseStatusCode('@dataInsightReport', 200);
}); });
it('Should have default alert with proper data', () => { it('Should have default alert', () => {
cy.get('[data-testid="sub-heading"]') cy.get('[data-testid="sub-heading"]').should('be.visible');
.should('be.visible') cy.get('[data-testid="trigger-type"]').should('be.visible');
.contains(dataInsightReport.description); cy.get('[data-testid="schedule-info-type"]').should('be.visible');
cy.get('[data-testid="destination"]').should('be.visible');
cy.get('[data-testid="trigger-type"]')
.should('be.visible')
.contains(dataInsightReport.triggerType);
cy.get('[data-testid="schedule-info-type"]')
.should('be.visible')
.contains(dataInsightReport.scheduleInfoType);
cy.get('[data-testid="sendToAdmins"]').should('be.visible');
cy.get('[data-testid="sendToTeams"]').should('be.visible');
cy.get('[data-testid="edit-button"]').should('be.visible'); cy.get('[data-testid="edit-button"]').should('be.visible');
}); });
@ -75,40 +65,29 @@ describe('Data Insight Alert', () => {
'api/v1/events/subscriptions/*', 'api/v1/events/subscriptions/*',
'dataInsightReportById' 'dataInsightReportById'
); );
cy.get('[data-testid="edit-button"]').should('be.visible').click(); cy.get('[data-testid="edit-button"]').click();
verifyResponseStatusCode('@dataInsightReportById', 200); verifyResponseStatusCode('@dataInsightReportById', 200);
cy.get('[data-testid="name"]') cy.get('[data-testid="name"]')
.should('be.visible')
.should('be.disabled') .should('be.disabled')
.should('have.value', dataInsightReport.name); .should('have.value', dataInsightReport.name);
// update the description // update the description
cy.get(descriptionBox) cy.get(descriptionBox)
.scrollIntoView() .scrollIntoView()
.should('be.visible')
.click() .click()
.clear() .clear()
.type(dataInsightReport.updatedDescription); .type(dataInsightReport.updatedDescription);
// update schedule info // update schedule info
cy.get('[data-testid="scheduleInfo"]') cy.get('[data-testid="scheduleInfo"]').scrollIntoView().click();
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[title="Monthly"]').should('be.visible').click(); cy.get('.ant-select-dropdown [title="Monthly"]').click();
// update send to teams and admins // update send to teams and admins
cy.get('[data-testid="sendToTeams"]') cy.get('[data-testid="sendToTeams"]').scrollIntoView().uncheck();
.scrollIntoView()
.should('exist')
.uncheck();
cy.get('[data-testid="sendToAdmins"]') cy.get('[data-testid="sendToAdmins"]').scrollIntoView().uncheck();
.scrollIntoView()
.should('exist')
.uncheck();
interceptURL('PUT', 'api/v1/events/subscriptions', 'updatedAlert'); interceptURL('PUT', 'api/v1/events/subscriptions', 'updatedAlert');
interceptURL( interceptURL(
@ -124,17 +103,17 @@ describe('Data Insight Alert', () => {
// verify the updated data // verify the updated data
cy.get('[data-testid="sub-heading"]') cy.get('[data-testid="sub-heading"]').should(
.should('be.visible') 'contain',
.contains(dataInsightReport.updatedDescription); dataInsightReport.updatedDescription
);
cy.get('[data-testid="trigger-type"]') cy.get('[data-testid="trigger-type"]').should(
.should('be.visible') 'contain',
.contains(dataInsightReport.triggerType); dataInsightReport.triggerType
);
cy.get('[data-testid="schedule-info-type"]') cy.get('[data-testid="schedule-info-type"]').should('contain', 'Monthly');
.should('be.visible')
.contains('Monthly');
}); });
it('Should Update the alert to default values', () => { it('Should Update the alert to default values', () => {
@ -143,40 +122,29 @@ describe('Data Insight Alert', () => {
'api/v1/events/subscriptions/*', 'api/v1/events/subscriptions/*',
'dataInsightReportById' 'dataInsightReportById'
); );
cy.get('[data-testid="edit-button"]').should('be.visible').click(); cy.get('[data-testid="edit-button"]').click();
verifyResponseStatusCode('@dataInsightReportById', 200); verifyResponseStatusCode('@dataInsightReportById', 200);
cy.get('[data-testid="name"]') cy.get('[data-testid="name"]')
.should('be.visible')
.should('be.disabled') .should('be.disabled')
.should('have.value', dataInsightReport.name); .should('have.value', dataInsightReport.name);
// update the description // update the description
cy.get(descriptionBox) cy.get(descriptionBox)
.scrollIntoView() .scrollIntoView()
.should('be.visible')
.click() .click()
.clear() .clear()
.type(dataInsightReport.description); .type(dataInsightReport.description);
// update schedule info // update schedule info
cy.get('[data-testid="scheduleInfo"]') cy.get('[data-testid="scheduleInfo"]').scrollIntoView().click();
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[title="Weekly"]').should('be.visible').click(); cy.get('.ant-select-dropdown [title="Weekly"]').click();
// update send to teams and admins // update send to teams and admins
cy.get('[data-testid="sendToTeams"]') cy.get('[data-testid="sendToTeams"]').scrollIntoView().check();
.scrollIntoView()
.should('exist')
.check();
cy.get('[data-testid="sendToAdmins"]') cy.get('[data-testid="sendToAdmins"]').scrollIntoView().check();
.scrollIntoView()
.should('exist')
.check();
interceptURL('PUT', 'api/v1/events/subscriptions', 'updatedAlert'); interceptURL('PUT', 'api/v1/events/subscriptions', 'updatedAlert');
interceptURL( interceptURL(
@ -192,17 +160,20 @@ describe('Data Insight Alert', () => {
// verify the updated data // verify the updated data
cy.get('[data-testid="sub-heading"]') cy.get('[data-testid="sub-heading"]').should(
.should('be.visible') 'contain',
.contains(dataInsightReport.description); dataInsightReport.description
);
cy.get('[data-testid="trigger-type"]') cy.get('[data-testid="trigger-type"]').should(
.should('be.visible') 'contain',
.contains(dataInsightReport.triggerType); dataInsightReport.triggerType
);
cy.get('[data-testid="schedule-info-type"]') cy.get('[data-testid="schedule-info-type"]').should(
.should('be.visible') 'contain',
.contains(dataInsightReport.scheduleInfoType); dataInsightReport.scheduleInfoType
);
cy.get('[data-testid="sendToAdmins"]').should('be.visible'); cy.get('[data-testid="sendToAdmins"]').should('be.visible');
cy.get('[data-testid="sendToTeams"]').should('be.visible'); cy.get('[data-testid="sendToTeams"]').should('be.visible');

View File

@ -896,6 +896,9 @@ const CreateUser = ({
<Select <Select
data-testid="roles-dropdown" data-testid="roles-dropdown"
disabled={isEmpty(roles)} disabled={isEmpty(roles)}
filterOption={(input, option) =>
(option?.label ?? '').includes(input)
}
mode="multiple" mode="multiple"
options={roleOptions} options={roleOptions}
placeholder={t('label.please-select-entity', { placeholder={t('label.please-select-entity', {

View File

@ -77,7 +77,7 @@
@tag-default-bg: @grey-1; @tag-default-bg: @grey-1;
@grey-bg-with-alpha: #7575751a; @grey-bg-with-alpha: #7575751a;
@btn-shadow: none; @btn-shadow: none;
@user-profile-background: rgba(9, 80, 197, 0.05); @user-profile-background: #f4f8ff;
@success-background-color: rgba(0, 131, 118, 0.2); @success-background-color: rgba(0, 131, 118, 0.2);
@tag-background-color: rgba(0, 0, 0, 0.03); @tag-background-color: rgba(0, 0, 0, 0.03);