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

View File

@ -50,17 +50,42 @@ describe('Entity Announcement', () => {
interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission');
interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'entityFeed');
interceptURL('GET', `/api/v1/${value.entity}/name/*`, 'getEntityDetails');
interceptURL('POST', '/api/v1/feed', 'waitForAnnouncement');
interceptURL(
'GET',
'/api/v1/feed?entityLink=*type=Announcement',
'announcementFeed'
);
visitEntityDetailsPage(value.term, value.serviceName, value.entity);
cy.get('[data-testid="manage-button"]').click();
cy.get('[data-testid="announcement-button"]').click();
cy.wait('@announcementFeed').then((res) => {
const data = res.response.body.data;
if (data.length > 0) {
const token = localStorage.getItem('oidcIdToken');
data.map((feed) => {
cy.request({
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);
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');
// Create Active Announcement
createAnnouncement(
'Announcement Title',
@ -90,7 +115,9 @@ describe('Entity Announcement', () => {
cy.get('[data-testid="inActive-announcements"]').should('be.visible');
// close announcement drawer
cy.get('[data-testid="title"] .anticon-close').should('be.visible').click();
cy.get('[data-testid="title"] .anticon-close')
.should('be.visible')
.click();
// reload page to get the active announcement card
cy.reload();
@ -100,6 +127,7 @@ describe('Entity Announcement', () => {
// check for announcement card on entity page
cy.get('[data-testid="announcement-card"]').should('be.visible');
});
};
ANNOUNCEMENT_ENTITIES.forEach((entity) => {
@ -107,4 +135,29 @@ describe('Entity Announcement', () => {
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);
});
it('Should have default alert with proper data', () => {
cy.get('[data-testid="sub-heading"]')
.should('be.visible')
.contains(dataInsightReport.description);
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');
it('Should have default alert', () => {
cy.get('[data-testid="sub-heading"]').should('be.visible');
cy.get('[data-testid="trigger-type"]').should('be.visible');
cy.get('[data-testid="schedule-info-type"]').should('be.visible');
cy.get('[data-testid="destination"]').should('be.visible');
cy.get('[data-testid="edit-button"]').should('be.visible');
});
@ -75,40 +65,29 @@ describe('Data Insight Alert', () => {
'api/v1/events/subscriptions/*',
'dataInsightReportById'
);
cy.get('[data-testid="edit-button"]').should('be.visible').click();
cy.get('[data-testid="edit-button"]').click();
verifyResponseStatusCode('@dataInsightReportById', 200);
cy.get('[data-testid="name"]')
.should('be.visible')
.should('be.disabled')
.should('have.value', dataInsightReport.name);
// update the description
cy.get(descriptionBox)
.scrollIntoView()
.should('be.visible')
.click()
.clear()
.type(dataInsightReport.updatedDescription);
// update schedule info
cy.get('[data-testid="scheduleInfo"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="scheduleInfo"]').scrollIntoView().click();
cy.get('[title="Monthly"]').should('be.visible').click();
cy.get('.ant-select-dropdown [title="Monthly"]').click();
// update send to teams and admins
cy.get('[data-testid="sendToTeams"]')
.scrollIntoView()
.should('exist')
.uncheck();
cy.get('[data-testid="sendToTeams"]').scrollIntoView().uncheck();
cy.get('[data-testid="sendToAdmins"]')
.scrollIntoView()
.should('exist')
.uncheck();
cy.get('[data-testid="sendToAdmins"]').scrollIntoView().uncheck();
interceptURL('PUT', 'api/v1/events/subscriptions', 'updatedAlert');
interceptURL(
@ -124,17 +103,17 @@ describe('Data Insight Alert', () => {
// verify the updated data
cy.get('[data-testid="sub-heading"]')
.should('be.visible')
.contains(dataInsightReport.updatedDescription);
cy.get('[data-testid="sub-heading"]').should(
'contain',
dataInsightReport.updatedDescription
);
cy.get('[data-testid="trigger-type"]')
.should('be.visible')
.contains(dataInsightReport.triggerType);
cy.get('[data-testid="trigger-type"]').should(
'contain',
dataInsightReport.triggerType
);
cy.get('[data-testid="schedule-info-type"]')
.should('be.visible')
.contains('Monthly');
cy.get('[data-testid="schedule-info-type"]').should('contain', 'Monthly');
});
it('Should Update the alert to default values', () => {
@ -143,40 +122,29 @@ describe('Data Insight Alert', () => {
'api/v1/events/subscriptions/*',
'dataInsightReportById'
);
cy.get('[data-testid="edit-button"]').should('be.visible').click();
cy.get('[data-testid="edit-button"]').click();
verifyResponseStatusCode('@dataInsightReportById', 200);
cy.get('[data-testid="name"]')
.should('be.visible')
.should('be.disabled')
.should('have.value', dataInsightReport.name);
// update the description
cy.get(descriptionBox)
.scrollIntoView()
.should('be.visible')
.click()
.clear()
.type(dataInsightReport.description);
// update schedule info
cy.get('[data-testid="scheduleInfo"]')
.scrollIntoView()
.should('be.visible')
.click();
cy.get('[data-testid="scheduleInfo"]').scrollIntoView().click();
cy.get('[title="Weekly"]').should('be.visible').click();
cy.get('.ant-select-dropdown [title="Weekly"]').click();
// update send to teams and admins
cy.get('[data-testid="sendToTeams"]')
.scrollIntoView()
.should('exist')
.check();
cy.get('[data-testid="sendToTeams"]').scrollIntoView().check();
cy.get('[data-testid="sendToAdmins"]')
.scrollIntoView()
.should('exist')
.check();
cy.get('[data-testid="sendToAdmins"]').scrollIntoView().check();
interceptURL('PUT', 'api/v1/events/subscriptions', 'updatedAlert');
interceptURL(
@ -192,17 +160,20 @@ describe('Data Insight Alert', () => {
// verify the updated data
cy.get('[data-testid="sub-heading"]')
.should('be.visible')
.contains(dataInsightReport.description);
cy.get('[data-testid="sub-heading"]').should(
'contain',
dataInsightReport.description
);
cy.get('[data-testid="trigger-type"]')
.should('be.visible')
.contains(dataInsightReport.triggerType);
cy.get('[data-testid="trigger-type"]').should(
'contain',
dataInsightReport.triggerType
);
cy.get('[data-testid="schedule-info-type"]')
.should('be.visible')
.contains(dataInsightReport.scheduleInfoType);
cy.get('[data-testid="schedule-info-type"]').should(
'contain',
dataInsightReport.scheduleInfoType
);
cy.get('[data-testid="sendToAdmins"]').should('be.visible');
cy.get('[data-testid="sendToTeams"]').should('be.visible');

View File

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

View File

@ -77,7 +77,7 @@
@tag-default-bg: @grey-1;
@grey-bg-with-alpha: #7575751a;
@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);
@tag-background-color: rgba(0, 0, 0, 0.03);