From b3f927ca58212c626ad0724cefce97c1fd7449a4 Mon Sep 17 00:00:00 2001 From: StackedPancakez <146324887+StackedPancakez@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:05:30 +0000 Subject: [PATCH 1/4] Revert "Remove code that starts and appends chat widget to the DOM" --- app/webpacker/controllers/chat_controller.js | 17 +++++++++++++++-- spec/features/chat_spec.rb | 2 +- .../controllers/chat_controller_spec.js | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) 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/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(); From 4744ffc566d1bd82e4110a5afd28b380d269fa9e Mon Sep 17 00:00:00 2001 From: john hayes-reed Date: Wed, 8 Nov 2023 13:22:40 +0000 Subject: [PATCH 2/4] Add websocket endpoint to secure headers for messaging --- config/initializers/secure_headers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index 21dc3b4dc8..3b2d4c5626 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.smootch.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] From 679d73a15ac3c73a0676e4a19ece4abd26c51a7a Mon Sep 17 00:00:00 2001 From: john hayes-reed Date: Wed, 8 Nov 2023 15:28:24 +0000 Subject: [PATCH 3/4] fix typo --- config/initializers/secure_headers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index 3b2d4c5626..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[wss://api.eu-1.smootch.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] + 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] From 42f64ca3929fc397c3d479cbf15125730aebf237 Mon Sep 17 00:00:00 2001 From: john hayes-reed Date: Mon, 13 Nov 2023 12:46:17 +0000 Subject: [PATCH 4/4] Remove CSS that kills launcher icon for chat widget --- app/webpacker/styles/links-and-buttons.scss | 5 ----- 1 file changed, 5 deletions(-) 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; -}