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

MLPAB-2637: Add track progress button to dashboard when paid or paying #1725

Merged
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
39 changes: 39 additions & 0 deletions cypress/e2e/donor/dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,45 @@ describe('Dashboard', () => {
});
})

context('when payment task started', () => {
it('LPAs have a track progress button', () => {
cy.visit('/fixtures?redirect=/task-list&progress=checkAndSendToYourCertificateProvider');

cy.contains('a', 'Pay for the LPA').click()
cy.contains('a', 'Continue').click()
cy.get('input[name="yes-no"]').check('yes', { force: true });
cy.contains('button', 'Save and continue').click()

cy.contains('a', 'Manage your LPAs').click()

cy.get('button').should('not.contain', 'Continue');

cy.contains('Property and affairs');
cy.contains('Sam Smith');
cy.contains('strong', 'In progress');
cy.contains('a', 'Go to task list');
cy.contains('a', 'Delete LPA');
cy.contains('a', 'Check LPA progress').click();

cy.url().should('contain', '/progress');
});
});

context('when paid', () => {
it('LPAs have a track progress button', () => {
cy.visit('/fixtures?redirect=&progress=payForTheLpa');

cy.contains('Property and affairs');
cy.contains('Sam Smith');
cy.contains('strong', 'In progress');
cy.contains('a', 'Go to task list');
cy.contains('a', 'Delete LPA');
cy.contains('a', 'Check LPA progress').click();

cy.url().should('contain', '/progress');
});
});

context('with submitted LPA', () => {
it('completed LPAs have a track progress button', () => {
Cypress.on('uncaught:exception', () => {
Expand Down
2 changes: 2 additions & 0 deletions internal/lpastore/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ func LpaFromDonorProvided(l *donordata.Provided) *lpadata.Lpa {
Email: l.Correspondent.Email,
Address: l.Correspondent.Address,
},
PaymentInProgress: !l.Tasks.PayForLpa.IsCompleted() && !l.Tasks.PayForLpa.IsNotStarted(),
Paid: l.Tasks.PayForLpa.IsCompleted(),
}

for _, a := range l.Attorneys.Attorneys {
Expand Down
4 changes: 4 additions & 0 deletions internal/lpastore/lpadata/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ type Lpa struct {
// lpa-store the application payment must be complete.
Paid bool

// PaymentInProgress is set if the donor has started the payment task for online
// applications and is always false for paper applications as they have already paid.
PaymentInProgress bool

// IsOrganisationDonor is set to true when the Lpa is being made by a
// supporter working for an organisation.
IsOrganisationDonor bool
Expand Down
1 change: 1 addition & 0 deletions internal/lpastore/resolving_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (s *ResolvingService) merge(lpa *lpadata.Lpa, donor *donordata.Provided) *l
lpa.Donor.Channel = lpadata.ChannelPaper
} else {
lpa.Drafted = donor.Tasks.CheckYourLpa.IsCompleted()
lpa.PaymentInProgress = !donor.Tasks.PayForLpa.IsCompleted() && !donor.Tasks.PayForLpa.IsNotStarted()
lpa.Paid = donor.Tasks.PayForLpa.IsCompleted()
_, lpa.IsOrganisationDonor = donor.SK.Organisation()

Expand Down
6 changes: 6 additions & 0 deletions web/template/dashboard.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
<a class="govuk-button govuk-button--secondary" href="{{ link .App (global.Paths.Progress.Format .Item.Lpa.LpaID) }}">{{ tr .App "trackLpaProgress" }}</a>
<a class="govuk-button govuk-button--secondary" href="{{ link .App (global.Paths.WithdrawThisLpa.Format .Item.Lpa.LpaID) }}">{{ tr .App "withdrawLpa" }}</a>
</div>
{{ else if or .Item.Lpa.PaymentInProgress .Item.Lpa.Paid }}
<div class="govuk-button-group">
<a class="govuk-button" href="{{ link .App (global.Paths.TaskList.Format .Item.Lpa.LpaID) }}">{{ tr .App "goToTaskList" }}</a>
<a class="govuk-button govuk-button--secondary" href="{{ link .App (global.Paths.Progress.Format .Item.Lpa.LpaID) }}">{{ tr .App "trackLpaProgress" }}</a>
<a class="govuk-button govuk-button--secondary" href="{{ link .App (global.Paths.DeleteThisLpa.Format .Item.Lpa.LpaID) }}">{{ tr .App "deleteLpa" }}</a>
</div>
{{ else }}
<div class="govuk-button-group">
<a class="govuk-button" href="{{ link .App (global.Paths.TaskList.Format .Item.Lpa.LpaID) }}">{{ tr .App "goToTaskList" }}</a>
Expand Down
Loading