-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3303 from alphagov/govuk-chat-promo
Display GOV.UK Chat promo on certain pages
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module GovukChatPromoHelper | ||
GOVUK_CHAT_PROMO_BASE_PATHS = %w[ | ||
/business-support-helpline | ||
/company-tax-returns | ||
/corporation-tax | ||
/pay-corporation-tax | ||
/pay-vat | ||
/search-for-trademark | ||
/set-up-business | ||
/submit-vat-return | ||
/write-business-plan | ||
].freeze | ||
|
||
def show_govuk_chat_promo?(base_path) | ||
ENV["GOVUK_CHAT_PROMO_ENABLED"] == "true" && GOVUK_CHAT_PROMO_BASE_PATHS.include?(base_path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<% content_item = @content_item.content_item.parsed_content %> | ||
|
||
<div class="govuk-grid-column-one-third"> | ||
<% if show_govuk_chat_promo?(@content_item.base_path) %> | ||
<%= render "govuk_publishing_components/components/chat_entry", { border_top: true } %> | ||
<% end %> | ||
|
||
<%= render 'govuk_publishing_components/components/contextual_sidebar', content_item: content_item %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "test_helper" | ||
|
||
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) | ||
end | ||
|
||
test "show_govuk_chat_promo? when base_path not in configuration" do | ||
ClimateControl.modify GOVUK_CHAT_PROMO_ENABLED: "true" do | ||
assert_not show_govuk_chat_promo?("/non-matching-path") | ||
end | ||
end | ||
|
||
test "show_govuk_chat_promo? when base_path is in configuration" do | ||
ClimateControl.modify GOVUK_CHAT_PROMO_ENABLED: "true" do | ||
assert show_govuk_chat_promo?(GOVUK_CHAT_PROMO_BASE_PATHS.first) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "test_helper" | ||
|
||
class GovukChatPromoTest < ActionDispatch::IntegrationTest | ||
test "renders GOV.UK chat promo for matching content type and base path" do | ||
ClimateControl.modify GOVUK_CHAT_PROMO_ENABLED: "true" do | ||
setup_and_visit_a_page_with_specific_base_path("answer", GovukChatPromoHelper::GOVUK_CHAT_PROMO_BASE_PATHS.first) | ||
|
||
assert page.has_css?(".gem-c-chat-entry") | ||
end | ||
end | ||
|
||
def schema_type | ||
"answer" | ||
end | ||
end |