Skip to content

Commit

Permalink
Merge pull request #3585 from folio-org/FAT-12685-FAT-12687-FAT-12692
Browse files Browse the repository at this point in the history
Test cases covering Profile picture
  • Loading branch information
PavloPak committed May 9, 2024
2 parents 1222d66 + dab740a commit bdff321
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
59 changes: 59 additions & 0 deletions cypress/e2e/users/profile-picture-validations.cy.js
@@ -0,0 +1,59 @@
import TopMenu from '../../support/fragments/topMenu';
import Users from '../../support/fragments/users/users';
import permissions from '../../support/dictionary/permissions';
import UsersCard from '../../support/fragments/users/usersCard';
import UsersSearchPane from '../../support/fragments/users/usersSearchPane';
import UserEdit from '../../support/fragments/users/userEdit';
import ProfileCard from '../../support/fragments/users/profilePicture';

describe('profile-picture-validation', () => {
let testUser = {};

before('Preconditions', () => {
cy.getAdminToken();
cy.createTempUser([permissions.uiUserEdit.gui, permissions.uiUsersPermissionsView.gui])
.then((userProperties) => {
testUser = userProperties;
})
.then(() => {
cy.loginAsAdmin({
path: TopMenu.usersPath,
waiter: UsersSearchPane.waitLoading,
});
});
});

after('Deleting created entities', () => {
cy.getAdminToken();
Users.deleteViaApi(testUser.userId);
});

it(
'C446093 Update profile picture via local storage or external Url (volaris)',
{ tags: ['smokeBroken', 'volaris'] },
() => {
UsersSearchPane.searchByUsername(testUser.username);
UsersCard.waitLoading();
UserEdit.openEdit();
ProfileCard.verifyProfileCardIsPresent();
ProfileCard.expandUpdateDropDown();
ProfileCard.verifyLocalUploadbuttonIsPresent();
ProfileCard.setPictureFromExternalUrl();
ProfileCard.verifyPictureIsSet();
},
);

it(
'C442795, C442796 Verify that profile picture and associated update options display appropriately with Users: Can view, edit, and delete profile pictures',
{ tags: ['smokeBroken', 'volaris'] },
() => {
UsersSearchPane.searchByUsername(testUser.username);
UsersCard.waitLoading();
UserEdit.openEdit();
ProfileCard.verifyProfileCardIsPresent();
ProfileCard.expandUpdateDropDown();
ProfileCard.deleteProfilePicture();
ProfileCard.verifyPictureIsRemoved();
},
);
});
57 changes: 57 additions & 0 deletions cypress/support/fragments/users/profilePicture.js
@@ -0,0 +1,57 @@
import { including } from '@interactors/html';
import { Button, not, ProfilePictureCard } from '../../../../interactors';

const updateDropDownCss = 'div[id="updateProfilePictureDropdown"] > button';
const externalPictureUrl =
'https://png.pngtree.com/png-vector/20191101/ourmid/pngtree-cartoon-color-simple-male-avatar-png-image_1934459.jpg';
const localFileButton = Button({ dataTestID: 'localFile' });
const externalUrlButton = Button({ dataTestID: 'externalURL' });
const deletePictureButton = Button({ dataTestID: 'delete' });

export default {
verifyProfileCardIsPresent() {
cy.expect(ProfilePictureCard({ testId: 'profile-picture' }).exists());
},

expandUpdateDropDown() {
cy.do(cy.get(updateDropDownCss).click({ force: true }));

Check warning on line 17 in cypress/support/fragments/users/profilePicture.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Do not use force on click and type calls
},

verifyLocalUploadbuttonIsPresent() {
cy.expect(localFileButton.exists());
},

setPictureFromExternalUrl() {
cy.do(externalUrlButton.click({ force: true }));
cy.do(
cy.get('#external-image-url').clear(),
cy.get('#external-image-url').type(externalPictureUrl),
cy.get('#save-external-link-btn').click(),
);
this.saveAndClose();
},

saveAndClose() {
cy.get('#clickable-save').click({ force: true });

Check warning on line 35 in cypress/support/fragments/users/profilePicture.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Do not use force on click and type calls
},

deleteProfilePicture() {
cy.do(deletePictureButton.click({ force: true }));
cy.get('div[role="document"] span').contains('Yes').click();
this.saveAndClose();
},

verifyPictureIsSet() {
cy.expect(
ProfilePictureCard({ testId: 'profile-picture' }).has({ src: including(externalPictureUrl) }),
);
},

verifyPictureIsRemoved() {
cy.expect(
ProfilePictureCard({ testId: 'profile-picture' }).has({
src: not(including(externalPictureUrl)),
}),
);
},
};
1 change: 1 addition & 0 deletions interactors/index.js
Expand Up @@ -92,6 +92,7 @@ export { AdvancedSearch, AdvancedSearchRow } from './advanced-search';
export { FieldSet, FieldInFieldset } from './fieldset';
export { default as ConfirmationModal } from './confirmation-modal';
export { default as Warning } from './warning';
export { default as ProfilePictureCard } from './profilePictureCard';

// Stripes-smart-component interactors
export { AddressList, AddressEdit, AddressItem } from './address-edit-list';
Expand Down
9 changes: 9 additions & 0 deletions interactors/profilePictureCard.js
@@ -0,0 +1,9 @@
import HTML from './baseHTML';

export default HTML.extend('image')
.selector('img')
.filters({
alt: (el) => el.getAttribute('alt'),
testId: (el) => el.getAttribute('data-testid'),
src: (el) => el.getAttribute('src'),
});

0 comments on commit bdff321

Please sign in to comment.