-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
There was a problem hiding this 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?
Nice one, this looks good enough to me that we could proceed to write tests for it. |
@kevindew I've added some tests here, with a couple of comments. I tested out the branch of 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" |
There was a problem hiding this 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.
73cea68
to
250f45c
Compare
Thanks @kevindew, I've made those changes to simplify things a bit. |
250f45c
to
80c18c8
Compare
test/integration/answer_test.rb
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
- no test, consider the integration code sufficiently simple that it doesn't need a test
- 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
test/integration/answer_test.rb
Outdated
@@ -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 |
There was a problem hiding this comment.
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
- no test, consider the integration code sufficiently simple that it doesn't need a test
- 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.
80c18c8
to
56b8d8e
Compare
@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:
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:
Let me know what you think. |
@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? |
If I'm understanding the |
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. |
@AshGDS thanks for the reply. Sorry, my screenshots didn't illustrate this particularly well. The
|
Thanks @kevindew, I'll check with design then. |
I think there could be accessibility problems with changing the order using |
No worries, thanks @jackbot - an issue with ordering elements with 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 👍 |
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. |
There was a problem hiding this 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.
|
||
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) |
There was a problem hiding this comment.
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.
56b8d8e
to
abd4912
Compare
Thanks for adding the env var there and doing the testing @leenagupte. I've fixed the filename of the test file now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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.
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.
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
andguide
content types from this codebase.The CTA is to be shown in the sidebar on the right of the relevant pages.