diff --git a/app/webpacker/controllers/chat_controller.js b/app/webpacker/controllers/chat_controller.js index aef18e4883..527c863387 100644 --- a/app/webpacker/controllers/chat_controller.js +++ b/app/webpacker/controllers/chat_controller.js @@ -27,9 +27,8 @@ export default class extends Controller { const closeTime = dayjs().set('hour', 17).set('minute', 30).tz(timeZone); const now = dayjs().tz(timeZone); const weekend = [6, 0].includes(now.get('day')); - const disabled = true; // temporary to disable chat - return !disabled && !weekend && now >= openTime && now <= closeTime; + return !weekend && now >= openTime && now <= closeTime; } start(e) { @@ -43,6 +42,8 @@ export default class extends Controller { this.chatTarget.textContent = 'Starting chat...'; } + this.appendZendeskScript(); + this.waitForZendeskScript(() => { this.showWebWidget(); this.waitForWebWidget(() => { @@ -51,6 +52,18 @@ export default class extends Controller { }); } + appendZendeskScript() { + if (this.zendeskScriptLoaded) { + return; + } + + const script = document.createElement('script'); + script.setAttribute('id', 'ze-snippet'); + script.src = + 'https://static.zdassets.com/ekr/snippet.js?key=34a8599c-cfec-4014-99bd-404a91839e37'; + document.body.appendChild(script); + } + waitForWebWidget(callback) { const interval = setInterval(() => { if (window.zEACLoaded) { diff --git a/app/webpacker/styles/links-and-buttons.scss b/app/webpacker/styles/links-and-buttons.scss index 4e3f88599f..dc9933ca9e 100644 --- a/app/webpacker/styles/links-and-buttons.scss +++ b/app/webpacker/styles/links-and-buttons.scss @@ -200,8 +200,3 @@ body a.govuk-back-link { display: inline-block; } } - -// Default Zendesk chat button (hidden as we use our own). -#launcher { - display: none; -} diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index 21dc3b4dc8..3f495b6491 100644 --- a/config/initializers/secure_headers.rb +++ b/config/initializers/secure_headers.rb @@ -28,7 +28,7 @@ google_doubleclick = %w[*.doubleclick.net *.googleads.g.doubleclick.net *.ad.doubleclick.net *.fls.doubleclick.net stats.g.doubleclick.net] google_apis = %w[*.googleapis.com googleapis.com https://fonts.googleapis.com] - zendesk = %w[api.eu-1.smooch.io *.zendesk.com static.zdassets.com https://*.zopim.com wss://*.zopim.com dfesupport-tpuk.zendesk.com ekr.zdassets.com] + zendesk = %w[wss://api.eu-1.smooch.io/faye api.eu-1.smooch.io *.zendesk.com static.zdassets.com https://*.zopim.com wss://*.zopim.com dfesupport-tpuk.zendesk.com ekr.zdassets.com] facebook = %w[*.facebook.com *.facebook.net *.connect.facebook.net] govuk = %w[*.gov.uk www.gov.uk] jquery = %w[code.jquery.com] diff --git a/spec/features/chat_spec.rb b/spec/features/chat_spec.rb index 50d5316a0a..2107d03405 100644 --- a/spec/features/chat_spec.rb +++ b/spec/features/chat_spec.rb @@ -11,7 +11,7 @@ context "when chat is online" do let(:date) { Time.zone.local(2021, 1, 1, 9) } - xscenario "viewing the chat section of the talk to us component" do + scenario "viewing the chat section of the talk to us component" do visit_on_date root_path dismiss_cookies diff --git a/spec/javascript/controllers/chat_controller_spec.js b/spec/javascript/controllers/chat_controller_spec.js index c6fc406fae..d89fc453bc 100644 --- a/spec/javascript/controllers/chat_controller_spec.js +++ b/spec/javascript/controllers/chat_controller_spec.js @@ -39,7 +39,7 @@ describe('ChatController', () => { return document.querySelector('a').textContent; } - xdescribe('when the chat is online', () => { + describe('when the chat is online', () => { beforeEach(() => { chatShowSpy = jest.fn(() => true); chatOpenSpy = jest.fn();