Skip to content

Commit

Permalink
e2e - updated tests for the UI changes of removing roles in grids (#2371
Browse files Browse the repository at this point in the history
)

* Updates

* Test updates for button updates

* More updates for buttons

* Button updates

* Test updates for UI components

* Updates for event log, status, notifications

* e2e updates

* File service, configuration service, welcome

* Updates on PDF, script and notifications

* subscription and service status updates

* Updates on events and directory

* e2e updates for status, directory and tenant admin

* directory and service status

* Notifications test updates

* One comment for roles in notification type modal

* e2e test updates for status and notifications

* Changed var to let

* e2e test updates for configuration

* e2e test updates for welcome page

* Removed unused element

* e2e updates

* test updates for events and script

* e2e updates on welcome page and notifications

* Fixes for service status

* updates for file service

* e2e test updates for event, file, notification

* Update for pdf

* update for status

* Update

* e2e updates

* e2e updates

* e2e updates

* e2e updates

* Added a config setting

* Commented out edit PDF template steps

* Update

* update

* Updated file tests

* Updated pdf test

* Removed headless=true command parameter

* Switch e2e test run from Chrome to Electron

* Switch e2e test run from headless to headed

* e2e fixes

* e2e updates

* e2e updates

* Test fixes

* Updated cs-322 with validation of open icon

* Added validation of pdf template body

* Added a couple of steps of selecting filters

* Added a walkaround

* Walkaround for 30 second refresh

* Added more wait to avoid random test failures

* File service test updates

* Put accessiblity test step back

* Commented out accessibility step for file types

* Added support info validation on subscriber app

* Fixed a timestamp bug

* Added more delay on file type name

* test updates

* subscriber app test update

* Updated load more button page object

* e2e test updates

* Fixed a typo

* Added a wait

* Updates of subscription management tests

* test updates for calendar and script

* Test updates

* test updates

* enabled api doc link tests

* Re-enabled tenant creation test

* Adjusted wait for 2 failed tests

* added shadow() for shadow dom element

* Updated tests for UI changes of removing roles

* Chnaged from let to const

---------

Co-authored-by: Howard Zhang <[email protected]>
  • Loading branch information
howard-zhang and howard-zhang-goa authored Dec 8, 2023
1 parent 574adbe commit ef7d30e
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 528 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Calendar
When the user clicks Cancel button in Add calendar modal
Then the user views Calendar tab table header on calendars page
And no critical or serious accessibility issues on "calendar calendars page"
When the user clicks "Edit" button for the calendar of "autotest-calendarAccessibility", "DO NOT DELETE", "auto-test-role1"
When the user clicks "Edit" button for the calendar of "autotest-calendarAccessibility", "DO NOT DELETE"
Then the user views Edit calendar modal
And no critical or serious accessibility issues on "calendar edit calendar modal"

Expand All @@ -43,15 +43,15 @@ Feature: Calendar
# Validate data
When the user enters "autotest-addcalendar", "autotest calendar desc", "auto-test-role1, urn:ads:autotest:chat-service:chat-admin" in Add calendar modal
And the user clicks Save button in Add calendar modal
Then the user "views" the calendar of "autotest-addcalendar", "autotest calendar desc", "auto-test-role1, urn:ads:autotest:chat-service:chat-admin"
Then the user "views" the calendar of "autotest-addcalendar", "autotest calendar desc"
# Edit
When the user clicks "Edit" button for the calendar of "autotest-addcalendar", "autotest calendar desc", "auto-test-role1, urn:ads:autotest:chat-service:chat-admin"
When the user clicks "Edit" button for the calendar of "autotest-addcalendar", "autotest calendar desc"
Then the user views Edit calendar modal
When the user enters "autotest calendar desc edit" as description and selects "auto-test-role2" as role in Edit calendar modal
And the user clicks Save button in Edit calendar modal
Then the user "views" the calendar of "autotest-addcalendar", "autotest calendar desc edit", "auto-test-role2"
Then the user "views" the calendar of "autotest-addcalendar", "autotest calendar desc edit"
# Delete
When the user clicks "Delete" button for the calendar of "autotest-addcalendar", "autotest calendar desc edit", "auto-test-role2"
When the user clicks "Delete" button for the calendar of "autotest-addcalendar", "autotest calendar desc edit"
Then the user views delete "calendar" confirmation modal for "autotest-addcalendar"
When the user clicks Delete button in delete confirmation modal
Then the user "should not view" the calendar of "autotest-addcalendar", "autotest script desc edit", "auto-test-role2"
Then the user "should not view" the calendar of "autotest-addcalendar", "autotest script desc edit"
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ When('the user clicks Cancel button in Add calendar modal', function () {
});

Then('the user views Calendar tab table header on calendars page', function () {
calendarObj.calendarTableHeader().should('be.visible');
calendarObj.calendarTableHeader().should('be.visible');
});

When('the user enters {string} in name field in calendar modal', function (name) {
Expand All @@ -54,78 +54,73 @@ Then('the user views the error message of {string} on namespace in calendar moda
.should('contain', errorMsg);
});

When('the user enters {string}, {string}, {string} in Add calendar modal',
function (name, desc, role) {
cy.viewport(1920, 1080);
calendarObj.addCalendarModalNameField().shadow().find('input').clear().type(name, { delay: 100, force: true });
calendarObj.addCalendarModalDescriptionField().shadow().find('.goa-textarea').clear().type(desc, { force: true });
// Select roles or client roles
const roles = role.split(',');
for (let i = 0; i < roles.length; i++) {
if (roles[i].includes(':')) {
const clientRoleStringArray = roles[i].split(':');
let clientName = '';
for (let j = 0; j < clientRoleStringArray.length - 1; j++) {
if (j !== clientRoleStringArray.length - 2) {
clientName = clientName + clientRoleStringArray[j].trim() + ':';
} else {
clientName = clientName + clientRoleStringArray[j];
}
}
const roleName = clientRoleStringArray[clientRoleStringArray.length - 1];
calendarObj
.addCalendarModalClientRolesTable(clientName)
.shadow()
.find('.role-name')
.contains(roleName)
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
When('the user enters {string}, {string}, {string} in Add calendar modal', function (name, desc, role) {
cy.viewport(1920, 1080);
calendarObj.addCalendarModalNameField().shadow().find('input').clear().type(name, { delay: 100, force: true });
calendarObj.addCalendarModalDescriptionField().shadow().find('.goa-textarea').clear().type(desc, { force: true });
// Select roles or client roles
const roles = role.split(',');
for (let i = 0; i < roles.length; i++) {
if (roles[i].includes(':')) {
const clientRoleStringArray = roles[i].split(':');
let clientName = '';
for (let j = 0; j < clientRoleStringArray.length - 1; j++) {
if (j !== clientRoleStringArray.length - 2) {
clientName = clientName + clientRoleStringArray[j].trim() + ':';
} else {
clientName = clientName + clientRoleStringArray[j];
}
}
const roleName = clientRoleStringArray[clientRoleStringArray.length - 1];
calendarObj
.addCalendarModalClientRolesTable(clientName)
.shadow()
.find('.role-name')
.contains(roleName)
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
} else {
calendarObj
.addCalendarModalRolesTable()
.shadow()
.find('.role-name')
.contains(roles[i].trim())
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
}
}
calendarObj
.addCalendarModalRolesTable()
.shadow()
.find('.role-name')
.contains(roles[i].trim())
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
}
}
});

Then('the user {string} the calendar of {string}, {string}, {string}', function (viewOrNot, name, desc, role) {
findCalendar(name, desc, role).then((rowNumber) => {
Then('the user {string} the calendar of {string}, {string}', function (viewOrNot, name, desc) {
findCalendar(name, desc).then((rowNumber) => {
switch (viewOrNot) {
case 'views':
expect(rowNumber).to.be.greaterThan(
0,
'Calendar of ' + name + ', ' + desc + ', ' + role + ' has row #' + rowNumber
);
expect(rowNumber).to.be.greaterThan(0, 'Calendar of ' + name + ', ' + desc + ' has row #' + rowNumber);
break;
case 'should not view':
expect(rowNumber).to.equal(0, 'Calendar of ' + name + ', ' + desc + ', ' + role + ' has row #' + rowNumber);
expect(rowNumber).to.equal(0, 'Calendar of ' + name + ', ' + desc + ' has row #' + rowNumber);
break;
default:
expect(viewOrNot).to.be.oneOf(['views', 'should not view']);
}
});
});
//Find a calendar with name, description and role(s)
//Input: calendar name, calendar description, role(s) in a string separated with comma
//Find a calendar with name, description
//Input: calendar name, calendar descriptionin a string separated with comma
//Return: row number if the calendar is found; zero if the script isn't found
function findCalendar(name, desc, role) {
function findCalendar(name, desc) {
return new Cypress.Promise((resolve, reject) => {
try {
let rowNumber = 0;
const roles = role.split(',');
const targetedNumber = roles.length + 2; // Name, description and roles all need to match to find the calendar
const targetedNumber = 2; // Name and description need to match to find the calendar
calendarObj
.calendarTableBody()
.find('tr')
Expand All @@ -140,12 +135,6 @@ function findCalendar(name, desc, role) {
if (rowElement.cells[2].innerHTML.includes(desc)) {
counter = counter + 1;
}
// cy.log(rowElement.cells[3].innerHTML); // Print out the role cell innerHTML for debug purpose
roles.forEach((runningRole) => {
if (rowElement.cells[3].innerHTML.includes(runningRole.trim())) {
counter = counter + 1;
}
});
Cypress.log({
name: 'Number of matched items for row# ' + rowElement.rowIndex + ': ',
message: String(String(counter)),
Expand All @@ -166,92 +155,94 @@ function findCalendar(name, desc, role) {
});
}

When(
'the user clicks {string} button for the calendar of {string}, {string}, {string}',
function (button, name, desc, role) {
findCalendar(name, desc, role).then((rowNumber) => {
expect(rowNumber).to.be.greaterThan(
0,
'Script of ' + name + ', ' + desc + ', ' + role + ' has row #' + rowNumber
);
cy.wait(1000); // Wait for buttons to show up
switch (button.toLowerCase()) {
case 'edit':
calendarObj.calendarEditButton(rowNumber).shadow().find('button').click({ force: true });
break;
case 'delete':
calendarObj.calendarDeleteButton(rowNumber).shadow().find('button').click({ force: true });
break;
default:
expect(button).to.be.oneOf(['edit', 'delete']);
}
});
}
);
When('the user clicks {string} button for the calendar of {string}, {string}', function (button, name, desc) {
findCalendar(name, desc).then((rowNumber) => {
expect(rowNumber).to.be.greaterThan(0, 'Script of ' + name + ', ' + desc + ' has row #' + rowNumber);
cy.wait(1000); // Wait for buttons to show up
switch (button.toLowerCase()) {
case 'edit':
calendarObj.calendarEditButton(rowNumber).shadow().find('button').click({ force: true });
break;
case 'delete':
calendarObj.calendarDeleteButton(rowNumber).shadow().find('button').click({ force: true });
break;
default:
expect(button).to.be.oneOf(['edit', 'delete']);
}
});
});

Then('the user views Edit calendar modal', function () {
calendarObj.editCalendarModal().should('exist');
});

When('the user enters {string} as description and selects {string} as role in Edit calendar modal', function (description, role) {
calendarObj.editCalendarModalDescriptionField().shadow().find('.goa-textarea').clear().type(description, { force: true });
//Unselect all checkboxes
calendarObj
.editCalendarModalTable()
.shadow()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.then((elements) => {
for (let i = 0; i < elements.length; i++) {
if (elements[i].getAttribute('class')?.includes('--selected')) {
elements[i].click();
}
}
});
// Select roles
const roles = role.split(',');
When(
'the user enters {string} as description and selects {string} as role in Edit calendar modal',
function (description, role) {
calendarObj
.editCalendarModalDescriptionField()
.shadow()
.find('.goa-textarea')
.clear()
.type(description, { force: true });
//Unselect all checkboxes
calendarObj
.editCalendarModalTable()
.shadow()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.then((elements) => {
for (let i = 0; i < elements.length; i++) {
if (elements[i].getAttribute('class')?.includes('--selected')) {
elements[i].click();
}
}
});
// Select roles
const roles = role.split(',');
for (let i = 0; i < roles.length; i++) {
if (roles[i].includes(':')) {
const clientRoleStringArray = roles[i].split(':');
let clientName = '';
for (let j = 0; j < clientRoleStringArray.length - 1; j++) {
if (j !== clientRoleStringArray.length - 2) {
clientName = clientName + clientRoleStringArray[j].trim() + ':';
} else {
clientName = clientName + clientRoleStringArray[j];
}
}
const roleName = clientRoleStringArray[clientRoleStringArray.length - 1];
calendarObj
.addCalendarModalClientRolesTable(clientName)
.shadow()
.find('.role-name')
.contains(roleName)
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
} else {
calendarObj
.addCalendarModalRolesTable()
.shadow()
.find('.role-name')
.contains(roles[i].trim())
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
const clientRoleStringArray = roles[i].split(':');
let clientName = '';
for (let j = 0; j < clientRoleStringArray.length - 1; j++) {
if (j !== clientRoleStringArray.length - 2) {
clientName = clientName + clientRoleStringArray[j].trim() + ':';
} else {
clientName = clientName + clientRoleStringArray[j];
}
}
const roleName = clientRoleStringArray[clientRoleStringArray.length - 1];
calendarObj
.addCalendarModalClientRolesTable(clientName)
.shadow()
.find('.role-name')
.contains(roleName)
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
} else {
calendarObj
.addCalendarModalRolesTable()
.shadow()
.find('.role-name')
.contains(roles[i].trim())
.next()
.find('goa-checkbox')
.shadow()
.find('.goa-checkbox-container')
.scrollIntoView()
.click({ force: true });
}
}
}
});
);

When('the user clicks Save button in Edit calendar modal', function () {
cy.wait(1000); // Wait for the button to enable
calendarObj.calendarModalSaveButton().shadow().find('button').scrollIntoView().click({ force: true });
cy.wait(2000); // Wait for the save operation
});
});
Loading

0 comments on commit ef7d30e

Please sign in to comment.