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

Display GOV.UK Chat promo on certain pages #3303

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Display GOV.UK Chat promo on certain pages #3303

merged 1 commit into from
Aug 28, 2024

Conversation

jackbot
Copy link
Contributor

@jackbot jackbot commented Aug 19, 2024

Note: this is a draft and an incomplete implementation. I'm just looking for feedback for the approach taken.

We want to show a promo to the new GOV.UK Chat application on certain pages on GOV.UK. It's a CTA pointing users to the chat app.

The list of URLs we want the promo to appear on is quite short and cover only answer and guide content types from this codebase.

The CTA is to be shown in the sidebar on the right of the relevant pages.

Screenshot 2024-08-27 at 09 49 23

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 19, 2024 11:10 Inactive
Copy link
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Approach looks great to me, looks like @jon-kirwan isn't far away from merging the component in so that we can see the final result: alphagov/govuk_publishing_components#4151

Not sure if you and him want to converge to try out his component before he merges it to rule out any issues?

config/application.rb Outdated Show resolved Hide resolved
app/views/shared/_sidebar_navigation.html.erb Outdated Show resolved Hide resolved
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 20, 2024 07:22 Inactive
@kevindew
Copy link
Member

Nice one, this looks good enough to me that we could proceed to write tests for it.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 20, 2024 14:01 Inactive
@jackbot
Copy link
Contributor Author

jackbot commented Aug 20, 2024

@kevindew I've added some tests here, with a couple of comments.

I tested out the branch of govuk_publishing_components with the actual component in and noticed a couple of discrepancies between what was rendered and the Figma designs. I've chatted with Jon about it, and he'll look into it.

The tests are written in such a way that they'll still be relevant when I switch out the dummy component with the real one, as they both contain the text "Try GOV.UK Chat"

Copy link
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Thanks @jackbot - nice job with the minitest fight. After chatting with @leenagupte I've made a few suggestions that are related to how we could simplify things a bit. They were a little surprised at how many files are affected, which is my fault as I told them it'd not be much more complex than:

<% if SHOW_CHAT_PROMO_BASE_PATHS.include?(content_item.base_path) %>
  <%= render "govuk_publishing_components/chat_promo" %>
<% end %>

Let me know what you think, but I think in general they'll make it mostly easier to test and reduce places with chat code.

app/helpers/govuk_chat_promo_helper.rb Outdated Show resolved Hide resolved
app/helpers/govuk_chat_promo_helper.rb Outdated Show resolved Hide resolved
app/views/shared/_sidebar_navigation.html.erb Outdated Show resolved Hide resolved
test/helpers/govuk_chat_promo_helper_spec.rb Outdated Show resolved Hide resolved
test/support/govuk_chat_promo.rb Outdated Show resolved Hide resolved
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 21, 2024 07:32 Inactive
@jackbot
Copy link
Contributor Author

jackbot commented Aug 21, 2024

Thanks @kevindew, I've made those changes to simplify things a bit.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 21, 2024 07:40 Inactive
@@ -33,4 +33,12 @@ class AnswerTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item("answer")
assert_not page.has_css?(".gem-c-single-page-notification-button")
end

test "renders GOV.UK chat promo for matching base path" do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't really sure where to put this test now that we could technically render the promo on any content type page now. There doesn't seem to be any "integration test for all content types" test file anywhere, as far as I could see.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it doesn't look like there is one. Closest thing seems to be meta_tags test.

I imagine we've got a choice between

  1. no test, consider the integration code sufficiently simple that it doesn't need a test
  2. create a simple govuk_chat_promo_test in integration tests.

I think the most responsible thing to do is the latter with us being prepared to remove it if the team don't want it to keep chat surface area smaller.

I guess a thing to consider is that, for when we have the component installed, the assertion will change from has_text?("Try GOV.UK Chat") to has_selector(".gem-c-chat-entry") so would be a little more contrived as we shouldn't couple the test to the component copy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello. I agree that 2, creating a separate test file is the best option. Keeping the tests separate will make them easier to remove later without needing to unpick them from the rest of the test suite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks both, I've created a separate test file that just tests the happy path; I think the unit tests for the helper cover all the rest of the paths but let me know if you disagree.

I've also removed the temporary view because we can now render the actual component.

Copy link
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Great stuff, just a note on the integration test


class GovukChatPromoHelperTest < ActionView::TestCase
test "show_govuk_chat_promo? when configuration disabled" do
assert_not show_govuk_chat_promo?(GOVUK_CHAT_PROMO_BASE_PATHS.first)
Copy link
Member

Choose a reason for hiding this comment

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

Aside: It surprises me that this constant is in scope, I wonder how that works. I didn't think it'd be included when methods are included.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was a surprise to me too.

@@ -33,4 +33,12 @@ class AnswerTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item("answer")
assert_not page.has_css?(".gem-c-single-page-notification-button")
end

test "renders GOV.UK chat promo for matching base path" do
Copy link
Member

Choose a reason for hiding this comment

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

Yeah it doesn't look like there is one. Closest thing seems to be meta_tags test.

I imagine we've got a choice between

  1. no test, consider the integration code sufficiently simple that it doesn't need a test
  2. create a simple govuk_chat_promo_test in integration tests.

I think the most responsible thing to do is the latter with us being prepared to remove it if the team don't want it to keep chat surface area smaller.

I guess a thing to consider is that, for when we have the component installed, the assertion will change from has_text?("Try GOV.UK Chat") to has_selector(".gem-c-chat-entry") so would be a little more contrived as we shouldn't couple the test to the component copy.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 27, 2024 08:49 Inactive
@jackbot
Copy link
Contributor Author

jackbot commented Aug 27, 2024

@kevindew @leenagupte one thing I've noticed is the placement of the CTA on mobile in the designs makes things a little bit more complex.

Here's a side-by-side of what it currently looks like vs what it should look like:

App Design
Screenshot 2024-08-27 at 09 49 47 Screenshot 2024-08-27 at 09 54 06

So the CTA should come below the related content, whereas the placement in this PR places it above, like it does on desktop.

So there'a couple of solutions here:

  1. Leave it as it is - means less impact on this codebase. We can talk to design and see if they're happy with this compromise
  2. Modify the CSS so that on mobile the sidebar is display: flex; flex-direction: column-reverse to swap the position of the CTA and related content. This comes at the cost of touching more files in this codebase though

Let me know what you think.

@leenagupte
Copy link
Contributor

@jackbot I think it's best to check with the frontend community about how the stacking of components works and the best options for solving this problem. Perhaps @andysellick or @AshGDS could help?

@AshGDS
Copy link
Contributor

AshGDS commented Aug 27, 2024

If I'm understanding the flex proposal correctly, would this swap the order of the Related content and Collection sections on the sidebar? If so, this will impact analytics (which relies on indexes listing what position the sections are in lists)

@kevindew
Copy link
Member

Thanks @jackbot, so if I understand correctly the designs dictate a different ordering for desktop and mobile. I think it'd be best to check with our designers first on this. Let's first rule out that the changing order isn't a mistake. It seems unnecessarily complex having order different in mobile so I think we should push for having just one that is consistent for both.

@jackbot
Copy link
Contributor Author

jackbot commented Aug 27, 2024

@AshGDS thanks for the reply. Sorry, my screenshots didn't illustrate this particularly well.

The flex proposal wouldn't touch the ordering of the "Related content" and "collection" sections at all. It would position the new Chat promo below the "collection" section.

As-is With flex stuff applied
Screenshot 2024-08-27 at 11 20 59 Screenshot 2024-08-27 at 11 24 24

@jackbot
Copy link
Contributor Author

jackbot commented Aug 27, 2024

Thanks @kevindew, I'll check with design then.

@jon-kirwan
Copy link
Contributor

  1. Modify the CSS so that on mobile the sidebar is display: flex; flex-direction: column-reverse to swap the position of the CTA and related content. This comes at the cost of touching more files in this codebase though

Let me know what you think.

I think there could be accessibility problems with changing the order using flex, particularly for keyboard users, as it will cause items to be navigated in reverse order.

@AshGDS
Copy link
Contributor

AshGDS commented Aug 27, 2024

No worries, thanks @jackbot - an issue with ordering elements with flex is that the order of the DOM is preserved, which could create an accessibility issue.

See here for more information: https://adropincalm.com/blog/accessibility-issues-using-order-in-grid-and-flex/

EDIT: Ah, just seen Jon has said the same 👍

@jackbot
Copy link
Contributor Author

jackbot commented Aug 27, 2024

Thanks for that @jon-kirwan and @AshGDS, I wasn't aware of that accessibility issue.

I've talked to design about this and they're happy that the promo sits above the related content section, so we don't need to do anything here to fiddle with the layout on mobile.

I'm going to mark this ready for review now.

@jackbot jackbot marked this pull request as ready for review August 27, 2024 13:08
Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

I've added one tiny inline comment about the test file name, but other than that it looks good to me 👍

I've added the environment variable to the review app in Heroku to try it out.

Strangely enough the first link https://government-frontend-pr-3303.herokuapp.com/business-support-helpline redirects to https://www.gov.uk/business-support-service for me. Not sure what's happening there.

All the other pages look great though.

test/helpers/govuk_chat_promo_helper_spec.rb Outdated Show resolved Hide resolved

class GovukChatPromoHelperTest < ActionView::TestCase
test "show_govuk_chat_promo? when configuration disabled" do
assert_not show_govuk_chat_promo?(GOVUK_CHAT_PROMO_BASE_PATHS.first)
Copy link
Contributor

Choose a reason for hiding this comment

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

This was a surprise to me too.

We want to show a promo to the new GOV.UK Chat application on certain pages
on GOV.UK.

The list of URLs is quite short and cover only `answer` and `guide`
content types.

The CTA is to be shown in the sidebar on the right of the relevant
pages.
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3303 August 28, 2024 07:18 Inactive
@jackbot jackbot changed the title [DO NOT MERGE] Display GOV.UK Chat promo on certain pages Display GOV.UK Chat promo on certain pages Aug 28, 2024
@jackbot
Copy link
Contributor Author

jackbot commented Aug 28, 2024

Thanks for adding the env var there and doing the testing @leenagupte. I've fixed the filename of the test file now.

Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

👍

@jackbot jackbot merged commit d8751d8 into main Aug 28, 2024
11 checks passed
@jackbot jackbot deleted the govuk-chat-promo branch August 28, 2024 09:45
davidgisbey added a commit to alphagov/finder-frontend that referenced this pull request Nov 25, 2024
We want to show a promo to the new GOV.UK Chat application on certain pages
on GOV.UK.

We already have this implemented in Government Frontend
alphagov/government-frontend#3303
and Collections alphagov/collections#3742.

We're implementing it in:

- finder_frontend
- smart_answers
- frontend

This updates the finder show page to render the chat banner above the
related links similar to the other applications.
davidgisbey added a commit to alphagov/finder-frontend that referenced this pull request Nov 26, 2024
We want to show a promo to the new GOV.UK Chat application on certain pages
on GOV.UK.

We already have this implemented in Government Frontend
alphagov/government-frontend#3303
and Collections alphagov/collections#3742.

We're implementing it in:

- finder_frontend
- smart_answers
- frontend

This updates the finder show page to render the chat banner above the
related links similar to the other applications.
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.

6 participants