-
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.
Add HMRC webchat unavailability message
- Loading branch information
Steve Laing
committed
May 11, 2018
1 parent
03eb0f8
commit 5ced5c8
Showing
3 changed files
with
59 additions
and
18 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,20 @@ | ||
module WebchatAvailabilityHelper | ||
UNAVAILABILITY_MESSAGE = "This service will be unavailable from 4pm on Saturday 12 May to 9am on Monday 14 May.".freeze | ||
HMRC_WEBCHAT_CONTACT_PATHS = %w( | ||
/government/organisations/hm-revenue-customs/contact/online-services-helpdesk | ||
/government/organisations/hm-revenue-customs/contact/income-tax-enquiries-for-individuals-pensioners-and-employees | ||
/government/organisations/hm-revenue-customs/contact/self-assessment | ||
/government/organisations/hm-revenue-customs/contact/tax-credits-enquiries | ||
).freeze | ||
UNAVAILABILITY_START = Time.parse("2018-05-12 16:00 BST").freeze | ||
UNAVAILABILITY_END = Time.parse("2018-05-14 09:00 BST").freeze | ||
|
||
def webchat_unavailable?(now = Time.zone.now) | ||
show_unavailability = now >= UNAVAILABILITY_START && now < UNAVAILABILITY_END | ||
show_unavailability && HMRC_WEBCHAT_CONTACT_PATHS.include?(@content_item.base_path) | ||
end | ||
|
||
def unavailability_message | ||
UNAVAILABILITY_MESSAGE | ||
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,25 +1,29 @@ | ||
<span class="js-webchat" | ||
data-availability-url="<%= @content_item.webchat_availability_url %>" | ||
data-open-url="<%= @content_item.webchat_open_url %>"> | ||
<% if @content_item.base_path == '/government/organisations/hm-revenue-customs/contact/tax-credits-enquiries' %> | ||
Advisers can only talk to you about Child Tax Credit and Working Tax Credit. | ||
They won't be able to transfer you to another webchat team. | ||
<br/> | ||
<br/> | ||
<% if webchat_unavailable? %> | ||
<%= unavailability_message %> | ||
<% else %> | ||
<% if @content_item.base_path == '/government/organisations/hm-revenue-customs/contact/tax-credits-enquiries' %> | ||
Advisers can only talk to you about Child Tax Credit and Working Tax Credit. | ||
They won't be able to transfer you to another webchat team. | ||
<br/> | ||
<br/> | ||
<% end %> | ||
<span class="js-webchat-advisers-error"> | ||
Webchat is unavailable at the moment because of technical problems. | ||
</span> | ||
<span class="js-webchat-advisers-unavailable hidden"> | ||
Webchat is closed at the moment. | ||
</span> | ||
<span class="js-webchat-advisers-busy hidden"> | ||
All webchat advisers are busy at the moment. | ||
</span> | ||
<span class="js-webchat-advisers-available hidden"> | ||
Advisers are available to chat. | ||
<a href="#" rel="external" class="js-webchat-open-button">Speak to an adviser now</a>. | ||
</span> | ||
<% end %> | ||
<span class="js-webchat-advisers-error"> | ||
Webchat is unavailable at the moment because of technical problems. | ||
</span> | ||
<span class="js-webchat-advisers-unavailable hidden"> | ||
Webchat is closed at the moment. | ||
</span> | ||
<span class="js-webchat-advisers-busy hidden"> | ||
All webchat advisers are busy at the moment. | ||
</span> | ||
<span class="js-webchat-advisers-available hidden"> | ||
Advisers are available to chat. | ||
<a href="#" rel="external" class="js-webchat-open-button">Speak to an adviser now</a>. | ||
</span> | ||
</span> | ||
<% # This is inline in the source however slimmer will optimize this. %> | ||
<%= javascript_include_tag "webchat", integrity: true, crossorigin: 'anonymous' %> |
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 @@ | ||
require 'test_helper' | ||
|
||
class WebchatAvailabilityHelperTest < ActionView::TestCase | ||
tests WebchatAvailabilityHelper | ||
|
||
setup do | ||
@content_item = Object.new | ||
@content_item.stubs(:base_path).returns(HMRC_WEBCHAT_CONTACT_PATHS.first) | ||
end | ||
|
||
test "webchat_unavailable? indicates unavailability" do | ||
refute webchat_unavailable?(Time.parse("2018-05-12 15:59 BST")) | ||
assert webchat_unavailable?(Time.parse("2018-05-12 16:00 BST")) | ||
assert webchat_unavailable?(Time.parse("2018-05-14 08:59 BST")) | ||
refute webchat_unavailable?(Time.parse("2018-05-14 09:00 BST")) | ||
end | ||
end |