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

Unsubscribe button on document collection pages #3409

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Conversation

hannako
Copy link
Contributor

@hannako hannako commented Nov 8, 2024

What

Fix two issues with the email subscription signup process on Document Collection pages.

First commit: Display a flash message to confirm subscription.

This should have been added in #2535

Before After
Screenshot 2024-11-12 at 22 28 09 Screenshot 2024-11-12 at 22 26 38

Second commit: Fix unsubscribe button

Allow users with a gov.uk account to unsubscribe from a document collection via the single page notification button. See commit message for full explanation and links to documentation.

Trello

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 8, 2024 17:08 Inactive
@hannako hannako force-pushed the unsubscribe_button branch from e2269fe to 8e20744 Compare November 8, 2024 17:12
@hannako hannako changed the title Unsubscribe button Unsubscribe button on document collection pages Nov 8, 2024
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 8, 2024 17:13 Inactive
@hannako hannako marked this pull request as draft November 8, 2024 17:34
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 12, 2024 13:20 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 12, 2024 14:33 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 12, 2024 21:53 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 12, 2024 22:09 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 12, 2024 22:15 Inactive
Document collection email subscriptions are complicated[1]

The expected behaviour is:

If a document collection has a taxonomy topic email override in its links,
render the signup link component, and subscribe the user to the taxonomy topic instead of
to the document collection itself.

In all other cases, render a single page notification button.

The button is a gem component, and it uses the value of the attribute
`skip_account` to determine the form action of this button[2]

- If the user has an active govuk-account session, the button should post to
email-alert-frontend's /email/subscriptions/single-page/new endpoint. This endpoint enforces
the gov.uk account[3].

- If the user is not logged into their account (or they don't have an account) then the button
should post to email-alert-api's magic link endpoint, /email-signup instead. This endpoint does
not enforce the govuk account.

Current behaviour:

Prior to this commit, we were passing skip_account = "true" to the button component on all
document collection pages, and therefore hardcoding the button to post to the account free
endpoint regardless of whether or not they were logged into their account.

New behaviour:

What this commit does, is to only set the value of skip_account to "true" for users without an active
govuk-account session.

Why are we making this change?

For users with an existing subscription returning to a document collection page, the single page notification
button doesn't allow them to unsubscribe. The button text is "Stop getting emails about this page", but instead
of posting to email/subscriptions/single-page/new, which supports both subscribing AND unsubscribing[4] it is
hardcoded to post to /email-signup which supports sign up only. This means they must log into their govuk accounts
in order to manage their subscriptions.

[1] https://docs.publishing.service.gov.uk/manual/document-collection-emails-a-special-case.html
[2] https://github.com/alphagov/govuk_publishing_components/blob/main/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb#L58-L64
[3] https://github.com/alphagov/email-alert-frontend/blob/main/app/controllers/govuk_account_signups_controller.rb#L15-L17
[4] https://github.com/alphagov/email-alert-frontend/blob/main/app/controllers/govuk_account_signups_controller.rb#L27-L34
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 12, 2024 22:20 Inactive
@hannako hannako marked this pull request as ready for review November 12, 2024 22:36
@KludgeKML
Copy link
Contributor

Commit 3: I kind of forget what the equivalence is, but I think controller tests are the olde-world version of request tests, which is probably reasonable for this test case (we're not testing the actual user interaction in the test, which would make it an integration/system test, just what is returned for a specific request - ie given an account or not, does the signup control in the returned page point to the account or magic link endpoint?)

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3409 November 18, 2024 14:55 Inactive
Copy link
Contributor

@KludgeKML KludgeKML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hannako hannako merged commit c229e1c into main Nov 19, 2024
11 checks passed
@hannako hannako deleted the unsubscribe_button branch November 19, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants