Skip to content

Commit

Permalink
Merge pull request #1188 from ORCID/fix-even-more-cy-tests
Browse files Browse the repository at this point in the history
fix even more cypress tests
  • Loading branch information
bobcaprice authored May 16, 2024
2 parents 98bf92e + 345b4f9 commit 3798abd
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 110 deletions.
6 changes: 3 additions & 3 deletions ui/cypress/e2e/reset-test-data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Add new user", () => {
cy.visit("/assertion");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
});
cy.visit("/user");
cy.get(".btn-group").each(($e) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe("Add new user", () => {
cy.visit("/assertion");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
});
cy.programmaticSignout();
});
Expand All @@ -68,7 +68,7 @@ describe("Add new user", () => {
cy.visit("/assertion");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
});
cy.programmaticSignout();
});
Expand Down
14 changes: 6 additions & 8 deletions ui/cypress/e2e/retention/add-affiliation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Add and remove affiliation", () => {

it("Add affiliation", function () {
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.visit("/assertion/new");
cy.visit("ui/en/affiliations/new");

cy.get("#field_email").type(record.invalidEmail);
cy.get("small.text-danger").should("exist");
Expand All @@ -54,9 +54,7 @@ describe("Add and remove affiliation", () => {
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("small").filter('[data-cy="invalidDateWarning"]').should("exist");
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
cy.get("#field_startDay").select(startDate.day);
cy.get("small").should("not.exist");
Expand All @@ -73,7 +71,7 @@ describe("Add and remove 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.visit("ui/en/affiliations");
cy.get("tbody").children().first().children().eq(0).contains(record.email);
cy.get("tbody")
.children()
Expand Down Expand Up @@ -143,18 +141,18 @@ describe("Add and remove affiliation", () => {

it("Confirm UI changes on the assertion page", () => {
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.visit("/assertion");
cy.visit("ui/en/affiliations");
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", () => {
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.visit("/assertion");
cy.visit("ui/en/affiliations");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
});
recurse(
() =>
Expand Down
105 changes: 39 additions & 66 deletions ui/cypress/e2e/retention/add-member.cy.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,62 @@
/// <reference types="cypress" />
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('Test "Add member" functionality', () => {
it('Add member', function() {
it("Add member", function () {
cy.programmaticSignin(credentials.adminEmail, credentials.adminPassword);
cy.visit('/member');
cy.get('tbody')
cy.visit("ui/en/members");
cy.get("tbody")
.children()
// Fetch existing salesforce id
.first().children().first().then(existingSfId => {
.first()
.children()
.first()
.then((existingSfId) => {
// Check required field flags
cy.visit('/member/new')
cy.get('#field_salesforceId').should('have.class', 'ng-invalid');
cy.get('#field_clientName').should('have.class', 'ng-invalid');
cy.visit("ui/en/members/new");
cy.get("#field_salesforceId").should("have.class", "ng-invalid");
cy.get("#field_clientName").should("have.class", "ng-invalid");
// Save button should be disabled
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
// Check salesforce id warning message when field is clear
cy.get('#field_salesforceId')
.type(salesforceId)
.clear();
cy.get('small').should('exist');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get("#field_salesforceId").type(salesforceId).clear();
cy.get("small").should("exist");
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
// Enter existing salesforce id to generate an error
cy.get('#field_salesforceId').type(existingSfId.text());
cy.get('#field_parentSalesforceId').type(clientName);
cy.get("#field_salesforceId").type(existingSfId.text());
cy.get("#field_parentSalesforceId").type(clientName);
// Enter invalid client name to generate an error
cy.get('#field_clientName')
.type(data.invalidString)
.clear();
cy.get('small').should('exist');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_clientName').type(data.populatedMember.clientName);
cy.get('#save-entity').click();
cy.get("#field_clientName").type(data.invalidString).clear();
cy.get("small").should("exist");
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
cy.get("#field_clientName").type(data.populatedMember.clientName);
cy.get("#save-entity").click();
// Two error messages should appear for existing salesforce id and member name
cy.get('.validation-errors')
.children()
.should('have.length', 2);
cy.get(".validation-errors").children().should("have.length", 2);
// Enter invalid client id to generate an error
cy.get('#field_clientId').type(data.invalidString);
cy.get('small').should('exist');
cy.get("#field_clientId").type(data.invalidString);
cy.get("small").should("exist");
// Check for flag on client id input field
cy.get('#field_clientId').should('have.class', 'ng-invalid');
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get("#field_clientId").should("have.class", "ng-invalid");
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
// Check the enable assertions checkbox
cy.get('#field_assertionServiceEnabled').check();
cy.get('#field_clientId')
.clear()
.type(clientId);
cy.get('#field_clientName')
.clear()
.type(clientName);
cy.get("#field_assertionServiceEnabled").check();
cy.get("#field_clientId").clear().type(clientId);
cy.get("#field_clientName").clear().type(clientName);
// Checkbox should be unchecked after clearing client id field
cy.get('#field_assertionServiceEnabled')
.should('not.be.checked')
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("#field_isConsortiumLead").should("not.be.checked").check();
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
cy.get("#field_parentSalesforceId").clear().type(salesforceId);
// Save button should still be disabled due to invalid parent SF id
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('exist');
cy.get('#field_parentSalesforceId')
.clear()
.type(existingSfId.text());
cy.get('#save-entity')
.invoke('attr', 'disabled')
.should('not.exist');
cy.get("#save-entity").invoke("attr", "disabled").should("exist");
cy.get("#field_parentSalesforceId").clear().type(existingSfId.text());
cy.get("#save-entity").invoke("attr", "disabled").should("not.exist");
});
});
});
4 changes: 2 additions & 2 deletions ui/cypress/e2e/retention/add-user.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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("ui/en/users/new");
// type in invalid email address
cy.get("#field_email").type(data.invalidEmail);
// type in name and surname
Expand Down Expand Up @@ -64,7 +64,7 @@ describe("Add new user", () => {

it("Remove added user", function () {
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.visit("/user");
cy.visit("ui/en/users");
cy.get(".btn-group").each(($e) => {
cy.wrap($e)
.children()
Expand Down
4 changes: 2 additions & 2 deletions ui/cypress/e2e/retention/notifications.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ describe("Test notifications", () => {
data.notificationsMember.users.owner.email,
credentials.password,
);
cy.visit("/assertion");
cy.visit("ui/en/affiliations");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAssertion"]').click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
});
cy.programmaticSignout();
});
Expand Down
2 changes: 1 addition & 1 deletion ui/cypress/e2e/retention/reset-password.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Test the password reset functionality", () => {
cy.get("#currentPassword").type(credentials.wrongConfirmationPasssword);
cy.processPasswordForm("#newPassword");
cy.get(".alert-danger")
.filter('data-cy="passwordChangeError"]')
.filter('[data-cy="passwordChangeError"]')
.should("exist");
cy.get("#currentPassword").clear().type(credentials.password);
cy.get("button").filter('[type="submit"]').click();
Expand Down
14 changes: 7 additions & 7 deletions ui/cypress/e2e/retention/restricted-access.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Test restricted access", () => {
.filter('[data-cy="cannotProcessRequest"]')
.contains("Your request cannot be processed");
cy.get("div")
.filter('[data-cy="notauthorized"]')
.filter('[data-cy="notAuthorized"]')
.invoke("attr", "hidden")
.should("not.exist");
});
Expand All @@ -32,7 +32,7 @@ describe("Test restricted access", () => {
.filter('[data-cy="cannotProcessRequest"]')
.contains("Your request cannot be processed");
cy.get("div")
.filter('[data-cy="notauthorized"]')
.filter('[data-cy="notAuthorized"]')
.invoke("attr", "hidden")
.should("not.exist");
});
Expand All @@ -47,7 +47,7 @@ describe("Test restricted access", () => {
.filter('[data-cy="cannotProcessRequest"]')
.contains("Your request cannot be processed");
cy.get("div")
.filter('[data-cy="notauthorized"]')
.filter('[data-cy="notAuthorized"]')
.invoke("attr", "hidden")
.should("not.exist");
});
Expand All @@ -62,20 +62,20 @@ describe("Test restricted access", () => {
.filter('[data-cy="cannotProcessRequest"]')
.contains("Your request cannot be processed");
cy.get("div")
.filter('[data-cy="notauthorized"]')
.filter('[data-cy="notAuthorized"]')
.invoke("attr", "hidden")
.should("not.exist");
});

/* it('Anonymous users cannot access anything', function() {
cy.visit('/assertion');
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.get('div').filter('[data-cy="notAuthorized"]').invoke('attr', 'hidden').should('not.exist')
cy.visit('/user');
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.get('div').filter('[data-cy="notAuthorized"]').invoke('attr', 'hidden').should('not.exist')
cy.visit('/member');
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.get('div').filter('[data-cy="notAuthorized"]').invoke('attr', 'hidden').should('not.exist')
}); */
});
7 changes: 3 additions & 4 deletions ui/cypress/e2e/retention/ui-homepage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +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("https://orcid.org");
cy.get(".side-bar").contains("No website added");
cy.get(".side-bar").contains("@orcid.org");
cy.get(".main-section").contains(
"Consortium/Parent organization: Mambo No 5",
);
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("Description");
cy.get(".main-section").contains("Contacts");
cy.get(".main-section").contains("Agreement signatory (OFFICIAL)");
cy.get(".main-section").contains("[email protected]");
Expand Down Expand Up @@ -102,9 +102,8 @@ describe("Test homepage", () => {
cy.get(".side-bar").contains("www.haevesting.com");
cy.get(".side-bar").contains("[email protected]");
cy.get(".main-section").contains("Consortium lead");
cy.get(".main-section").contains("Consortium Members (2)");
cy.get(".main-section").contains("Consortium Members (1)");
cy.get(".main-section").contains("Member name");
cy.get(".main-section").contains("Yellow member");
cy.get(".main-section").contains("The Harvest Ascendancy");
cy.get(".main-section").contains("Contacts");
cy.get(".main-section").contains("Product Contact");
Expand Down
2 changes: 1 addition & 1 deletion ui/cypress/fixtures/test-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"invalidEmail": "@[email protected]",
"invalidWebsite": "orcid.org",
"invalidString": "a",
"italianLanguageCode": "7: it",
"italianLanguageCode": "4: it",
"outbox": {
"email": "[email protected]",
"updateEmail": "[email protected]",
Expand Down
23 changes: 10 additions & 13 deletions ui/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ 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('[data-cy="passwordTooShort"]').should("exist");
cy.get("small")
.filter('[data-cy="confirmationPasswordTooShort"]')
.should("exist");
Expand Down Expand Up @@ -134,7 +134,13 @@ Cypress.Commands.add("visitLinkFromEmail", (email) => {
const href = htmlDom.querySelector(
'a[href*="https://member-portal.qa.orcid.org/reset/finish?key="]',
).href;
cy.visit(href);
// TODO: remove the replace bit when migrated
cy.visit(
href.replace(
"https://member-portal.qa.orcid.org/",
"https://member-portal.qa.orcid.org/ui/en/",
),
);
});

Cypress.Commands.add("checkInbox", (subject, recipient, date) => {
Expand Down Expand Up @@ -199,19 +205,10 @@ Cypress.Commands.add("fetchLinkAndGrantPermission", (email) => {
.children()
.last()
.within(() => {
cy.get("a")
.filter(
'[jhitranslate="gatewayApp.assertionServiceAssertion.details.string"]',
)
.click();
cy.get("a").filter('[data-cy="viewDetailsButton"]').click();
});
cy.get(".jh-entity-details").within(() =>
cy
.get("button")
.filter(
'[jhitranslate="gatewayApp.assertionServiceAssertion.copyClipboard.string"]',
)
.click(),
cy.get("button").filter('[data-cy="copyToClipboard"]').click(),
);
cy.task("getClipboard").then((link) => {
cy.visit(link);
Expand Down
Loading

0 comments on commit 3798abd

Please sign in to comment.