Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add contact update cancel automated tests #687

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading