From b49a890629917b9db36c79a6c3c669a1f27e971e Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Wed, 15 May 2024 14:00:09 +0300 Subject: [PATCH] fix more tests --- ui/cypress/e2e/reset-test-data.cy.js | 118 ++--- .../e2e/retention/add-affiliation.cy.js | 221 ++++----- ui/cypress/e2e/retention/add-user.cy.js | 77 ++-- .../e2e/retention/csv-add-affiliations.cy.js | 200 +++++---- .../e2e/retention/csv-edit-affiliations.cy.js | 143 +++--- .../retention/csv-invalid-affiliations.cy.js | 27 +- .../e2e/retention/edit-affiliation.cy.js | 83 ++-- ui/cypress/e2e/retention/edit-member.cy.js | 88 ++-- ui/cypress/e2e/retention/edit-user.cy.js | 59 ++- ui/cypress/e2e/retention/notifications.cy.js | 164 ++++--- ui/cypress/e2e/retention/reset-password.cy.js | 77 ++-- .../e2e/retention/restricted-access.cy.js | 92 ++-- ui/cypress/e2e/retention/ui-authorities.cy.js | 422 ++++++++++++------ .../e2e/retention/ui-homepage-edit.cy.js | 6 +- ui/cypress/e2e/retention/ui-homepage.cy.js | 18 +- ui/cypress/fixtures/test-data.json | 15 +- ui/cypress/support/commands.js | 18 +- .../password-reset-finish.component.html | 10 +- .../password-reset-init.component.html | 1 + .../account/password/password.component.html | 218 ++++++--- .../affiliation-import-dialog.component.html | 2 +- .../affiliation-update.component.html | 7 + .../affiliation/affiliations.component.html | 2 +- .../send-notifications-dialog.component.html | 60 ++- ui/src/app/error/error.component.html | 6 +- .../app/member/member-update.component.html | 3 + 26 files changed, 1258 insertions(+), 879 deletions(-) diff --git a/ui/cypress/e2e/reset-test-data.cy.js b/ui/cypress/e2e/reset-test-data.cy.js index 19a15a46c..10f2d29a1 100644 --- a/ui/cypress/e2e/reset-test-data.cy.js +++ b/ui/cypress/e2e/reset-test-data.cy.js @@ -1,57 +1,75 @@ /// -import data from '../fixtures/test-data.json'; -import credentials from '../fixtures/credentials.json'; +import data from "../fixtures/test-data.json"; +import credentials from "../fixtures/credentials.json"; -describe('Add new user', () => { - it('Reset organization owner', () => { - cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword) - cy.changeOrgOwner() - }) +describe("Add new user", () => { + it("Reset organization owner", () => { + cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword); + cy.changeOrgOwner(); + }); - it('Remove all affiliations from test group', function () { - cy.programmaticSignin(data.member.users.owner.email, credentials.password) - cy.visit('/assertion') - cy.get('.btn-group').each($e => { - cy.wrap($e).children().last().click() - cy.get('#jhi-confirm-delete-assertion').click() - }) - cy.visit('/user') - cy.get('.btn-group').each($e => { - cy.wrap($e).children().last().invoke('attr', 'disabled').then((disabled) => { - disabled ? cy.log("Skipping user, button is disabled") : cy.removeAffiliation($e) - }) - }) - cy.programmaticSignout() - }) + it("Remove all affiliations from test group", function () { + cy.programmaticSignin(data.member.users.owner.email, credentials.password); + cy.visit("/assertion"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e).children().last().click(); + cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click(); + }); + cy.visit("/user"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e) + .children() + .last() + .invoke("attr", "disabled") + .then((disabled) => { + disabled + ? cy.log("Skipping user, button is disabled") + : cy.removeAffiliation($e); + }); + }); + cy.programmaticSignout(); + }); - it('Remove all affiliations from test member', function () { - cy.programmaticSignin(data.member.users.owner.email, credentials.password) - cy.visit('/user') - cy.get('.btn-group').each($e => { - cy.wrap($e).children().last().invoke('attr', 'disabled').then((disabled) => { - disabled ? cy.log("Skipping user, button is disabled") : cy.removeAffiliation($e) - }) - }) - cy.programmaticSignout() - }) + it("Remove all affiliations from test member", function () { + cy.programmaticSignin(data.member.users.owner.email, credentials.password); + cy.visit("/user"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e) + .children() + .last() + .invoke("attr", "disabled") + .then((disabled) => { + disabled + ? cy.log("Skipping user, button is disabled") + : cy.removeAffiliation($e); + }); + }); + cy.programmaticSignout(); + }); - it('Remove all affiliations from csv test member', function () { - cy.programmaticSignin(data.csvMember.users.owner.email, credentials.password) - cy.visit('/assertion') - cy.get('.btn-group').each($e => { - cy.wrap($e).children().last().click() - cy.get('#jhi-confirm-delete-assertion').click() - }) - cy.programmaticSignout() - }) + it("Remove all affiliations from csv test member", function () { + cy.programmaticSignin( + data.csvMember.users.owner.email, + credentials.password, + ); + cy.visit("/assertion"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e).children().last().click(); + cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click(); + }); + cy.programmaticSignout(); + }); - it('Remove all affiliations from the notifications member', function() { - cy.programmaticSignin(data.notificationsMember.users.owner.email, credentials.password); - cy.visit('/assertion') - cy.get('.btn-group').each($e => { - cy.wrap($e).children().last().click() - cy.get('#jhi-confirm-delete-assertion').click() - }) - cy.programmaticSignout() + it("Remove all affiliations from the notifications member", function () { + cy.programmaticSignin( + data.notificationsMember.users.owner.email, + credentials.password, + ); + cy.visit("/assertion"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e).children().last().click(); + cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click(); + }); + cy.programmaticSignout(); }); -}) +}); diff --git a/ui/cypress/e2e/retention/add-affiliation.cy.js b/ui/cypress/e2e/retention/add-affiliation.cy.js index c9d672210..36b825f9a 100644 --- a/ui/cypress/e2e/retention/add-affiliation.cy.js +++ b/ui/cypress/e2e/retention/add-affiliation.cy.js @@ -1,26 +1,27 @@ /// -import data from '../../fixtures/test-data.json'; -import record from '../../fixtures/orcid-record.json'; -import credentials from '../../fixtures/credentials.json'; -import { recurse } from 'cypress-recurse'; +import data from "../../fixtures/test-data.json"; +import record from "../../fixtures/orcid-record.json"; +import credentials from "../../fixtures/credentials.json"; +import { recurse } from "cypress-recurse"; const months = { - January: '01', - February: '02', - March: '03', - April: '04', - May: '05', - June: '06', - July: '07', - August: '08', - September: '09', - October: '10', - November: '11', - December: '12' + January: "01", + February: "02", + March: "03", + April: "04", + May: "05", + June: "06", + July: "07", + August: "08", + September: "09", + October: "10", + November: "11", + December: "12", }; -const { country, countryCode, url, invalidUrl, startDate, endDate, type } = record.affiliation; +const { country, countryCode, url, invalidUrl, startDate, endDate, type } = + record.affiliation; const { ringgold, grid, ror } = record.affiliation.org; -describe('Add and remove affiliation', () => { +describe("Add and remove affiliation", () => { /* beforeEach(() => { cy.programmaticSignin(data.member.users.owner.email, credentials.password); }); @@ -29,66 +30,64 @@ describe('Add and remove affiliation', () => { cy.programmaticSignout(); });*/ - it('Add affiliation', function () { + it("Add affiliation", function () { cy.programmaticSignin(data.member.users.owner.email, credentials.password); - cy.visit('/assertion/new'); + cy.visit("/assertion/new"); - cy.get('#field_email').type(record.invalidEmail); - cy.get('small.text-danger').should('exist'); - cy.get('#field_email') - .clear() - .type(record.email); - cy.get('small.text-danger').should('not.exist'); - cy.get('#field_affiliationSection').select(type); - cy.get('#field_orgName').type(data.testString); - cy.get('#field_orgCity').type(data.testString); - cy.get('#field_orgCountry').select(country); + cy.get("#field_email").type(record.invalidEmail); + cy.get("small.text-danger").should("exist"); + cy.get("#field_email").clear().type(record.email); + cy.get("small.text-danger").should("not.exist"); + cy.get("#field_affiliationSection").select(type); + cy.get("#field_orgName").type(data.testString); + cy.get("#field_orgCity").type(data.testString); + cy.get("#field_orgCountry").select(country); cy.checkOrgId(ringgold.name, ringgold.invalidId, ringgold.id); cy.checkOrgId(grid.name, grid.invalidId, grid.id); cy.checkOrgId(ror.name, ror.invalidId, ror.id); - cy.get('#field_departmentName').type(data.testString); - cy.get('#field_roleTitle').type(data.testString); - cy.get('#field_url').type(invalidUrl); - cy.get('#field_startYear').select(startDate.year); - cy.get('#field_startMonth').select(startDate.month); - cy.get('#field_startDay').select(startDate.invalidDay); - cy.get('#field_endYear').select(endDate.year); - cy.get('#field_endMonth').select(endDate.month); - cy.get('#field_endDay').select(endDate.day); - cy.get('small') + cy.get("#field_departmentName").type(data.testString); + cy.get("#field_roleTitle").type(data.testString); + cy.get("#field_url").type(invalidUrl); + cy.get("#field_startYear").select(startDate.year); + cy.get("#field_startMonth").select(startDate.month); + cy.get("#field_startDay").select(startDate.invalidDay); + cy.get("#field_endYear").select(endDate.year); + cy.get("#field_endMonth").select(endDate.month); + cy.get("#field_endDay").select(endDate.day); + cy.get("small") .filter('[jhitranslate="entity.validation.endDate.string"]') - .should('exist'); - cy.get('#save-entity') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_startDay').select(startDate.day); - cy.get('small').should('not.exist'); - cy.get('#save-entity').click(); - cy.get('.alerts') - .children() - .should('have.length', 1); + .should("exist"); + cy.get("#save-entity").invoke("attr", "disabled").should("exist"); + cy.get("#field_startDay").select(startDate.day); + cy.get("small").should("not.exist"); + cy.get("#save-entity").click(); + cy.get(".alerts").children().should("have.length", 1); - cy.get('#save-entity').click(); - cy.get('.alerts') - .children() - .should('have.length', 2); - cy.get('#field_url') - .clear() - .type(url) - .get('#save-entity') - .click(); - cy.get('.alert-success').should('exist'); + cy.get("#save-entity").click(); + cy.get(".alerts").children().should("have.length", 2); + cy.get("#field_url").clear().type(url).get("#save-entity").click(); + cy.get(".alert-success").should("exist"); cy.programmaticSignout(); }); - it('Grant permission and check ORCID record for added affiliation', () => { + it("Grant permission and check ORCID record for added affiliation", () => { cy.programmaticSignin(data.member.users.owner.email, credentials.password); // Get permission link - cy.visit('/assertion'); - cy.get('tbody').children().first().children().eq(0).contains(record.email); - cy.get('tbody').children().first().children().eq(1).should('not.contain', record.id); - cy.get('tbody').children().first().children().eq(2).contains(record.affiliation.type); - cy.get('tbody').children().first().children().eq(4).contains('Pending'); + cy.visit("/assertion"); + cy.get("tbody").children().first().children().eq(0).contains(record.email); + cy.get("tbody") + .children() + .first() + .children() + .eq(1) + .should("not.contain", record.id); + cy.get("tbody") + .children() + .first() + .children() + .eq(2) + .contains(record.affiliation.type); + cy.get("tbody").children().first().children().eq(4).contains("Pending"); cy.fetchLinkAndGrantPermission(record.email); @@ -96,69 +95,83 @@ describe('Add and remove affiliation', () => { () => cy.request({ url: `https://pub.qa.orcid.org/v3.0/${record.id}/services`, - headers: { Accept: 'application/json' } + headers: { Accept: "application/json" }, }), - res => { - const service = res.body['affiliation-group'][0]['summaries'][0]['service-summary']; - expect(res.body['affiliation-group']).to.have.length(1); - expect(service['department-name']).to.eq(data.testString); - expect(service['role-title']).to.eq(data.testString); - expect(service['organization']['address']['city']).to.eq(data.testString.trim()); - expect(service['organization']['address']['country']).to.eq(countryCode); - expect(service['organization']['name']).to.eq(data.testString.trim()); - expect(service['url']['value']).to.eq(url); - expect(service['start-date']['year']['value']).to.eq(startDate.year); - expect(service['start-date']['month']['value']).to.eq(months[startDate.month]); - expect(service['start-date']['day']['value']).to.eq(startDate.day); - expect(service['end-date']['year']['value']).to.eq(endDate.year); - expect(service['end-date']['month']['value']).to.eq(months[endDate.month]); - expect(service['end-date']['day']['value']).to.eq(endDate.day); - expect(service['organization']['disambiguated-organization']['disambiguated-organization-identifier']).to.eq(ror.id); - expect(service['organization']['disambiguated-organization']['disambiguation-source']).to.eq(ror.name); + (res) => { + const service = + res.body["affiliation-group"][0]["summaries"][0]["service-summary"]; + expect(res.body["affiliation-group"]).to.have.length(1); + expect(service["department-name"]).to.eq(data.testString); + expect(service["role-title"]).to.eq(data.testString); + expect(service["organization"]["address"]["city"]).to.eq( + data.testString.trim(), + ); + expect(service["organization"]["address"]["country"]).to.eq( + countryCode, + ); + expect(service["organization"]["name"]).to.eq(data.testString.trim()); + expect(service["url"]["value"]).to.eq(url); + expect(service["start-date"]["year"]["value"]).to.eq(startDate.year); + expect(service["start-date"]["month"]["value"]).to.eq( + months[startDate.month], + ); + expect(service["start-date"]["day"]["value"]).to.eq(startDate.day); + expect(service["end-date"]["year"]["value"]).to.eq(endDate.year); + expect(service["end-date"]["month"]["value"]).to.eq( + months[endDate.month], + ); + expect(service["end-date"]["day"]["value"]).to.eq(endDate.day); + expect( + service["organization"]["disambiguated-organization"][ + "disambiguated-organization-identifier" + ], + ).to.eq(ror.id); + expect( + service["organization"]["disambiguated-organization"][ + "disambiguation-source" + ], + ).to.eq(ror.name); }, { log: true, limit: 20, // max number of iterations timeout: 600000, // time limit in ms - delay: 30000 // delay before next iteration, ms - } + delay: 30000, // delay before next iteration, ms + }, ); }); - it('Confirm UI changes on the assertion page', () => { + it("Confirm UI changes on the assertion page", () => { cy.programmaticSignin(data.member.users.owner.email, credentials.password); - cy.visit('/assertion'); - cy.get('tbody').children().first().children().eq(1).contains(record.id); - cy.get('tbody').children().first().children().eq(4).contains('In ORCID'); + cy.visit("/assertion"); + cy.get("tbody").children().first().children().eq(1).contains(record.id); + cy.get("tbody").children().first().children().eq(4).contains("In ORCID"); cy.programmaticSignout(); - }) + }); - it('Delete affiliation', () => { + it("Delete affiliation", () => { cy.programmaticSignin(data.member.users.owner.email, credentials.password); - cy.visit('/assertion'); - cy.get('.btn-group').each($e => { - cy.wrap($e) - .children() - .last() - .click(); - cy.get('#jhi-confirm-delete-assertion').click(); + cy.visit("/assertion"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e).children().last().click(); + cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click(); }); recurse( () => cy.request({ url: `https://pub.qa.orcid.org/v3.0/${record.id}/services`, - headers: { Accept: 'application/json' } + headers: { Accept: "application/json" }, }), - res => { + (res) => { console.log(res); - expect(res.body['affiliation-group']).to.have.length(0); + expect(res.body["affiliation-group"]).to.have.length(0); }, { log: true, limit: 20, // max number of iterations timeout: 600000, // time limit in ms - delay: 30000 // delay before next iteration, ms - } + delay: 30000, // delay before next iteration, ms + }, ); cy.programmaticSignout(); }); diff --git a/ui/cypress/e2e/retention/add-user.cy.js b/ui/cypress/e2e/retention/add-user.cy.js index 84b6e607c..a848c3ec1 100644 --- a/ui/cypress/e2e/retention/add-user.cy.js +++ b/ui/cypress/e2e/retention/add-user.cy.js @@ -1,82 +1,79 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; -describe('Add new user', () => { - it('Add user', function() { +describe("Add new user", () => { + it("Add user", function () { // enter email cy.programmaticSignin(data.member.users.owner.email, credentials.password); - cy.visit('/user/new'); + cy.visit("/user/new"); // type in invalid email address - cy.get('#field_email').type(data.invalidEmail); + cy.get("#field_email").type(data.invalidEmail); // type in name and surname - cy.get('#field_firstName').type(data.testString); - cy.get('#field_lastName').type(data.testString); + cy.get("#field_firstName").type(data.testString); + cy.get("#field_lastName").type(data.testString); // save button should be disabled - cy.get('#save-entity2') - .invoke('attr', 'disabled') - .should('exist'); + cy.get("#save-entity2").invoke("attr", "disabled").should("exist"); // email input field should have warning label - cy.get('#field_email') - .should('have.class', 'ng-invalid') + cy.get("#field_email") + .should("have.class", "ng-invalid") // enter existing email address .clear() .type(data.member.users.owner.email); - cy.get('#save-entity2').click(); - cy.get('.validation-errors') - .children() - .should('have.length', 1); - cy.get('#field_email') - .clear() - .type(data.member.users.newUser.email); + cy.get("#save-entity2").click(); + cy.get(".validation-errors").children().should("have.length", 1); + cy.get("#field_email").clear().type(data.member.users.newUser.email); // check "Organization owner" - cy.get('#field_mainContact').click(); + cy.get("#field_mainContact").click(); // Admin checkbox should not exist - cy.get('#field_isAdmin').should('not.exist'); + cy.get("#field_isAdmin").should("not.exist"); // save - cy.get('#save-entity').click(); - cy.get('.alert-success').should('exist'); + cy.get("#save-entity").click(); + cy.get(".alert-success").should("exist"); // check org owner update email const date = new Date(); - cy.task('checkInbox', { + cy.task("checkInbox", { subject: data.outbox.ownerUpdateSubject, to: data.member.users.newUser.email, }); // check activation email and follow the provided url - cy.task('checkInbox', { + cy.task("checkInbox", { subject: data.outbox.activationSubject, to: data.member.users.newUser.email, - }).then(email => { + }).then((email) => { cy.visitLinkFromEmail(email); }); - cy.processPasswordForm('#password'); + cy.processPasswordForm("#password"); // check success message - cy.get('.alert-success').within(() => { - cy.get('a') - .filter('[jhitranslate="global.messages.info.authenticated.link.string"]') - .click(); + cy.get(".alert-success").within(() => { + cy.get("a").filter('[data-cy="navigateToSignIn"]').click(); }); // sign in and confirm the activation was successful }); - it('Change organisation owner back to the original user', function() { - cy.programmaticSignin(data.member.users.newUser.email, credentials.password); + it("Change organisation owner back to the original user", function () { + cy.programmaticSignin( + data.member.users.newUser.email, + credentials.password, + ); cy.changeOrgOwner(); }); - it('Remove added user', function() { + it("Remove added user", function () { cy.programmaticSignin(data.member.users.owner.email, credentials.password); - cy.visit('/user'); - cy.get('.btn-group').each($e => { + cy.visit("/user"); + cy.get(".btn-group").each(($e) => { cy.wrap($e) .children() .last() - .invoke('attr', 'disabled') - .then(disabled => { - disabled ? cy.log('Skipping user, button is disabled') : cy.removeAffiliation($e); + .invoke("attr", "disabled") + .then((disabled) => { + disabled + ? cy.log("Skipping user, button is disabled") + : cy.removeAffiliation($e); }); }); }); diff --git a/ui/cypress/e2e/retention/csv-add-affiliations.cy.js b/ui/cypress/e2e/retention/csv-add-affiliations.cy.js index 0779615c6..57095adb7 100644 --- a/ui/cypress/e2e/retention/csv-add-affiliations.cy.js +++ b/ui/cypress/e2e/retention/csv-add-affiliations.cy.js @@ -1,137 +1,171 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; -import record from '../../fixtures/csv-orcid-record.json'; -import { recurse } from 'cypress-recurse'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; +import record from "../../fixtures/csv-orcid-record.json"; +import { recurse } from "cypress-recurse"; -describe('Test adding affiliations via CSV', () => { +describe("Test adding affiliations via CSV", () => { beforeEach(() => { - cy.programmaticSignin(data.csvMember.users.owner.email, credentials.password); - cy.visit('/assertion'); - }) - - it('Upload CSV and check inbox for the confirmation email', function() { - cy.uploadCsv('../fixtures/affiliations.csv'); - cy.task('checkInbox', { + cy.programmaticSignin( + data.csvMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/affiliations/"); + }); + + it("Upload CSV and check inbox for the confirmation email", function () { + cy.uploadCsv("../fixtures/affiliations.csv"); + cy.task("checkInbox", { subject: data.outbox.csvUpload, to: data.csvMember.users.owner.email, - }).then(email => { + }).then((email) => { const body = email[0].body.html; - expect(body).to.have.string('The CSV upload was successfully processed with the following results:'); - expect(body).to.have.string('7\r\n\t  \r\n\t affiliations added'); - expect(body).to.have.string('0\r\n\t  \r\n\t affiliations updated'); - expect(body).to.have.string('0\r\n\t  \r\n\t affiliations deleted'); - expect(body).to.have.string('2\r\n\t  \r\n\t duplicate(s) ignored'); + expect(body).to.have.string( + "The CSV upload was successfully processed with the following results:", + ); + expect(body).to.have.string( + "7\r\n\t  \r\n\t affiliations added", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t affiliations updated", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t affiliations deleted", + ); + expect(body).to.have.string( + "2\r\n\t  \r\n\t duplicate(s) ignored", + ); }); }); - it('Grant permission and confirm that the affiliations were added to the UI and the registry', function() { - cy.get('tbody').within(() => { - cy.get('tr').each(($e) => { + it("Grant permission and confirm that the affiliations were added to the UI and the registry", function () { + cy.get("tbody").within(() => { + cy.get("tr").each(($e) => { cy.wrap($e).children().eq(0).contains(record.email); - cy.wrap($e).children().eq(1).should('not.contain', record.id); - cy.wrap($e).children().eq(4).contains('Pending'); - }) - }) + cy.wrap($e).children().eq(1).should("not.contain", record.id); + cy.wrap($e).children().eq(4).contains("Pending"); + }); + }); cy.fetchLinkAndGrantPermission(record.email); recurse( () => cy.request({ url: `https://pub.qa.orcid.org/v3.0/${record.id}/activities`, - headers: { Accept: 'application/json' } + headers: { Accept: "application/json" }, }), - res => { - expect(res.body['distinctions']['affiliation-group']).to.have.length(1); - expect(res.body['educations']['affiliation-group']).to.have.length(1); - expect(res.body['employments']['affiliation-group']).to.have.length(1); - expect(res.body['invited-positions']['affiliation-group']).to.have.length(1); - expect(res.body['memberships']['affiliation-group']).to.have.length(1); - expect(res.body['qualifications']['affiliation-group']).to.have.length(1); - expect(res.body['services']['affiliation-group']).to.have.length(1); + (res) => { + expect(res.body["distinctions"]["affiliation-group"]).to.have.length(1); + expect(res.body["educations"]["affiliation-group"]).to.have.length(1); + expect(res.body["employments"]["affiliation-group"]).to.have.length(1); + expect( + res.body["invited-positions"]["affiliation-group"], + ).to.have.length(1); + expect(res.body["memberships"]["affiliation-group"]).to.have.length(1); + expect(res.body["qualifications"]["affiliation-group"]).to.have.length( + 1, + ); + expect(res.body["services"]["affiliation-group"]).to.have.length(1); }, { log: true, limit: 20, // max number of iterations timeout: 600000, // time limit in ms - delay: 30000 // delay before next iteration, ms - } - ); - }); + delay: 30000, // delay before next iteration, ms + }, + ); + }); - it ('Check that the statuses of the affiliations have changed to "In ORCID"', function() { - cy.get('tbody').within(() => { - cy.get('tr').each(($e) => { + it('Check that the statuses of the affiliations have changed to "In ORCID"', function () { + cy.get("tbody").within(() => { + cy.get("tr").each(($e) => { cy.wrap($e).children().eq(1).contains(record.id); - cy.wrap($e).children().eq(4).contains('In ORCID'); - }) - }) - }) + cy.wrap($e).children().eq(4).contains("In ORCID"); + }); + }); + }); - it('Download the CSV and edit the contents to have the affiliations removed', function() { - cy.intercept('https://member-portal.qa.orcid.org/services/assertionservice/api/assertion/csv').as('generateCsv') - cy.get('#jh-generate-csv').click(); + it("Download the CSV and edit the contents to have the affiliations removed", function () { + cy.intercept( + "https://member-portal.qa.orcid.org/services/assertionservice/api/assertion/csv", + ).as("generateCsv"); + cy.get("#jh-generate-csv").click(); // Occasionally, trying to download the csv results in a 403 code due to an invalid CSRF token, in which case we retry - cy.wait('@generateCsv').then((int) => { + cy.wait("@generateCsv").then((int) => { if (int.response.statusCode !== 200) { - cy.get('#jh-generate-csv').click(); + cy.get("#jh-generate-csv").click(); } - }) - cy.task('checkInbox', { + }); + cy.task("checkInbox", { to: data.csvMember.users.owner.email, subject: data.outbox.csvDownload, include_attachments: true, - }).then(csv => { - const csvContents = Buffer.from(csv[0].attachments[0].data, 'base64') - .toString('ascii') + }).then((csv) => { + const csvContents = Buffer.from(csv[0].attachments[0].data, "base64") + .toString("ascii") .trim(); - const lines = csvContents.split('\n'); + const lines = csvContents.split("\n"); console.log(lines); for (var i = 1; i < lines.length; i++) { - lines[i] = ',,,,,,,,,,,,,,,' + lines[i].slice(lines[i].lastIndexOf(',')); + lines[i] = + ",,,,,,,,,,,,,,," + lines[i].slice(lines[i].lastIndexOf(",")); } - const data = lines.join('\n'); - cy.writeFile('./cypress/fixtures/downloadedAffiliations.csv', data); - }); + const data = lines.join("\n"); + cy.writeFile("./cypress/fixtures/downloadedAffiliations.csv", data); + }); }); - it('Upload second CSV and check inbox for the confirmation email', function() { - cy.uploadCsv('../fixtures/downloadedAffiliations.csv'); - cy.task('checkInbox', { + it("Upload second CSV and check inbox for the confirmation email", function () { + cy.uploadCsv("../fixtures/downloadedAffiliations.csv"); + cy.task("checkInbox", { subject: data.outbox.csvUpload, to: data.csvMember.users.owner.email, - }).then(email => { + }).then((email) => { const body = email[0].body.html; - expect(body).to.have.string('The CSV upload was successfully processed with the following results:'); - expect(body).to.have.string('0\r\n\t  \r\n\t affiliations added'); - expect(body).to.have.string('0\r\n\t  \r\n\t affiliations updated'); - expect(body).to.have.string('7\r\n\t  \r\n\t affiliations deleted'); - expect(body).to.have.string('0\r\n\t  \r\n\t duplicate(s) ignored'); + expect(body).to.have.string( + "The CSV upload was successfully processed with the following results:", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t affiliations added", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t affiliations updated", + ); + expect(body).to.have.string( + "7\r\n\t  \r\n\t affiliations deleted", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t duplicate(s) ignored", + ); }); }); - it ('Confirm that the affiliations have been removed from the UI and the registry', function() { + it("Confirm that the affiliations have been removed from the UI and the registry", function () { recurse( () => cy.request({ url: `https://pub.qa.orcid.org/v3.0/${record.id}/activities`, - headers: { Accept: 'application/json' } + headers: { Accept: "application/json" }, }), - res => { - expect(res.body['distinctions']['affiliation-group']).to.have.length(0); - expect(res.body['educations']['affiliation-group']).to.have.length(0); - expect(res.body['employments']['affiliation-group']).to.have.length(0); - expect(res.body['invited-positions']['affiliation-group']).to.have.length(0); - expect(res.body['memberships']['affiliation-group']).to.have.length(0); - expect(res.body['qualifications']['affiliation-group']).to.have.length(0); - expect(res.body['services']['affiliation-group']).to.have.length(0); + (res) => { + expect(res.body["distinctions"]["affiliation-group"]).to.have.length(0); + expect(res.body["educations"]["affiliation-group"]).to.have.length(0); + expect(res.body["employments"]["affiliation-group"]).to.have.length(0); + expect( + res.body["invited-positions"]["affiliation-group"], + ).to.have.length(0); + expect(res.body["memberships"]["affiliation-group"]).to.have.length(0); + expect(res.body["qualifications"]["affiliation-group"]).to.have.length( + 0, + ); + expect(res.body["services"]["affiliation-group"]).to.have.length(0); }, { log: true, limit: 20, // max number of iterations timeout: 600000, // time limit in ms - delay: 30000 // delay before next iteration, ms - } - ); - }) + delay: 30000, // delay before next iteration, ms + }, + ); + }); }); diff --git a/ui/cypress/e2e/retention/csv-edit-affiliations.cy.js b/ui/cypress/e2e/retention/csv-edit-affiliations.cy.js index 98d5548e7..9b792306b 100644 --- a/ui/cypress/e2e/retention/csv-edit-affiliations.cy.js +++ b/ui/cypress/e2e/retention/csv-edit-affiliations.cy.js @@ -1,77 +1,116 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; -import record from '../../fixtures/csv-populated-orcid-record.json'; -import helpers from '../../helpers/helpers.js'; -import { recurse } from 'cypress-recurse'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; +import record from "../../fixtures/csv-populated-orcid-record.json"; +import helpers from "../../helpers/helpers.js"; +import { recurse } from "cypress-recurse"; const testString = helpers.newUser.testString; -describe('Test updating affiliations via CSV', () => { +describe("Test updating affiliations via CSV", () => { beforeEach(() => { - cy.programmaticSignin(data.csvPopulatedMember.users.owner.email, credentials.password); - cy.visit('/assertion'); + cy.programmaticSignin( + data.csvPopulatedMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/affiliations/"); }); - it('Edit the contents of the existing CSV file', function() { - let editSections = ['department-name', 'org-city', 'org-name', 'role-title']; - let result = ''; - cy.readFile('./cypress/fixtures/editAffiliations.csv').then(csv => { + it("Edit the contents of the existing CSV file", function () { + let editSections = [ + "department-name", + "org-city", + "org-name", + "role-title", + ]; + let result = ""; + cy.readFile("./cypress/fixtures/editAffiliations.csv").then((csv) => { console.log(csv); - let lines = csv.trim().split('\n'); - let headers = lines[0].split(','); - result = lines[0] + '\n'; + let lines = csv.trim().split("\n"); + let headers = lines[0].split(","); + result = lines[0] + "\n"; for (var i = 1; i < lines.length; i++) { - let currentline = lines[i].split(','); + let currentline = lines[i].split(","); for (var j = 0; j < headers.length; j++) { - if (editSections.includes(headers[j])) currentline[j] = `"${testString}"`; + if (editSections.includes(headers[j])) + currentline[j] = `"${testString}"`; } - result += currentline.join(',') + '\n'; + result += currentline.join(",") + "\n"; } console.log(result); - cy.writeFile('./cypress/fixtures/editAffiliations.csv', result); - }) - + cy.writeFile("./cypress/fixtures/editAffiliations.csv", result); + }); }); - it('Upload CSV and check inbox for the confirmation email', function() { - cy.uploadCsv('../fixtures/editAffiliations.csv'); - cy.task('checkInbox', { + it("Upload CSV and check inbox for the confirmation email", function () { + cy.uploadCsv("../fixtures/editAffiliations.csv"); + cy.task("checkInbox", { subject: data.outbox.csvUpload, - to: data.csvPopulatedMember.users.owner.email - }).then(email => { + to: data.csvPopulatedMember.users.owner.email, + }).then((email) => { const body = email[0].body.html; - expect(body).to.have.string('The CSV upload was successfully processed with the following results:'); - expect(body).to.have.string('0\r\n\t  \r\n\t affiliations added'); - expect(body).to.have.string('7\r\n\t  \r\n\t affiliations updated'); - expect(body).to.have.string('0\r\n\t  \r\n\t affiliations deleted'); - expect(body).to.have.string('0\r\n\t  \r\n\t duplicate(s) ignored'); + expect(body).to.have.string( + "The CSV upload was successfully processed with the following results:", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t affiliations added", + ); + expect(body).to.have.string( + "7\r\n\t  \r\n\t affiliations updated", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t affiliations deleted", + ); + expect(body).to.have.string( + "0\r\n\t  \r\n\t duplicate(s) ignored", + ); }); }); - it('Confirm the changes in the registry', function() { + it("Confirm the changes in the registry", function () { recurse( () => cy.request({ url: `https://pub.qa.orcid.org/v3.0/${record.id}/activities`, - headers: { Accept: 'application/json' } + headers: { Accept: "application/json" }, }), - res => { - const distinction = res.body['distinctions']['affiliation-group'][0]['summaries'][0]['distinction-summary']; - const education = res.body['educations']['affiliation-group'][0]['summaries'][0]['education-summary']; - const employment = res.body['employments']['affiliation-group'][0]['summaries'][0]['employment-summary']; - const invitedPosition = res.body['invited-positions']['affiliation-group'][0]['summaries'][0]['invited-position-summary']; - const membership = res.body['memberships']['affiliation-group'][0]['summaries'][0]['membership-summary']; - const qualification = res.body['qualifications']['affiliation-group'][0]['summaries'][0]['qualification-summary']; - const service = res.body['services']['affiliation-group'][0]['summaries'][0]['service-summary']; + (res) => { + const distinction = + res.body["distinctions"]["affiliation-group"][0]["summaries"][0][ + "distinction-summary" + ]; + const education = + res.body["educations"]["affiliation-group"][0]["summaries"][0][ + "education-summary" + ]; + const employment = + res.body["employments"]["affiliation-group"][0]["summaries"][0][ + "employment-summary" + ]; + const invitedPosition = + res.body["invited-positions"]["affiliation-group"][0]["summaries"][0][ + "invited-position-summary" + ]; + const membership = + res.body["memberships"]["affiliation-group"][0]["summaries"][0][ + "membership-summary" + ]; + const qualification = + res.body["qualifications"]["affiliation-group"][0]["summaries"][0][ + "qualification-summary" + ]; + const service = + res.body["services"]["affiliation-group"][0]["summaries"][0][ + "service-summary" + ]; const trimmedString = testString.trim(); // cy.checkAffiliationChanges will not retry on fail, which is why we make sure all sections got updated before asserting everything - expect(distinction['department-name']).to.eq(trimmedString); - expect(education['department-name']).to.eq(trimmedString); - expect(employment['department-name']).to.eq(trimmedString); - expect(invitedPosition['department-name']).to.eq(trimmedString); - expect(membership['department-name']).to.eq(trimmedString); - expect(qualification['department-name']).to.eq(trimmedString); - expect(service['department-name']).to.eq(trimmedString); + expect(distinction["department-name"]).to.eq(trimmedString); + expect(education["department-name"]).to.eq(trimmedString); + expect(employment["department-name"]).to.eq(trimmedString); + expect(invitedPosition["department-name"]).to.eq(trimmedString); + expect(membership["department-name"]).to.eq(trimmedString); + expect(qualification["department-name"]).to.eq(trimmedString); + expect(service["department-name"]).to.eq(trimmedString); cy.checkAffiliationChanges(distinction, trimmedString); cy.checkAffiliationChanges(education, trimmedString); cy.checkAffiliationChanges(employment, trimmedString); @@ -84,8 +123,8 @@ describe('Test updating affiliations via CSV', () => { log: true, limit: 20, // max number of iterations timeout: 600000, // time limit in ms - delay: 30000 // delay before next iteration, ms - } - ); - }) + delay: 30000, // delay before next iteration, ms + }, + ); + }); }); diff --git a/ui/cypress/e2e/retention/csv-invalid-affiliations.cy.js b/ui/cypress/e2e/retention/csv-invalid-affiliations.cy.js index de11a9b11..2e4ed38ad 100644 --- a/ui/cypress/e2e/retention/csv-invalid-affiliations.cy.js +++ b/ui/cypress/e2e/retention/csv-invalid-affiliations.cy.js @@ -1,18 +1,23 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; -describe('Test invalid CSV upload', () => { - it('Upload CSV and check inbox for the error message', function() { - cy.programmaticSignin(data.csvMember.users.owner.email, credentials.password); - cy.visit('/assertion'); - cy.uploadCsv('../fixtures/invalidAffiliations.csv'); - cy.task('checkInbox', { +describe("Test invalid CSV upload", () => { + it("Upload CSV and check inbox for the error message", function () { + cy.programmaticSignin( + data.csvMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/affiliations/"); + cy.uploadCsv("../fixtures/invalidAffiliations.csv"); + cy.task("checkInbox", { subject: data.outbox.csvUpload, - to: data.csvMember.users.owner.email - }).then(email => { + to: data.csvMember.users.owner.email, + }).then((email) => { const body = email[0].body.html; - expect(body).to.have.string('There was a problem with your CSV upload. Pleases fix the errors below and try again.'); + expect(body).to.have.string( + "There was a problem with your CSV upload. Pleases fix the errors below and try again.", + ); }); }); }); diff --git a/ui/cypress/e2e/retention/edit-affiliation.cy.js b/ui/cypress/e2e/retention/edit-affiliation.cy.js index 00276d04c..39a343354 100644 --- a/ui/cypress/e2e/retention/edit-affiliation.cy.js +++ b/ui/cypress/e2e/retention/edit-affiliation.cy.js @@ -1,69 +1,62 @@ /// -import data from '../../fixtures/test-data.json'; -import record from '../../fixtures/populated-orcid-record.json'; -import credentials from '../../fixtures/credentials.json'; -import helpers from '../../helpers/helpers.js'; -import { recurse } from 'cypress-recurse'; +import data from "../../fixtures/test-data.json"; +import record from "../../fixtures/populated-orcid-record.json"; +import credentials from "../../fixtures/credentials.json"; +import helpers from "../../helpers/helpers.js"; +import { recurse } from "cypress-recurse"; const testString = helpers.newUser.testString; -describe('Edit an affiliation', () => { +describe("Edit an affiliation", () => { beforeEach(() => { - cy.programmaticSignin(data.populatedMember.users.owner.email, credentials.password); - }) - it('Edit affiliation in the member portal', function() { - cy.visit('/assertion') - cy.visit(`/assertion/${record.affiliation.id}/edit`); + cy.programmaticSignin( + data.populatedMember.users.owner.email, + credentials.password, + ); + }); + it("Edit affiliation in the member portal", function () { + cy.visit("ui/en/affiliations"); + cy.visit(`ui/en/affiliations/${record.affiliation.id}/edit`); - cy.get('#field_orgName') - .clear() - .type(testString); - cy.get('#field_orgCity') - .clear() - .type(testString); - cy.get('#field_departmentName') - .clear() - .type(testString); - cy.get('#field_roleTitle') - .clear() - .type(testString); - cy.get('#save-entity').click(); - - cy.get('tbody') + cy.get("#field_orgName").clear().type(testString); + cy.get("#field_orgCity").clear().type(testString); + cy.get("#field_departmentName").clear().type(testString); + cy.get("#field_roleTitle").clear().type(testString); + cy.get("#save-entity").click(); + + cy.get("tbody") .children() .first() .children() .eq(4) - .contains('Pending update in ORCID'); + .contains("Pending update in ORCID"); }); - it('Confirm the affiliation has been updated in the registry', () => { + it("Confirm the affiliation has been updated in the registry", () => { recurse( () => cy.request({ url: `https://pub.qa.orcid.org/v3.0/${record.id}/educations`, - headers: { Accept: 'application/json' } + headers: { Accept: "application/json" }, }), - res => { - const education = res.body['affiliation-group'][0]['summaries'][0]['education-summary']; - expect(res.body['affiliation-group']).to.have.length(1); - expect(education['department-name']).to.eq(testString); - expect(education['role-title']).to.eq(testString); - expect(education['organization']['address']['city']).to.eq(testString.trim()); - expect(education['organization']['name']).to.eq(testString.trim()); + (res) => { + const education = + res.body["affiliation-group"][0]["summaries"][0]["education-summary"]; + expect(res.body["affiliation-group"]).to.have.length(1); + expect(education["department-name"]).to.eq(testString); + expect(education["role-title"]).to.eq(testString); + expect(education["organization"]["address"]["city"]).to.eq( + testString.trim(), + ); + expect(education["organization"]["name"]).to.eq(testString.trim()); }, { log: true, limit: 20, // max number of iterations timeout: 600000, // time limit in ms - delay: 30000 // delay before next iteration, ms - } + delay: 30000, // delay before next iteration, ms + }, ); - cy.visit('assertion') - cy.get('tbody') - .children() - .first() - .children() - .eq(4) - .contains('In ORCID'); + cy.visit("ui/en/affiliations/"); + cy.get("tbody").children().first().children().eq(4).contains("In ORCID"); }); }); diff --git a/ui/cypress/e2e/retention/edit-member.cy.js b/ui/cypress/e2e/retention/edit-member.cy.js index a3002fae8..6afa597f5 100644 --- a/ui/cypress/e2e/retention/edit-member.cy.js +++ b/ui/cypress/e2e/retention/edit-member.cy.js @@ -1,70 +1,42 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; const { salesforceId, clientName, clientId } = data.member; -describe('Manage members menu', () => { - it('Test edit member form', function() { +describe("Manage members menu", () => { + it("Test edit member form", function () { cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword); - cy.visit(`/member/${data.member.id}/edit`); - cy.get('#field_isConsortiumLead') - .should('be.checked') - .uncheck(); - cy.get('#field_salesforceId') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_parentSalesforceId') - .clear() - .type(clientName); + cy.visit(`ui/en/members/${data.member.id}/edit`); + cy.get("#field_isConsortiumLead").should("be.checked").uncheck(); + cy.get("#field_salesforceId").invoke("attr", "disabled").should("exist"); + cy.get("#field_parentSalesforceId").clear().type(clientName); // Shouldn't be able to save without a client name - cy.get('#field_clientName').clear(); - cy.get('#save-entity') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('small') - .filter('[jhitranslate="entity.validation.required.string"]') - .should('exist'); + cy.get("#field_clientName").clear(); + cy.get("#save-entity").invoke("attr", "disabled").should("exist"); + cy.get("small").filter('[data-cy="fieldIsRequired"]').should("exist"); // Enter existing client name and check for relevant error message - cy.get('#field_clientName').type(data.populatedMember.clientName); - cy.get('#save-entity').click(); - cy.get('.validation-errors') - .children() - .should('have.length', 1); - cy.get('#field_clientName') - .clear() - .type(clientName); + cy.get("#field_clientName").type(data.populatedMember.clientName); + cy.get("#save-entity").click(); + cy.get(".validation-errors").children().should("have.length", 1); + cy.get("#field_clientName").clear().type(clientName); // Check client id warning message - cy.get('#field_clientId').type(data.invalidString); - cy.get('small').should('exist'); - cy.get('#save-entity') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_clientId').clear(); - cy.get('#field_clientId').type(clientId); + cy.get("#field_clientId").type(data.invalidString); + cy.get("small").should("exist"); + cy.get("#save-entity").invoke("attr", "disabled").should("exist"); + cy.get("#field_clientId").clear(); + cy.get("#field_clientId").type(clientId); // Assertions enabled checkbox should be unchecked after clearing client id field - cy.get('#field_assertionServiceEnabled') - .should('not.be.checked') - .check(); + cy.get("#field_assertionServiceEnabled").should("not.be.checked").check(); // Parent salesforce id for consortium lead members must match salesforce id or be blank - cy.get('#field_isConsortiumLead') - .should('not.be.checked') - .check(); - cy.get('#save-entity') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_parentSalesforceId') - .clear() - .type(salesforceId); - cy.get('#save-entity') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_salesforceId') - .invoke('val') - .then(id => { - cy.get('#field_parentSalesforceId') - .clear() - .type(id); - cy.get('#save-entity').click(); + cy.get("#field_isConsortiumLead").should("not.be.checked").check(); + cy.get("#save-entity").invoke("attr", "disabled").should("exist"); + cy.get("#field_parentSalesforceId").clear().type(salesforceId); + cy.get("#save-entity").invoke("attr", "disabled").should("exist"); + cy.get("#field_salesforceId") + .invoke("val") + .then((id) => { + cy.get("#field_parentSalesforceId").clear().type(id); + cy.get("#save-entity").click(); }); }); }); diff --git a/ui/cypress/e2e/retention/edit-user.cy.js b/ui/cypress/e2e/retention/edit-user.cy.js index be041aedd..2a5186e31 100644 --- a/ui/cypress/e2e/retention/edit-user.cy.js +++ b/ui/cypress/e2e/retention/edit-user.cy.js @@ -1,49 +1,40 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; -describe('Test the edit user form', () => { - it('Edit user', function() { - cy.programmaticSignin(data.populatedMember.users.owner.email, credentials.password); - cy.visit(`/user/${data.populatedMember.users.owner.id}/edit`); +describe("Test the edit user form", () => { + it("Edit user", function () { + cy.programmaticSignin( + data.populatedMember.users.owner.email, + credentials.password, + ); + cy.visit(`ui/en/users/${data.populatedMember.users.owner.id}/edit`); // Clear first name input field - cy.get('#field_firstName').clear(); + cy.get("#field_firstName").clear(); // Shouldn't be possible to save with an empty name field - cy.get('#save-entity2') - .invoke('attr', 'disabled') - .should('exist'); + cy.get("#save-entity2").invoke("attr", "disabled").should("exist"); // Check for 'required' flag on the input field - cy.get('#field_firstName') - .should('have.class', 'ng-invalid') - .type("Automated") + cy.get("#field_firstName") + .should("have.class", "ng-invalid") + .type("Automated"); // Clear last name input field - cy.get('#field_lastName').clear(); + cy.get("#field_lastName").clear(); // Shouldn't be possible to save with an empty name field - cy.get('#save-entity2') - .invoke('attr', 'disabled') - .should('exist'); + cy.get("#save-entity2").invoke("attr", "disabled").should("exist"); // Check for 'required' flag on the input field - cy.get('#field_lastName') - .should('have.class', 'ng-invalid') - .type("Test") + cy.get("#field_lastName").should("have.class", "ng-invalid").type("Test"); // Check disabled fields - cy.get('#field_email') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_mainContact') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#field_salesforceId') - .invoke('attr', 'disabled') - .should('exist'); + cy.get("#field_email").invoke("attr", "disabled").should("exist"); + cy.get("#field_mainContact").invoke("attr", "disabled").should("exist"); + cy.get("#field_salesforceId").invoke("attr", "disabled").should("exist"); // Admin checkbox should not exist - cy.get('#field_isAdmin').should('not.exist'); - // 'Activated' checkbox is missing the 'disabled' attr + cy.get("#field_isAdmin").should("not.exist"); + // 'Activated' checkbox is missing the 'disabled' attr /*cy.get('#field_activated') .invoke('attr', 'disabled') .should('exist');*/ // save - cy.get('#save-entity2').click(); - cy.get('.alert-success').should('exist'); - }); + cy.get("#save-entity2").click(); + cy.get(".alert-success").should("exist"); + }); }); diff --git a/ui/cypress/e2e/retention/notifications.cy.js b/ui/cypress/e2e/retention/notifications.cy.js index 6e082fe32..ffcdfdbeb 100644 --- a/ui/cypress/e2e/retention/notifications.cy.js +++ b/ui/cypress/e2e/retention/notifications.cy.js @@ -1,108 +1,132 @@ /// -import data from '../../fixtures/test-data.json'; -import record from '../../fixtures/orcid-record.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import record from "../../fixtures/orcid-record.json"; +import credentials from "../../fixtures/credentials.json"; const { country, type } = record.affiliation; const { ror } = record.affiliation.org; -describe('Test notifications', () => { - it('Add an affiliation with an email missing from the registry', function() { - cy.programmaticSignin(data.notificationsMember.users.owner.email, credentials.password); - cy.visit('/assertion/new'); - cy.get('#field_email').type(record.nonregisteredEmail); - cy.get('#field_affiliationSection').select(type); - cy.get('#field_orgName').type(data.testString); - cy.get('#field_orgCity').type(data.testString); - cy.get('#field_orgCountry').select(country); - cy.get('#field_disambiguationSource').select(ror.name); - cy.get('#field_disambiguatedOrgId').type(ror.id); - cy.get('#save-entity').click(); - cy.get('.alert-success').should('exist'); +describe("Test notifications", () => { + it("Add an affiliation with an email missing from the registry", function () { + cy.programmaticSignin( + data.notificationsMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/affiliations/new"); + cy.get("#field_email").type(record.nonregisteredEmail); + cy.get("#field_affiliationSection").select(type); + cy.get("#field_orgName").type(data.testString); + cy.get("#field_orgCity").type(data.testString); + cy.get("#field_orgCountry").select(country); + cy.get("#field_disambiguationSource").select(ror.name); + cy.get("#field_disambiguatedOrgId").type(ror.id); + cy.get("#save-entity").click(); + cy.get(".alert-success").should("exist"); cy.programmaticSignout(); }); - it('Add an affiliation with an email present in the registry and generate notifications', function() { - cy.programmaticSignin(data.notificationsMember.users.owner.email, credentials.password); - cy.visit('/assertion/new'); - cy.get('#field_email').type(record.email); - cy.get('#field_affiliationSection').select(type); - cy.get('#field_orgName').type(data.testString + ' 2'); - cy.get('#field_orgCity').type(data.testString + ' 2'); - cy.get('#field_orgCountry').select(country); - cy.get('#field_disambiguationSource').select(ror.name); - cy.get('#field_disambiguatedOrgId').type(ror.id); - cy.get('#save-entity').click(); - cy.get('.alert-success').should('exist'); - cy.visit('/assertion'); - cy.get('#jh-send-notifications').click(); - cy.get('#langKey').should('have.value', data.italianLanguageCode); - cy.get('#jhi-confirm-csv-upload').click(); - cy.get('.alert-success').should('exist'); - cy.get('tbody') - .children() - .should('have.length', 2); - cy.get('tbody') + it("Add an affiliation with an email present in the registry and generate notifications", function () { + cy.programmaticSignin( + data.notificationsMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/affiliations/new"); + cy.get("#field_email").type(record.email); + cy.get("#field_affiliationSection").select(type); + cy.get("#field_orgName").type(data.testString + " 2"); + cy.get("#field_orgCity").type(data.testString + " 2"); + cy.get("#field_orgCountry").select(country); + cy.get("#field_disambiguationSource").select(ror.name); + cy.get("#field_disambiguatedOrgId").type(ror.id); + cy.get("#save-entity").click(); + cy.get(".alert-success").should("exist"); + cy.visit("ui/en/affiliations"); + cy.get("button").filter('[data-cy="sendNotifications"]').click(); + cy.get("#langKey").should("have.value", data.italianLanguageCode); + cy.get("button").filter('[data-cy="confirmCsvUpload"]').click(); + cy.get(".alert-success").should("exist"); + cy.get("tbody").children().should("have.length", 2); + cy.get("tbody") .children() .eq(0) .children() .eq(4) - .contains('Notification requested'); - cy.get('tbody') + .contains("Notification requested"); + cy.get("tbody") .children() .eq(1) .children() .eq(4) - .contains('Notification requested'); + .contains("Notification requested"); cy.programmaticSignout(); }); - it('Check inbox for succesful notfications confirmation', function() { - cy.task('checkInbox', { + it("Check inbox for succesful notfications confirmation", function () { + cy.task("checkInbox", { subject: data.outbox.notificationConfirmation, - to: data.notificationsMember.users.owner.email - }).then(email => { + to: data.notificationsMember.users.owner.email, + }).then((email) => { const body = email[0].body.html; - expect(body).to.have.string('Thank you for choosing to use the permission notification process.'); - expect(body).to.have.string('1\r\n  \r\n ORCID inbox notifications'); - expect(body).to.have.string('1\r\n  \r\n emails'); + expect(body).to.have.string( + "Thank you for choosing to use the permission notification process.", + ); + expect(body).to.have.string( + "1\r\n  \r\n ORCID inbox notifications", + ); + expect(body).to.have.string( + "1\r\n  \r\n emails", + ); }); }); - it('Check inbox for translated notification for non-registered email', function() { - cy.task('checkInbox', { + it("Check inbox for translated notification for non-registered email", function () { + cy.task("checkInbox", { subject: data.outbox.notificationNonRegisteredUserItalian, - to: record.nonregisteredEmail - }).then(email => { + to: record.nonregisteredEmail, + }).then((email) => { const body = email[0].body.html; cy.log(body); - expect(body).to.have.string('Consentendo a NOTIFICATIONS TEST di aggiungere le informazioni di ricerca al tuo record ORCID, puoi dedicare più tempo alla ricerca e meno alla gestione! Prima però avremo bisogno del tuo permesso, quindi clicca sul link di seguito per iniziare. Ti reindirizzeremo su ORCID; dopo aver eseguito l’accesso, clicca su “autorizza accesso” per consentire a NOTIFICATIONS TEST di aggiungere informazioni al tuo record'); - expect(body).to.have.string('Dopo aver concesso il permesso, al tuo record ORCID verrà aggiunta una voce di affiliazione. Tieni presente che potrebbero volerci fino a 5 minuti per l’aggiornamento del tuo record ORCID.'); + expect(body).to.have.string( + "Consentendo a NOTIFICATIONS TEST di aggiungere le informazioni di ricerca al tuo record ORCID, puoi dedicare più tempo alla ricerca e meno alla gestione! Prima però avremo bisogno del tuo permesso, quindi clicca sul link di seguito per iniziare. Ti reindirizzeremo su ORCID; dopo aver eseguito l’accesso, clicca su “autorizza accesso” per consentire a NOTIFICATIONS TEST di aggiungere informazioni al tuo record", + ); + expect(body).to.have.string( + "Dopo aver concesso il permesso, al tuo record ORCID verrà aggiunta una voce di affiliazione. Tieni presente che potrebbero volerci fino a 5 minuti per l’aggiornamento del tuo record ORCID.", + ); }); }); - it('Check inbox for translated notification for the registered email', function() { - cy.task('checkInbox', { + it("Check inbox for translated notification for the registered email", function () { + cy.task("checkInbox", { subject: data.outbox.notificationRegisteredUser, to: record.email, - from: data.outbox.updateEmail - }).then(email => { + from: data.outbox.updateEmail, + }).then((email) => { const body = email[0].body.html; - expect(body).to.have.string('Le affiliazioni possono essere aggiunte al tuo archivio dalle organizzazioni a te associate. Questo ti fa risparmiare tempo e aumenta il livello di fiducia in archivio.'); - expect(body).to.have.string('Grant permission \r\n '); - expect(body).to.have.string('href="https://qa.orcid.org/inbox/encrypted/'); - expect(body).to.have.string('ORCID Member Portal - QA\r\n has asked for permission to make changes to your ORCID record'); + expect(body).to.have.string( + "Le affiliazioni possono essere aggiunte al tuo archivio dalle organizzazioni a te associate. Questo ti fa risparmiare tempo e aumenta il livello di fiducia in archivio.", + ); + expect(body).to.have.string( + "Grant permission \r\n ", + ); + expect(body).to.have.string( + 'href="https://qa.orcid.org/inbox/encrypted/', + ); + expect(body).to.have.string( + "ORCID Member Portal - QA\r\n has asked for permission to make changes to your ORCID record", + ); }); }); - it('Delete added affiliations', function() { - cy.programmaticSignin(data.notificationsMember.users.owner.email, credentials.password); - cy.visit('/assertion') - cy.get('.btn-group').each($e => { - cy.wrap($e).children().last().click() - cy.get('#jhi-confirm-delete-assertion').click() - }) - cy.programmaticSignout() + it("Delete added affiliations", function () { + cy.programmaticSignin( + data.notificationsMember.users.owner.email, + credentials.password, + ); + cy.visit("/assertion"); + cy.get(".btn-group").each(($e) => { + cy.wrap($e).children().last().click(); + cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click(); + }); + cy.programmaticSignout(); }); - }); diff --git a/ui/cypress/e2e/retention/reset-password.cy.js b/ui/cypress/e2e/retention/reset-password.cy.js index 4375d5c3a..0ad752bf1 100644 --- a/ui/cypress/e2e/retention/reset-password.cy.js +++ b/ui/cypress/e2e/retention/reset-password.cy.js @@ -1,58 +1,49 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; -describe('Test the password reset functionality', () => { - it('Forgot your password?', function() { - cy.visit('/reset/request'); - cy.get('#email').type(data.invalidEmail); - cy.get('small') - .filter('[jhitranslate="global.messages.validate.email.invalid.string"]') - .should('exist'); - cy.get('button') +describe("Test the password reset functionality", () => { + it("Forgot your password?", function () { + cy.visit("ui/en/reset/request"); + cy.get("#email").type(data.invalidEmail); + cy.get("small").filter('[data-cy="emailInvalid"]').should("exist"); + cy.get("button") .filter('[type="submit"]') - .invoke('attr', 'disabled') - .should('exist'); - cy.get('#email') - .clear() - .type(data.member.users.owner.email); - cy.get('button') - .filter('[type="submit"]') - .click(); + .invoke("attr", "disabled") + .should("exist"); + cy.get("#email").clear().type(data.member.users.owner.email); + cy.get("button").filter('[type="submit"]').click(); - cy.task('checkInbox', { - to: data.member.users.owner.email, - subject: data.outbox.resetPasswordSubject - }).then(email => { + cy.task("checkInbox", { + to: data.member.users.owner.email, + subject: data.outbox.resetPasswordSubject, + }).then((email) => { cy.visitLinkFromEmail(email); }); - - cy.processPasswordForm('#password'); - cy.get('.alert-success').within(() => { - cy.get('a') - .filter('[jhitranslate="global.messages.info.authenticated.link.string"]') - .click(); + cy.processPasswordForm("#password"); + + cy.get(".alert-success").within(() => { + cy.get("a").filter('data-cy="navigateToSignIn"]').click(); }); // sign in and confirm the activation was successful cy.programmaticSignin(data.member.users.owner.email, credentials.password); cy.programmaticSignout(); }); - it('Change password', function() { - cy.programmaticSignin(data.populatedMember.users.owner.email, credentials.password); - cy.visit('/password'); - cy.get('#currentPassword').type(credentials.wrongConfirmationPasssword); - cy.processPasswordForm('#newPassword'); - cy.get('.alert-danger') - .filter('[jhitranslate="password.messages.error.string"]') - .should('exist'); - cy.get('#currentPassword') - .clear() - .type(credentials.password); - cy.get('button') - .filter('[type="submit"]') - .click(); - cy.get('.alert-success').should('exist'); + it("Change password", function () { + cy.programmaticSignin( + data.populatedMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/password"); + cy.get("#currentPassword").type(credentials.wrongConfirmationPasssword); + cy.processPasswordForm("#newPassword"); + cy.get(".alert-danger") + .filter('data-cy="passwordChangeError"]') + .should("exist"); + cy.get("#currentPassword").clear().type(credentials.password); + cy.get("button").filter('[type="submit"]').click(); + cy.get(".alert-success").should("exist"); }); }); diff --git a/ui/cypress/e2e/retention/restricted-access.cy.js b/ui/cypress/e2e/retention/restricted-access.cy.js index 875b642fd..5a01abff7 100644 --- a/ui/cypress/e2e/retention/restricted-access.cy.js +++ b/ui/cypress/e2e/retention/restricted-access.cy.js @@ -1,49 +1,81 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; -describe('Test restricted access', () => { +describe("Test restricted access", () => { afterEach(() => { cy.programmaticSignout(); - }) + }); - it('Regular users should not be able to access the Manage Members menu', function() { - cy.programmaticSignin(data.populatedMember.users.user.email, credentials.password); - cy.visit('/member'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + it("Regular users should not be able to access the Manage Members menu", function () { + cy.programmaticSignin( + data.populatedMember.users.user.email, + credentials.password, + ); + cy.visit("ui/en/members"); + cy.get("h1") + .filter('[data-cy="cannotProcessRequest"]') + .contains("Your request cannot be processed"); + cy.get("div") + .filter('[data-cy="notauthorized"]') + .invoke("attr", "hidden") + .should("not.exist"); }); - it('Regular users should not be able to access the Manage Users menu', function() { - cy.programmaticSignin(data.populatedMember.users.user.email, credentials.password); - cy.visit('/user'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + it("Regular users should not be able to access the Manage Users menu", function () { + cy.programmaticSignin( + data.populatedMember.users.user.email, + credentials.password, + ); + cy.visit("ui/en/users"); + cy.get("h1") + .filter('[data-cy="cannotProcessRequest"]') + .contains("Your request cannot be processed"); + cy.get("div") + .filter('[data-cy="notauthorized"]') + .invoke("attr", "hidden") + .should("not.exist"); }); - it('Org owners should not be able to access the Manage Members menu', function() { - cy.programmaticSignin(data.populatedMember.users.owner.email, credentials.password); - cy.visit('/member'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + it("Org owners should not be able to access the Manage Members menu", function () { + cy.programmaticSignin( + data.populatedMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/members"); + cy.get("h1") + .filter('[data-cy="cannotProcessRequest"]') + .contains("Your request cannot be processed"); + cy.get("div") + .filter('[data-cy="notauthorized"]') + .invoke("attr", "hidden") + .should("not.exist"); }); - it('Cannot access the assertion menu if assertions are not enabled', function() { - cy.programmaticSignin(data.homepageTestMembers.consortiumLeadAndMember.email, credentials.password); - cy.visit('/assertion'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + it("Cannot access the assertion menu if assertions are not enabled", function () { + cy.programmaticSignin( + data.homepageTestMembers.consortiumLeadAndMember.email, + credentials.password, + ); + cy.visit("ui/en/affiliations"); + cy.get("h1") + .filter('[data-cy="cannotProcessRequest"]') + .contains("Your request cannot be processed"); + cy.get("div") + .filter('[data-cy="notauthorized"]') + .invoke("attr", "hidden") + .should("not.exist"); }); /* it('Anonymous users cannot access anything', function() { cy.visit('/assertion'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + cy.get('h1').filter('[data-cy="cannotProcessRequest"]').contains('Your request cannot be processed') + cy.get('div').filter('[data-cy="notauthorized"]').invoke('attr', 'hidden').should('not.exist') cy.visit('/user'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + cy.get('h1').filter('[data-cy="cannotProcessRequest"]').contains('Your request cannot be processed') + cy.get('div').filter('[data-cy="notauthorized"]').invoke('attr', 'hidden').should('not.exist') cy.visit('/member'); - cy.get('h1').filter('[jhitranslate="error.title.string"]').contains('Your request cannot be processed') - cy.get('div').filter('[jhitranslate="error.http.403.string"]').invoke('attr', 'hidden').should('not.exist') + cy.get('h1').filter('[data-cy="cannotProcessRequest"]').contains('Your request cannot be processed') + cy.get('div').filter('[data-cy="notauthorized"]').invoke('attr', 'hidden').should('not.exist') }); */ }); diff --git a/ui/cypress/e2e/retention/ui-authorities.cy.js b/ui/cypress/e2e/retention/ui-authorities.cy.js index 19886e6c8..5ca44e3c7 100644 --- a/ui/cypress/e2e/retention/ui-authorities.cy.js +++ b/ui/cypress/e2e/retention/ui-authorities.cy.js @@ -1,8 +1,8 @@ /// -import data from '../../fixtures/test-data.json'; -import credentials from '../../fixtures/credentials.json'; +import data from "../../fixtures/test-data.json"; +import credentials from "../../fixtures/credentials.json"; -describe('Test authorities', () => { +describe("Test authorities", () => { afterEach(() => { cy.programmaticSignout(); }); @@ -14,47 +14,89 @@ describe('Test authorities', () => { * ************************************************************************************************************************ */ - it('User', function () { - cy.programmaticSignin(data.populatedMember.users.user.email, credentials.password); - cy.visit('/'); - cy.get('#admin-menu').should('not.exist'); - cy.get('#entity-menu').should('exist'); - cy.get('a') - .filter('[href="/assertion"]') - .should('exist'); - cy.get('a') - .filter('[href="/user"]') - .should('not.exist'); - cy.get('a') - .filter('[href="/member"]') - .should('not.exist'); + it("User", function () { + cy.programmaticSignin( + data.populatedMember.users.user.email, + credentials.password, + ); + cy.visit("ui/en/"); + cy.get("#admin-menu").should("not.exist"); + cy.get("#entity-menu").should("exist"); + cy.get("a").filter('[routerLink="/affiliations"]').should("exist"); + cy.get("a").filter('[routerLink="/users"]').should("not.exist"); + cy.get("a").filter('[routerLink="/members"]').should("not.exist"); cy.getUsersBySfId(data.populatedMember.salesforceId, 401); - cy.getUsersBySfId(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 400, "Salesforce id doesn't match current user's memeber"); - cy.getAllUsers(403, 'Forbidden'); - cy.getAllMembers(403, 'Forbidden'); - cy.addMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); - cy.updateMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); - cy.validateMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); + cy.getUsersBySfId( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 400, + "Salesforce id doesn't match current user's memeber", + ); + cy.getAllUsers(403, "Forbidden"); + cy.getAllMembers(403, "Forbidden"); + cy.addMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); + cy.updateMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); + cy.validateMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); //cy.changeNotificationLanguage(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, data.italianLanguageCode, 401); - cy.updateContact(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.updateMemberDetails(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, "The Harvest Ascendancy", 401, 'Unauthorized'); - cy.getMemberDetails(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberContacts(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberOrgIds(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - - - cy.getMembersList(403, 'Forbidden'); + cy.updateContact( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.updateMemberDetails( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + "The Harvest Ascendancy", + 401, + "Unauthorized", + ); + cy.getMemberDetails( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberContacts( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberOrgIds( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + + cy.getMembersList(403, "Forbidden"); // TODO: Awaiting endpoint changes - cy.getMember(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 200); + cy.getMember( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 200, + ); - cy.deleteMember(data.populatedMember.salesforceId, 403, 'Forbidden'); + cy.deleteMember(data.populatedMember.salesforceId, 403, "Forbidden"); - cy.addConsortiumMember(403, 'Forbidden'); - cy.removeConsortiumMember(403, 'Forbidden'); + cy.addConsortiumMember(403, "Forbidden"); + cy.removeConsortiumMember(403, "Forbidden"); cy.getAssertions(200); }); @@ -66,47 +108,89 @@ describe('Test authorities', () => { * ************************************************************************************************************************ */ - it('Org owner', function () { - cy.programmaticSignin(data.populatedMember.users.owner.email, credentials.password); - cy.visit('/'); - cy.get('#admin-menu').should('exist'); - cy.get('#entity-menu').should('exist'); - cy.get('a') - .filter('[href="/user"]') - .should('exist'); - cy.get('a') - .filter('[href="/assertion"]') - .should('exist'); - cy.get('a') - .filter('[href="/member"]') - .should('not.exist'); + it("Org owner", function () { + cy.programmaticSignin( + data.populatedMember.users.owner.email, + credentials.password, + ); + cy.visit("ui/en/"); + cy.get("#admin-menu").should("exist"); + cy.get("#entity-menu").should("exist"); + cy.get("a").filter('[routerlink="/users"]').should("exist"); + cy.get("a").filter('[routerlink="/affiliations"]').should("exist"); + cy.get("a").filter('[routerlink="/member"]').should("not.exist"); cy.getUsersBySfId(data.populatedMember.salesforceId, 200); - cy.getUsersBySfId(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 400, "Salesforce id doesn't match current user's memeber"); - cy.getAllUsers(403, 'Forbidden'); - cy.getAllMembers(403, 'Forbidden'); - cy.addMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); - cy.updateMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); - cy.validateMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); + cy.getUsersBySfId( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 400, + "Salesforce id doesn't match current user's memeber", + ); + cy.getAllUsers(403, "Forbidden"); + cy.getAllMembers(403, "Forbidden"); + cy.addMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); + cy.updateMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); + cy.validateMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); //cy.changeNotificationLanguage(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, data.italianLanguageCode, 401); - cy.updateContact(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.updateMemberDetails(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 'The Harvest Ascendancy', 401, 'Unauthorized'); - cy.getMemberDetails(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberContacts(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberOrgIds(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - - - cy.getMembersList(403, 'Forbidden'); + cy.updateContact( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.updateMemberDetails( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + "The Harvest Ascendancy", + 401, + "Unauthorized", + ); + cy.getMemberDetails( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberContacts( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberOrgIds( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + + cy.getMembersList(403, "Forbidden"); // TODO: Awaiting endpoint changes - cy.getMember(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 200); + cy.getMember( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 200, + ); - cy.addConsortiumMember(403, 'Forbidden'); - cy.removeConsortiumMember(403, 'Forbidden'); + cy.addConsortiumMember(403, "Forbidden"); + cy.removeConsortiumMember(403, "Forbidden"); - cy.deleteMember(data.populatedMember.salesforceId, 403, 'Forbidden'); + cy.deleteMember(data.populatedMember.salesforceId, 403, "Forbidden"); cy.getAssertions(200); }); @@ -117,45 +201,79 @@ describe('Test authorities', () => { * ************************************************************************************************************************ */ - it('Admin', function () { + it("Admin", function () { cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword); - cy.visit('/'); - cy.get('#admin-menu').should('exist'); - cy.get('#entity-menu').should('exist'); - cy.get('a') - .filter('[href="/user"]') - .should('exist'); - cy.get('a') - .filter('[href="/assertion"]') - .should('exist'); - cy.get('a') - .filter('[href="/member"]') - .should('exist'); - - cy.getUsersBySfId(data.populatedMember.salesforceId, 400, "Salesforce id doesn't match current user's memeber"); + cy.visit("ui/en/"); + cy.get("#admin-menu").should("exist"); + cy.get("#entity-menu").should("exist"); + cy.get("a").filter('[routerlink="/users"]').should("exist"); + cy.get("a").filter('[routerlink="/affiliations"]').should("exist"); + cy.get("a").filter('[routerlink="/members"]').should("exist"); + + cy.getUsersBySfId( + data.populatedMember.salesforceId, + 400, + "Salesforce id doesn't match current user's memeber", + ); cy.getAllUsers(200); cy.getAllMembers(200); - cy.addMember(data.populatedMember.salesforceId, false, false, 400, 'Member invalid'); - cy.updateMember(data.invalidString, false, false, 500, 'Internal Server Error'); + cy.addMember( + data.populatedMember.salesforceId, + false, + false, + 400, + "Member invalid", + ); + cy.updateMember( + data.invalidString, + false, + false, + 500, + "Internal Server Error", + ); cy.validateMember(data.populatedMember.salesforceId, false, false, 200); //cy.changeNotificationLanguage(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, data.italianLanguageCode, 401); - cy.updateContact(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.updateMemberDetails(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 'The Harvest Ascendancy', 401, 'Unauthorized'); - cy.getMemberDetails(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberContacts(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberOrgIds(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401, 'Unauthorized'); + cy.updateContact( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.updateMemberDetails( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + "The Harvest Ascendancy", + 401, + "Unauthorized", + ); + cy.getMemberDetails( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberContacts( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberOrgIds( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + "Unauthorized", + ); cy.getMembersList(200); // TODO: Awaiting endpoint changes - cy.getMember(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 200); + cy.getMember( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 200, + ); - cy.addConsortiumMember(403, 'Forbidden'); - cy.removeConsortiumMember(403, 'Forbidden'); + cy.addConsortiumMember(403, "Forbidden"); + cy.removeConsortiumMember(403, "Forbidden"); - cy.deleteMember(data.invalidString, 400, 'Invalid id'); + cy.deleteMember(data.invalidString, 400, "Invalid id"); cy.getAssertions(200); }); @@ -166,43 +284,81 @@ describe('Test authorities', () => { * ************************************************************************************************************************ */ - it('Consortium lead', function () { - cy.programmaticSignin(data.homepageTestMembers.consortiumLeadAndMember.email, credentials.password); - cy.visit('/'); - cy.get('#admin-menu').should('not.exist'); - cy.get('#entity-menu').should('not.exist'); - cy.get('a') - .filter('[href="/user"]') - .should('not.exist'); - cy.get('a') - .filter('[href="/assertion"]') - .should('not.exist'); - cy.get('a') - .filter('[href="/member"]') - .should('not.exist'); - - cy.getUsersBySfId(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 401); - cy.getUsersBySfId(data.populatedMember.salesforceId, 400, "Salesforce id doesn't match current user's memeber"); - cy.getAllUsers(403, 'Forbidden'); - cy.getAllMembers(403, 'Forbidden'); - cy.addMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); - cy.updateMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); - cy.validateMember(data.populatedMember.salesforceId, false, false, 403, 'Forbidden'); + it("Consortium lead", function () { + cy.programmaticSignin( + data.homepageTestMembers.consortiumLeadAndMember.email, + credentials.password, + ); + cy.visit("ui/en/"); + cy.get("#admin-menu").should("not.exist"); + cy.get("#entity-menu").should("not.exist"); + cy.get("a").filter('[routerlink="/users"]').should("not.exist"); + cy.get("a").filter('[routerlink="/affiliations"]').should("not.exist"); + cy.get("a").filter('[routerlink="/members"]').should("not.exist"); + + cy.getUsersBySfId( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 401, + ); + cy.getUsersBySfId( + data.populatedMember.salesforceId, + 400, + "Salesforce id doesn't match current user's memeber", + ); + cy.getAllUsers(403, "Forbidden"); + cy.getAllMembers(403, "Forbidden"); + cy.addMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); + cy.updateMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); + cy.validateMember( + data.populatedMember.salesforceId, + false, + false, + 403, + "Forbidden", + ); //cy.changeNotificationLanguage(data.populatedMember.salesforceId, data.italianLanguageCode, 401); - cy.updateContact(data.populatedMember.salesforceId, 401, 'Unauthorized'); - cy.updateMemberDetails(data.populatedMember.salesforceId, "Test", 401, 'Unauthorized'); - cy.getMemberDetails(data.populatedMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberContacts(data.populatedMember.salesforceId, 401, 'Unauthorized'); - cy.getMemberOrgIds(data.populatedMember.salesforceId, 401, 'Unauthorized'); - - cy.getMembersList(403, 'Forbidden'); + cy.updateContact(data.populatedMember.salesforceId, 401, "Unauthorized"); + cy.updateMemberDetails( + data.populatedMember.salesforceId, + "Test", + 401, + "Unauthorized", + ); + cy.getMemberDetails(data.populatedMember.salesforceId, 401, "Unauthorized"); + cy.getMemberContacts( + data.populatedMember.salesforceId, + 401, + "Unauthorized", + ); + cy.getMemberOrgIds(data.populatedMember.salesforceId, 401, "Unauthorized"); + + cy.getMembersList(403, "Forbidden"); // TODO: Awaiting endpoint changes - cy.getMember(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 200); - - cy.deleteMember(data.homepageTestMembers.consortiumLeadAndMember.salesforceId, 403, 'Forbidden'); + cy.getMember( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 200, + ); + + cy.deleteMember( + data.homepageTestMembers.consortiumLeadAndMember.salesforceId, + 403, + "Forbidden", + ); cy.addConsortiumMember(200); cy.removeConsortiumMember(200); @@ -211,13 +367,13 @@ describe('Test authorities', () => { }); // TODO: enable once the issue with signed out users not being able to visit routes is fixed - /* it('Anonymous', function() { + it("Anonymous", function () { cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword); - cy.visit('/'); - cy.get('#admin-menu').should('not.exist'); - cy.get('#entity-menu').should('not.exist') - cy.get('a').filter('[href="/user"]').should('not.exist'); - cy.get('a').filter('[href="/assertion"]').should('not.exist'); - cy.get('a').filter('[href="/member"]').should('not.exist'); - }); */ + cy.visit("ui/en/"); + cy.get("#admin-menu").should("not.exist"); + cy.get("#entity-menu").should("not.exist"); + cy.get("a").filter('[routerLink="/users"]').should("not.exist"); + cy.get("a").filter('[routerLink="/affiliations"]').should("not.exist"); + cy.get("a").filter('[routerLink="/members"]').should("not.exist"); + }); }); diff --git a/ui/cypress/e2e/retention/ui-homepage-edit.cy.js b/ui/cypress/e2e/retention/ui-homepage-edit.cy.js index fa409843e..d0698fedf 100644 --- a/ui/cypress/e2e/retention/ui-homepage-edit.cy.js +++ b/ui/cypress/e2e/retention/ui-homepage-edit.cy.js @@ -8,9 +8,9 @@ describe("Test editing member details", () => { it("Editing Almonds Forest member details", function () { const date = Date.now(); cy.programmaticSignin(email, credentials.password); - cy.visit("/"); + cy.visit("ui/en/"); cy.get("app-member-info").contains(date).should("not.exist"); - cy.visit("/edit"); + cy.visit("ui/en/edit"); cy.get(".text-danger").should("not.exist"); // wait for data to load cy.intercept( @@ -70,7 +70,7 @@ describe("Test editing member details", () => { cy.get("app-member-info").contains( `YES - ORCID can use trademarked assets`, ); - cy.visit("/edit"); + cy.visit("ui/en/edit"); // wait for data to load cy.intercept( `/services/memberservice/api/members/${data.homepageTestMembers.consortiumMember.salesforceId}/member-contacts`, diff --git a/ui/cypress/e2e/retention/ui-homepage.cy.js b/ui/cypress/e2e/retention/ui-homepage.cy.js index 1abc04e97..ac9da56d8 100644 --- a/ui/cypress/e2e/retention/ui-homepage.cy.js +++ b/ui/cypress/e2e/retention/ui-homepage.cy.js @@ -37,9 +37,9 @@ describe("Test homepage", () => { cy.get(".side-bar").contains("mambono5@mailinator.com"); cy.get(".main-section").contains("Consortium lead"); cy.get(".main-section").contains("Mambo no 5"); - cy.get(".main-section").contains("Consortium Members (2)"); + cy.get(".main-section").contains("Consortium Members (3)"); cy.get(".main-section").contains("Member name"); - cy.get(".main-section").contains("A Public Hot Metro"); + cy.get(".main-section").contains("The Almond Forest"); cy.get(".main-section").contains("Contacts"); cy.get(".main-section").contains("Main relationship contact (OFFICIAL)"); cy.get(".main-section").contains("first.last@orcid.org"); @@ -55,14 +55,15 @@ describe("Test homepage", () => { cy.get(".side-bar").contains("Public details"); cy.get(".side-bar").contains("Website"); cy.get(".side-bar").contains("Email"); - cy.get(".side-bar").contains("No website added"); + cy.get(".side-bar").contains("https://orcid.org"); cy.get(".side-bar").contains("@orcid.org"); cy.get(".main-section").contains( "Consortium/Parent organization: Mambo No 5", ); - cy.get(".main-section").contains("Membership: Active"); - cy.get(".main-section").contains("Almonds Forest"); - cy.get(".main-section").contains("Description"); + cy.get(".main-section").first().contains("Membership:"); + cy.get(".main-section").first().contains("Active"); + cy.get(".main-section").contains("The Almond Forest"); + cy.get(".main-section").contains("Lorem ipsum"); cy.get(".main-section").contains("Contacts"); cy.get(".main-section").contains("Agreement signatory (OFFICIAL)"); cy.get(".main-section").contains("last@orcid.org"); @@ -81,9 +82,10 @@ describe("Test homepage", () => { cy.get(".side-bar").contains("canadapost.ca"); cy.get(".side-bar").contains("support@orcid.org"); cy.get(".main-section").contains( - "Consortium/Parent organization: The Concord of Kinship", + "Consortium/Parent organization: The Harvest Ascendancy", ); - cy.get(".main-section").contains("Membership: Active"); + cy.get(".main-section").first().contains("Membership:"); + cy.get(".main-section").first().contains("Active"); cy.get(".main-section").contains("Grateful Frogs"); }); diff --git a/ui/cypress/fixtures/test-data.json b/ui/cypress/fixtures/test-data.json index 13c8d3820..cd6cc5fca 100644 --- a/ui/cypress/fixtures/test-data.json +++ b/ui/cypress/fixtures/test-data.json @@ -104,9 +104,16 @@ "homepageTestMembers": { "directMemberEmail": "qa+cy_mp_flyandmighty@orcid.org", "consortiumLeadEmail": "qa+cy_mp_mambono5@orcid.org", - "consortiumMember": {"email": "qa+cy_mp_almondsforest@orcid.org", "name": "Almonds Forest", "salesforceId": "0012i00000aA9dFAAS"}, + "consortiumMember": { + "email": "qa+cy_mp_almondsforest@orcid.org", + "name": "The Almond Forest", + "salesforceId": "0013J00000XUAT6QAP" + }, "consortiumMemberEmail2": "qa+cy_mp_gratefulfrogs@orcid.org", - "consortiumLeadAndMember": {"email": "qa+cy_mp_theharvestascendancy@orcid.org", "salesforceId": "0012i00000h6xo5AAA"}, - "inactiveConsortiumMemberEmail": "qa+cy_mp_considineandsons@orcid.org" + "consortiumLeadAndMember": { + "email": "qa+cy_mp_theharvestascendancy@orcid.org", + "salesforceId": "0013J00000XTsWvQAL" + }, + "inactiveConsortiumMemberEmail": "qa+cy_mp_considineandsons@orcid.org" } -} \ No newline at end of file +} diff --git a/ui/cypress/support/commands.js b/ui/cypress/support/commands.js index 498a2a5dc..b86cc60c6 100644 --- a/ui/cypress/support/commands.js +++ b/ui/cypress/support/commands.js @@ -104,15 +104,9 @@ Cypress.Commands.add("processPasswordForm", (newPasswordFieldId) => { .clear() .type(credentials.shortConfirmationPassword); // check for min length error messages + cy.get("small").filter('[data-cy="passwordTooShort"').should("exist"); cy.get("small") - .filter( - '[jhitranslate="global.messages.validate.newpassword.minlength.string"]', - ) - .should("exist"); - cy.get("small") - .filter( - '[jhitranslate="global.messages.validate.confirmpassword.minlength.string"]', - ) + .filter('[data-cy="confirmationPasswordTooShort"]') .should("exist"); // fix password cy.get(newPasswordFieldId).clear().type(credentials.password); @@ -123,9 +117,7 @@ Cypress.Commands.add("processPasswordForm", (newPasswordFieldId) => { // make sure you can't activate account cy.get("button").filter('[type="submit"]').click(); // check for confirmation error message - cy.get("div") - .filter('[jhitranslate="global.messages.error.dontmatch.string"]') - .should("exist"); + cy.get("div").filter('[data-cy="passwordsDoNotMatch"]').should("exist"); // fix confirmation password cy.get("#confirmPassword").clear().type(credentials.password); // activate account @@ -192,11 +184,11 @@ Cypress.Commands.add("uploadCsv", (path) => { cy.intercept( "https://member-portal.qa.orcid.org/services/assertionservice/api/assertion/upload", ).as("upload"); - cy.get("#jhi-confirm-csv-upload").click(); + cy.get("button").filter('[data-cy="confirmCsvUpload"]').click(); // Occasionally, trying to upload the csv results in a 403 code due to an invalid CSRF token, in which case we retry cy.wait("@upload").then((int) => { if (int.response.statusCode !== 200) { - cy.get("#jhi-confirm-csv-upload").click(); + y.get(button).filter('[data-cy="confirmCsvUpload"]').click(); } }); }); diff --git a/ui/src/app/account/password/password-reset-finish.component.html b/ui/src/app/account/password/password-reset-finish.component.html index 3e75d69f5..8ac52f1a4 100644 --- a/ui/src/app/account/password/password-reset-finish.component.html +++ b/ui/src/app/account/password/password-reset-finish.component.html @@ -54,12 +54,18 @@

Reset password

tabindex="0" (click)="navigateToLoginPage()" (keydown.enter)="navigateToLoginPage()" + data-cy="navigateToSignIn" i18n="@@global.messages.info.authenticated.link.string" >sign in.

-
+
The password and its confirmation do not match!
@@ -94,6 +100,7 @@

Reset password

Your password is required to be at least 4 characters. @@ -138,6 +145,7 @@

Reset password

Your password confirmation is required to be at least 4 characters. diff --git a/ui/src/app/account/password/password-reset-init.component.html b/ui/src/app/account/password/password-reset-init.component.html index 9d684b6f4..8b9b2ba29 100644 --- a/ui/src/app/account/password/password-reset-init.component.html +++ b/ui/src/app/account/password/password-reset-init.component.html @@ -45,6 +45,7 @@

Reset your password

Your email is invalid. diff --git a/ui/src/app/account/password/password.component.html b/ui/src/app/account/password/password.component.html index d2dc6120a..f737b9d47 100644 --- a/ui/src/app/account/password/password.component.html +++ b/ui/src/app/account/password/password.component.html @@ -1,78 +1,154 @@
-
-
-

{{passwordForUsernameString}}

+
+
+

{{ passwordForUsernameString }}

-
- Password changed! -
-
- An error has occurred! The password could not be changed. -
+
+ Password changed! +
+
+ An error has occurred! The password could not be changed. +
-
- The password and its confirmation do not match! -
+
+ The password and its confirmation do not match! +
-
- -
- - -
- - Your password is required. - -
-
-
- - -
- - Your password is required. - - - Your password is required to be at least 4 characters. - - - Your password cannot be longer than 50 characters. - -
- -
-
- - -
- - Your confirmation password is required. - - - Your confirmation password is required to be at least 4 characters. - - - Your confirmation password cannot be longer than 50 characters. - -
-
- -
+
+
+ + +
+ + Your password is required. + +
+
+
+ + +
+ + Your password is required. + + + Your password is required to be at least 4 characters. + + + Your password cannot be longer than 50 characters. + +
+ +
+
+ + +
+ + Your confirmation password is required. + + + Your confirmation password is required to be at least 4 characters. + + + Your confirmation password cannot be longer than 50 characters. + +
+ +
+
diff --git a/ui/src/app/affiliation/affiliation-import-dialog.component.html b/ui/src/app/affiliation/affiliation-import-dialog.component.html index 3eb55a764..92402e4ce 100644 --- a/ui/src/app/affiliation/affiliation-import-dialog.component.html +++ b/ui/src/app/affiliation/affiliation-import-dialog.component.html @@ -66,7 +66,7 @@
-