Skip to content

Commit

Permalink
add two tests for contact edit cancel scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
CMurrell148 committed Jan 2, 2025
1 parent 25eb0fc commit 1972c20
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ describe("Testing the components of the Trust contacts page", () => {
.checkSuccessPopup('Changes made to the SFSO (Schools financial support and oversight) lead name and email were updated')
.checkErrorPopupNotPresent();
});

it(`Checks that when cancelling the edit of a TRM contact that I am taken back to the previous page and that entered data is not saved`, () => {
contactsPage
.editTrustRelationshipManagerWithoutSaving("Should Notbe Seen", "[email protected]")
.clickContactUpdateCancelButton()
.checkTrustRelationshipManagerIsNotUpdated("Should Notbe Seen", "[email protected]");

navigation
.checkCurrentURLIsCorrect(`/trusts/contacts/in-dfe?uid=${uid}`);
});

it(`Checks that when cancelling the edit of a SFSO contact that I am taken back to the previous page and that entered data is not saved`, () => {
contactsPage
.editSfsoLeadWithoutSaving("Should Notbe Seen", "[email protected]")
.clickContactUpdateCancelButton()
.checkSfsoLeadIsNotUpdated("Should Notbe Seen", "[email protected]");

navigation
.checkCurrentURLIsCorrect(`/trusts/contacts/in-dfe?uid=${uid}`);
});
});

describe(`On the edit Trust relationship manager contact details page for a ${typeOfTrust}`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ContactsPage {
editContacts: {
nameInput: () => cy.get('[name="Name"]'),
emailInput: () => cy.get('[name="Email"]'),
saveButton: () => cy.contains('Save and continue')
saveButton: () => cy.contains('Save and continue'),
cancelButton: () => cy.contains('Cancel')
},

accountingOfficer: {
Expand Down Expand Up @@ -59,6 +60,12 @@ class ContactsPage {
},
};


public clickContactUpdateCancelButton(): this {
this.elements.editContacts.cancelButton().click();
return this;
}

public editTrustRelationshipManager(name: string, email: string): this {
const { trustRelationshipManager, editContacts } = this.elements;
trustRelationshipManager.editLink().click();
Expand All @@ -68,18 +75,46 @@ class ContactsPage {
return this;
}

public editTrustRelationshipManagerWithoutSaving(name: string, email: string): this {
const { trustRelationshipManager, editContacts } = this.elements;
trustRelationshipManager.editLink().click();
editContacts.nameInput().clear().type(name);
editContacts.emailInput().clear().type(email);
return this;
}

public checkTrustRelationshipManagerIsSuccessfullyUpdated(name: string, email: string): this {
this.elements.trustRelationshipManager.name().should('contain.text', name);
this.elements.trustRelationshipManager.email().should('contain.text', email);
return this;
}

public checkTrustRelationshipManagerIsNotUpdated(dontDisplayName: string, dontDisplayEmail: string): this {
this.elements.trustRelationshipManager.name().should('not.contain.text', dontDisplayName);
this.elements.trustRelationshipManager.email().should('not.contain.text', dontDisplayEmail);
return this;
}

public checkSfsoLeadIsNotUpdated(dontDisplayName: string, dontDisplayEmail: string): this {
this.elements.schoolsFinancialSupportOversight.name().should('not.contain.text', dontDisplayName);
this.elements.schoolsFinancialSupportOversight.email().should('not.contain.text', dontDisplayEmail);
return this;
}

public editSfsoLead(name: string, email: string): this {
const { schoolsFinancialSupportOversight, editContacts: EditContacts } = this.elements;
const { schoolsFinancialSupportOversight, editContacts } = this.elements;
schoolsFinancialSupportOversight.editLink().click();
EditContacts.nameInput().clear().type(name);
EditContacts.emailInput().clear().type(email);
EditContacts.saveButton().click();
editContacts.nameInput().clear().type(name);
editContacts.emailInput().clear().type(email);
editContacts.saveButton().click();
return this;
}

public editSfsoLeadWithoutSaving(name: string, email: string): this {
const { schoolsFinancialSupportOversight, editContacts } = this.elements;
schoolsFinancialSupportOversight.editLink().click();
editContacts.nameInput().clear().type(name);
editContacts.emailInput().clear().type(email);
return this;
}

Expand Down

0 comments on commit 1972c20

Please sign in to comment.