|
| 1 | +import uuid from 'uuid'; |
| 2 | +import Modals from '../../../support/fragments/modals'; |
| 3 | +import TopMenu from '../../../support/fragments/topMenu'; |
| 4 | +import UserEdit from '../../../support/fragments/users/userEdit'; |
| 5 | +import UsersCard from '../../../support/fragments/users/usersCard'; |
| 6 | +import UsersSearchPane from '../../../support/fragments/users/usersSearchPane'; |
| 7 | +import getRandomPostfix, { getTestEntityValue } from '../../../support/utils/stringTools'; |
| 8 | +import { parseSanityParameters } from '../../../support/utils/users'; |
| 9 | +import Users from '../../../support/fragments/users/users'; |
| 10 | + |
| 11 | +describe('Users', () => { |
| 12 | + const { user, memberTenant } = parseSanityParameters(); |
| 13 | + let testUser = {}; |
| 14 | + const testData = { |
| 15 | + editUser: { |
| 16 | + barcode: 'No value set-', |
| 17 | + firstName: 'No value set-', |
| 18 | + username: getTestEntityValue('username'), |
| 19 | + middleName: getTestEntityValue('middleName'), |
| 20 | + lastName: getTestEntityValue('lastName'), |
| 21 | + userType: 'Patron', |
| 22 | + email: `test@${getRandomPostfix()}folio.org`, |
| 23 | + preferredFirstName: getTestEntityValue('preferredFirstName'), |
| 24 | + expirationDate: '11/11/2035', |
| 25 | + externalSystemId: uuid(), |
| 26 | + birthDate: '12/12/2000', |
| 27 | + phone: '1234567890', |
| 28 | + mobilePhone: '2345678901', |
| 29 | + preferredContact: 'Text Message', |
| 30 | + status: 'Inactive', |
| 31 | + }, |
| 32 | + }; |
| 33 | + |
| 34 | + before('Setup', () => { |
| 35 | + cy.setTenant(memberTenant.id); |
| 36 | + cy.getUserToken(user.username, user.password) |
| 37 | + .then(() => { |
| 38 | + // Fetch user details (REQUIRED) |
| 39 | + cy.getUserDetailsByUsername(user.username).then((details) => { |
| 40 | + user.id = details.id; |
| 41 | + user.personal = details.personal; |
| 42 | + user.barcode = details.barcode; |
| 43 | + }); |
| 44 | + }) |
| 45 | + .then(() => { |
| 46 | + // Create temporary test user for editing |
| 47 | + cy.createTempUser([], 'staff').then((userProperties) => { |
| 48 | + testUser = userProperties; |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + cy.login(user.username, user.password, { |
| 53 | + path: TopMenu.usersPath, |
| 54 | + waiter: UsersSearchPane.waitLoading, |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + after('Cleanup', () => { |
| 59 | + cy.setTenant(memberTenant.id); |
| 60 | + cy.getUserToken(user.username, user.password); |
| 61 | + if (testUser.userId) { |
| 62 | + Users.deleteViaApi(testUser.userId); |
| 63 | + } |
| 64 | + }); |
| 65 | + |
| 66 | + it('C427 Edit user details (volaris)', { tags: ['dryRun', 'volaris', 'C427'] }, () => { |
| 67 | + UsersSearchPane.searchByUsername(testUser.username); |
| 68 | + UserEdit.openEdit(); |
| 69 | + UserEdit.editUserDetails(testData.editUser); |
| 70 | + Modals.confirmModalIfAny(); |
| 71 | + UserEdit.saveAndClose(); |
| 72 | + UsersCard.openExtendedInformationAccordion(); |
| 73 | + UsersCard.openContactInformationAccordion(); |
| 74 | + UsersCard.verifyUserDetails(testData.editUser); |
| 75 | + }); |
| 76 | +}); |
0 commit comments