Skip to content

Commit

Permalink
MLPAB-2760 support deleting voucherdata.Provided
Browse files Browse the repository at this point in the history
MLPAB-2760 fix and prevent clear chaining
  • Loading branch information
acsauk committed Mar 5, 2025
1 parent 129744e commit 1d790bb
Show file tree
Hide file tree
Showing 25 changed files with 323 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ coverage:
- "./internal/telemetry"
- "./internal/validation/error.go"
- "./mocks/*"
- "./scripts/*.go"
- "./scripts/pre-commit/*"
status:
project:
default:
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ repos:
entry: yarn run stop-only
language: node
args: [--folder, cypress]
- id: cypress-clear-no-chain
name: Prevent unsafe Cypress command chaining
entry: go run ./scripts/pre-commit/prevent_unsafe_chains.go
language: golang
types: [ file ]
files: \.cy.js$
# - repo: https://github.com/Yelp/detect-secrets
# rev: v1.4.0
# hooks:
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/attorney/confirm-your-details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ describe('Confirm your details', () => {

it('can change the phone number', () => {
cy.contains('.govuk-summary-list__row', 'Phone number').contains('a', 'Change').click();
cy.get('#f-phone').clear().type(TestMobile2);
cy.get('#f-phone').clear();
cy.get('#f-phone').type(TestMobile2);
cy.contains('button', 'Save and continue').click()

cy.contains('h2', 'Details you have given us').next().within(() => {
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/certificate-provider/enter-date-of-birth.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ describe('Enter date of birth', () => {

cy.get('#f-date-of-birth').type('not');
cy.get('#f-date-of-birth-month').type('valid');
cy.get('#f-date-of-birth-year').clear().type('values');
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type('values');
cy.contains('button', 'Save and continue').click();
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be a real date');
});
Expand Down
24 changes: 16 additions & 8 deletions cypress/e2e/donor/choose-attorneys-summary.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ describe('Choose attorneys summary', () => {
cy.url().should('contain', '/choose-attorneys-summary');
cy.url().should('match', /id=\w*/);

cy.get('#f-first-names').clear().type('Mark');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('Mark');

cy.contains('button', 'Save and continue').click();

Expand All @@ -54,7 +55,8 @@ describe('Choose attorneys summary', () => {
cy.url().should('contain', '/choose-attorneys-summary');
cy.url().should('match', /id=\w*/);

cy.get('#f-address-line-1').clear().type('1 RICHMOND PLACE');
cy.get('#f-address-line-1').clear();
cy.get('#f-address-line-1').type('1 RICHMOND PLACE');
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-attorneys-summary');
Expand All @@ -73,12 +75,18 @@ describe('Choose attorneys summary', () => {

cy.url().should('contain', '/choose-attorneys');

cy.get('#f-first-names').clear().type('Bob Arnold');
cy.get('#f-last-name').clear().type('Jones');
cy.get('#f-email').clear().type(TestEmail);
cy.get('input[name="date-of-birth-day"]').clear().type('31');
cy.get('input[name="date-of-birth-month"]').clear().type('12');
cy.get('input[name="date-of-birth-year"]').clear().type('1995');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('Bob Arnold');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Jones');
cy.get('#f-email').clear();
cy.get('#f-email').type(TestEmail);
cy.get('input[name="date-of-birth-day"]').clear();
cy.get('input[name="date-of-birth-day"]').type('31');
cy.get('input[name="date-of-birth-month"]').clear();
cy.get('input[name="date-of-birth-month"]').type('12');
cy.get('input[name="date-of-birth-year"]').clear();
cy.get('input[name="date-of-birth-year"]').type('1995');
cy.contains('button', 'Save and continue').click();

cy.contains('label', 'Enter a new address').click();
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/donor/choose-attorneys.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ describe('Choose attorneys', () => {
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be in the past');

cy.get('#f-date-of-birth-month').type('2');
cy.get('#f-date-of-birth-year').clear().type('1990');
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type('1990');
cy.contains('button', 'Save and continue').click();
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be a real date');
});
Expand Down Expand Up @@ -138,7 +139,8 @@ describe('Choose attorneys', () => {
cy.go(-2);
cy.url().should('contain', '/choose-attorneys');

cy.get('#f-date-of-birth-year').clear().type(new Date().getFullYear() - 20);
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type(new Date().getFullYear() - 20);
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-attorneys-address');
Expand Down
24 changes: 16 additions & 8 deletions cypress/e2e/donor/choose-replacement-attorneys-summary.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe('Choose replacement attorneys summary', () => {
cy.checkA11yApp();

cy.contains('.govuk-summary-card', 'Blake Buckley').contains('a', 'Change').click();
cy.get('#f-first-names').clear().type('Mark');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('Mark');

cy.contains('button', 'Save and continue').click();

Expand All @@ -44,7 +45,8 @@ describe('Choose replacement attorneys summary', () => {
.contains('a', 'Change')
.click();

cy.get('#f-address-line-1').clear().type('4 RICHMOND PLACE');
cy.get('#f-address-line-1').clear();
cy.get('#f-address-line-1').type('4 RICHMOND PLACE');
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-replacement-attorneys-summary');
Expand All @@ -59,12 +61,18 @@ describe('Choose replacement attorneys summary', () => {

cy.url().should('contain', '/choose-replacement-attorneys');

cy.get('#f-first-names').clear().type('Bob Arnold');
cy.get('#f-last-name').clear().type('Jones');
cy.get('#f-email').clear().type(TestEmail);
cy.get('input[name="date-of-birth-day"]').clear().type('31');
cy.get('input[name="date-of-birth-month"]').clear().type('12');
cy.get('input[name="date-of-birth-year"]').clear().type('1995');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('Bob Arnold');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Jones');
cy.get('#f-email').clear();
cy.get('#f-email').type(TestEmail);
cy.get('input[name="date-of-birth-day"]').clear();
cy.get('input[name="date-of-birth-day"]').type('31');
cy.get('input[name="date-of-birth-month"]').clear();
cy.get('input[name="date-of-birth-month"]').type('12');
cy.get('input[name="date-of-birth-year"]').clear();
cy.get('input[name="date-of-birth-year"]').type('1995');
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-replacement-attorneys-address');
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/donor/choose-replacement-attorneys.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ describe('Choose replacement attorneys', () => {
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be in the past');

cy.get('#f-date-of-birth-month').type('2');
cy.get('#f-date-of-birth-year').clear().type('1990');
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type('1990');
cy.contains('button', 'Save and continue').click();
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be a real date');
});
Expand Down Expand Up @@ -141,7 +142,8 @@ describe('Choose replacement attorneys', () => {
cy.go(-2);
cy.url().should('contain', '/choose-replacement-attorneys');

cy.get('#f-date-of-birth-year').clear().type(new Date().getFullYear() - 20);
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type(new Date().getFullYear() - 20);
cy.contains('button', 'Save and continue').click();

cy.url().should('contain', '/choose-replacement-attorneys-address');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
describe('Confirm your certificate provider is not related', () => {
beforeEach(() => {
cy.visit('/fixtures?redirect=/your-name&progress=addCorrespondent');
cy.get('#f-last-name').clear().type('Cooper');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Cooper');
cy.contains('button', 'Save and continue').click();
cy.visitLpa('/task-list');
cy.contains('li', "Check and send to your certificate provider")
Expand Down
13 changes: 9 additions & 4 deletions cypress/e2e/donor/make-a-new-lpa.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ describe('Make a new LPA', () => {

cy.url().should('contain', '/your-name');
cy.checkA11yApp();
cy.get('#f-first-names').should('have.value', 'Sam').focus().clear();
cy.get('#f-first-names').type('a').should('have.value', 'a');
cy.get('#f-last-name').should('have.value', 'Smith').focus().clear();
cy.get('#f-last-name').type('b').should('have.value', 'b');
cy.get('#f-first-names').should('have.value', 'Sam');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('a')
cy.get('#f-first-names').should('have.value', 'a');

cy.get('#f-last-name').should('have.value', 'Smith');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('b');
cy.get('#f-last-name').should('have.value', 'b');
cy.contains("button", "Continue").click();

cy.url().should('contain', '/we-have-updated-your-details');
Expand Down
16 changes: 8 additions & 8 deletions cypress/e2e/donor/you-cannot-sign-your-lpa-yet.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ describe('You cannot sign your LPA yet', () => {
cy.visit('/fixtures?redirect=/choose-attorneys-summary&progress=addCorrespondent');

cy.contains('.govuk-summary-card', 'Jessie Jones').contains('a', 'Change').click();
cy.get('#f-date-of-birth-year').focus().clear();
cy.get('#f-date-of-birth-year').focus().type(today.getFullYear() - 1);
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type(today.getFullYear() - 1);
cy.contains('button', 'Save and continue').click()
cy.contains('button', 'Save and continue').click()
cy.visitLpa('/choose-replacement-attorneys-summary')

cy.contains('.govuk-summary-card', 'Blake Buckley').contains('a', 'Change').click();
cy.get('#f-date-of-birth-year').focus().clear();
cy.get('#f-date-of-birth-year').focus().type(today.getFullYear() - 1);
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type(today.getFullYear() - 1);
cy.contains('button', 'Save and continue').click()
cy.contains('button', 'Save and continue').click()
cy.contains('a', 'Return to task list').click()
Expand All @@ -24,16 +24,16 @@ describe('You cannot sign your LPA yet', () => {
cy.contains('.govuk-summary-list__row', 'Jessie Jones').contains('a', 'Change').click();

cy.url().should('contain', '/choose-attorneys')
cy.get('#f-date-of-birth-year').focus().clear();
cy.get('#f-date-of-birth-year').focus().type("2000");
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type("2000");
cy.contains('button', 'Save and continue').click()
cy.url().should('contain', '/you-cannot-sign-your-lpa-yet')

cy.contains('.govuk-summary-list__row', 'Blake Buckley').contains('a', 'Change').click();

cy.url().should('contain', '/choose-replacement-attorneys')
cy.get('#f-date-of-birth-year').focus().clear();
cy.get('#f-date-of-birth-year').focus().type("2000");
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type("2000");
cy.contains('button', 'Save and continue').click()
cy.url().should('contain', '/task-list')
});
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/donor/your-date-of-birth.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ describe('Your date of birth', () => {
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be in the past');

cy.get('#f-date-of-birth-month').type('2');
cy.get('#f-date-of-birth-year').clear().type('1990');
cy.get('#f-date-of-birth-year').clear();
cy.get('#f-date-of-birth-year').type('1990');
cy.contains('button', 'Save and continue').click();
cy.contains('#date-of-birth-hint + .govuk-error-message', 'Date of birth must be a real date');
});
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/donor/your-name.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ describe('Your name', () => {
});

it('warns when name shared with other actor', () => {
cy.get('#f-first-names').clear().type('Jessie');
cy.get('#f-last-name').clear().type('Jones');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('Jessie');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Jones');
cy.contains('button', 'Save and continue').click();
cy.url().should('contain', '/your-name');

Expand Down
18 changes: 12 additions & 6 deletions cypress/e2e/supporter/edit-member.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ describe('Edit member', () => {

cy.checkA11yApp();

cy.get('#f-first-names').clear().type('John');
cy.get('#f-last-name').clear().type('Doe');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('John');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Doe');

cy.contains('button', "Save").click()

Expand All @@ -32,8 +34,10 @@ describe('Edit member', () => {

cy.checkA11yApp();

cy.get('#f-first-names').clear().type('John');
cy.get('#f-last-name').clear().type('Doe');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('John');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Doe');

cy.contains('button', "Save").click()

Expand Down Expand Up @@ -111,8 +115,10 @@ describe('Edit member', () => {
cy.checkA11yApp();
cy.contains('Your name');

cy.get('#f-first-names').clear().type('John');
cy.get('#f-last-name').clear().type('Doe');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('John');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Doe');

cy.contains('button', "Save").click()

Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/supporter/manage-organisation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ describe('Manage organisation', () => {
cy.url().should('contain', '/manage-organisation/organisation-details/edit-organisation-name');
cy.checkA11yApp();

cy.get('#f-name').clear().type('My organisation');
cy.get('#f-name').clear();
cy.get('#f-name').type('My organisation');
cy.contains('button', 'Continue').click();

cy.url().should('contain', '/manage-organisation/organisation-details');
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/supporter/view-lpa.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('View LPA', () => {

cy.contains('.govuk-summary-list__row', 'First names').find('a').click();

cy.get('#f-first-names').clear().type('2');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('2');
cy.contains('button', 'Save and continue').click();
cy.contains('a', 'Dashboard').click();
cy.contains('2 Smith');
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/voucher/confirm-your-identity.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ describe('Confirm your identity', () => {

it('warns when matches another actor', () => {
cy.visitLpa('/your-name');
cy.get('#f-first-names').clear().type('Charlie');
cy.get('#f-last-name').clear().type('Cooper');
cy.get('#f-first-names').clear();
cy.get('#f-first-names').type('Charlie');
cy.get('#f-last-name').clear();
cy.get('#f-last-name').type('Cooper');
cy.contains('button', 'Save and continue').click();
cy.contains('button', 'Continue').click();
cy.contains('label', 'Yes').click();
Expand Down
Loading

0 comments on commit 1d790bb

Please sign in to comment.