2020-07-16 13:50:16 +00:00
|
|
|
/// <reference types="Cypress" />
|
|
|
|
/* globals cy, expect */
|
|
|
|
|
|
|
|
context('Edit User Browser Testing', () => {
|
|
|
|
let userFirstName = 'Edited User First Name ',
|
|
|
|
userLastName = 'Edited User Last Name ',
|
|
|
|
jobDescription = 'Edited Job Description ',
|
|
|
|
city = 'Edited City ',
|
|
|
|
phone = '+1234',
|
|
|
|
website = 'https://test.site/';
|
|
|
|
before(() => {
|
|
|
|
cy.randomNum().then(num => {
|
|
|
|
userFirstName += num;
|
|
|
|
userLastName += num;
|
|
|
|
jobDescription += num;
|
|
|
|
city += num;
|
|
|
|
phone += num;
|
|
|
|
website += num;
|
|
|
|
});
|
|
|
|
cy.clearLocalStorageSnapshot();
|
|
|
|
cy.clearLocalStorage({ domain: null });
|
|
|
|
cy.clearCookies({ domain: null });
|
|
|
|
});
|
|
|
|
beforeEach(() => cy.restoreLocalStorage());
|
|
|
|
afterEach(() => cy.saveLocalStorage());
|
|
|
|
it('should visit user login screen', () => cy.userLogin());
|
|
|
|
it('should login', () => cy.login());
|
|
|
|
describe('User Edition process', () => {
|
2020-09-17 11:08:44 +00:00
|
|
|
it('should visit the user edit screen', () => {
|
2021-02-22 20:27:58 +00:00
|
|
|
cy.visit('/members/members-edit-profile');
|
2020-09-17 11:08:44 +00:00
|
|
|
cy.location().should((loc) => {
|
2021-02-22 20:27:58 +00:00
|
|
|
expect(loc.pathname).to.eq('/members/members-edit-profile');
|
2020-09-17 11:08:44 +00:00
|
|
|
});
|
|
|
|
});
|
2020-07-16 13:50:16 +00:00
|
|
|
/// Workaround - Routing bug - user won't land on edit profile screen
|
|
|
|
it('should navigate to user edit screen', () => {
|
2021-02-22 20:27:58 +00:00
|
|
|
cy.get('#members-my-profile solid-link[next="members-edit-profile"]').click();
|
2020-07-16 13:50:16 +00:00
|
|
|
});
|
|
|
|
/// End workaround
|
|
|
|
it('should enter new user data', () => {
|
2021-02-22 20:27:58 +00:00
|
|
|
cy.get('#members-edit-profile input[name="first_name"]').clear().type(userFirstName);
|
|
|
|
cy.get('#members-edit-profile input[name="first_name"]').should('have.value', userFirstName);
|
|
|
|
cy.get('#members-edit-profile input[name="last_name"]').clear().type(userLastName);
|
|
|
|
cy.get('#members-edit-profile input[name="last_name"]').should('have.value', userLastName);
|
|
|
|
cy.get('#members-edit-profile textarea[name="profile.job"]').clear().type(jobDescription);
|
|
|
|
cy.get('#members-edit-profile textarea[name="profile.job"]').should('have.value', jobDescription);
|
|
|
|
cy.get('#members-edit-profile input[name="profile.city"]').clear().type(city);
|
|
|
|
cy.get('#members-edit-profile input[name="profile.city"]').should('have.value', city);
|
|
|
|
cy.get('#members-edit-profile input[name="profile.phone"]').clear().type(phone);
|
|
|
|
cy.get('#members-edit-profile input[name="profile.phone"]').should('have.value', phone);
|
|
|
|
cy.get('#members-edit-profile input[name="profile.website"]').clear().type(website);
|
|
|
|
cy.get('#members-edit-profile input[name="profile.website"]').should('have.value', website);
|
2020-07-16 13:50:16 +00:00
|
|
|
});
|
|
|
|
it('should click button to save the user', () => {
|
2021-02-22 20:27:58 +00:00
|
|
|
cy.get('#members-edit-profile input[value="ENREGISTRER"]').click();
|
2020-07-16 13:50:16 +00:00
|
|
|
});
|
|
|
|
it('should land on user information screen', () => {
|
|
|
|
cy.location().should(location => {
|
|
|
|
/// Workaround - Routing bug - route pathname won't be /profile as it should
|
|
|
|
expect(location.pathname).to.eq('/');
|
2021-02-22 20:27:58 +00:00
|
|
|
// expect(location.pathname).to.eq('/members');
|
2020-07-16 13:50:16 +00:00
|
|
|
/// End workaround
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('should show edited user data on user information screen', () => {
|
|
|
|
cy.contains('solid-display-value[name="name"]', userFirstName + ' ' + userLastName).should("exist");
|
|
|
|
cy.contains('solid-display-value[name="profile.job"]', jobDescription).should("exist");
|
|
|
|
cy.contains('solid-display-value[name="profile.city"]', city).should("exist");
|
2020-10-07 12:25:53 +00:00
|
|
|
cy.contains('directory-link-tel a', phone).should("exist");
|
|
|
|
cy.contains('directory-website a', website).should("exist");
|
2020-07-16 13:50:16 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|