diff --git a/app/components/footer_component.html.erb b/app/components/footer_component.html.erb index 5054724431..8a2a1bbc0d 100644 --- a/app/components/footer_component.html.erb +++ b/app/components/footer_component.html.erb @@ -46,5 +46,3 @@ - -<%= render "sections/zendesk_chat_settings" %> diff --git a/app/views/sections/_zendesk_chat_settings.html.erb b/app/views/sections/_zendesk_chat_settings.html.erb deleted file mode 100644 index 3e7363d797..0000000000 --- a/app/views/sections/_zendesk_chat_settings.html.erb +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/app/webpacker/javascript/zendesk_chat_reload.js b/app/webpacker/javascript/zendesk_chat_reload.js deleted file mode 100644 index 3e0c2eb5b5..0000000000 --- a/app/webpacker/javascript/zendesk_chat_reload.js +++ /dev/null @@ -1,7 +0,0 @@ -// Ensure the Zendesk Chat widget gets reloaded on page change. -// Without this, it works on the first page load but then does not -// appear if you change page and try and open it. -window.addEventListener('turbolinks:before-render', function () { - window.zEACLoaded = undefined; - window.$zopim = undefined; -}); diff --git a/app/webpacker/packs/application.js b/app/webpacker/packs/application.js index 9762d8641d..bc66f2b34f 100644 --- a/app/webpacker/packs/application.js +++ b/app/webpacker/packs/application.js @@ -11,7 +11,6 @@ require.context('../images', true); require.context('../documents', true); require('../javascript/perfume'); -require('../javascript/zendesk_chat_reload'); Rails.start(); Turbolinks.start(); diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index 16962591cf..8a8a59c91d 100644 --- a/config/initializers/secure_headers.rb +++ b/config/initializers/secure_headers.rb @@ -28,7 +28,6 @@ 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.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] @@ -51,7 +50,7 @@ # We're not sure why yet but the asset host needs to be # explicitly whitelisted in the media_src directive or the CSP - #  blocks videos from loading. We don't appear to have this issue + # blocks videos from loading. We don't appear to have this issue # with the img_src, oddly. assets = [] assets << ENV["APP_ASSETS_URL"] if ENV["APP_ASSETS_URL"].present? @@ -64,15 +63,15 @@ default_src: %w['none'], base_uri: self_base, child_src: self_base.concat(youtube, pinterest, snapchat), - connect_src: self_base.concat(google_apis, pinterest, google_analytics, google_supported, google_doubleclick, facebook, zendesk, snapchat, sentry, gtm_server, clarity, vwo), + connect_src: self_base.concat(google_apis, pinterest, google_analytics, google_supported, google_doubleclick, facebook, snapchat, sentry, gtm_server, clarity, vwo), font_src: self_base.concat(govuk, data, %w[fonts.gstatic.com]), form_action: self_base.concat(snapchat, facebook, govuk), frame_src: self_base.concat(snapchat, facebook, youtube, google_doubleclick, google_analytics, data, pinterest, clarity, vwo), frame_ancestors: self_base, img_src: self_base.concat(govuk, pinterest, facebook, youtube, twitter, google_supported, google_adservice, google_apis, google_analytics, google_doubleclick, data, lid_pixels, gtm_server, reddit, clarity, vwo, %w[chart.googleapis.com wingify-assets.s3.amazonaws.com cx.atdmt.com linkbam.uk]), manifest_src: self_base, - media_src: self_base.concat(zendesk).concat(assets), - script_src: quoted_unsafe_inline + quoted_unsafe_eval + self_base.concat(google_analytics, google_supported, google_apis, lid_pixels, govuk, facebook, jquery, pinterest, twitter, snapchat, youtube, zendesk, reddit, clarity, vwo), + media_src: self_base.concat(assets), + script_src: quoted_unsafe_inline + quoted_unsafe_eval + self_base.concat(google_analytics, google_supported, google_apis, lid_pixels, govuk, facebook, jquery, pinterest, twitter, snapchat, youtube, reddit, clarity, vwo), style_src: quoted_unsafe_inline + self_base.concat(govuk, google_apis, google_supported, vwo), worker_src: self_base.concat(blob), } diff --git a/spec/components/footer_component_spec.rb b/spec/components/footer_component_spec.rb index f55a6fa016..adb3720b50 100644 --- a/spec/components/footer_component_spec.rb +++ b/spec/components/footer_component_spec.rb @@ -26,13 +26,4 @@ expect(page).not_to have_css(talk_to_us_selector) end end - - describe "Zendesk Chat settings snippet" do - subject! do - render_inline(described_class.new) - page.native.inner_html - end - - it { is_expected.to include("window.zESettings") } - end end diff --git a/spec/javascript/controllers/chat_controller_spec.js b/spec/javascript/controllers/chat_controller_spec.js index 830908e4e1..f0953fbd52 100644 --- a/spec/javascript/controllers/chat_controller_spec.js +++ b/spec/javascript/controllers/chat_controller_spec.js @@ -5,9 +5,6 @@ describe('ChatController', () => { beforeAll(() => registerController()); afterEach(() => jest.useRealTimers()); - let chatShowSpy; - let chatOpenSpy; - const setBody = (chatAvailable = 'true') => { document.body.innerHTML = `
@@ -29,8 +26,6 @@ describe('ChatController', () => {

- - // Zendesk modal. `; } @@ -39,23 +34,15 @@ describe('ChatController', () => { application.register('chat', ChatController); } - const setCurrentTime = (time) => { - jest.useFakeTimers().setSystemTime(new Date(time).getTime()) - } - - const getButtonText = () => { - return document.querySelector('a').textContent; + const mockFetch = (result) => { + global.fetch = jest.fn(() => { + return Promise.resolve({ + json: () => (result) + }) + }) } - describe('when the new chat is enabled', () => { - - const mockFetch = (result) => { - global.fetch = jest.fn(() => { - return Promise.resolve({ - json: () => (result) - }) - }) - } + describe('chat', () => { describe('when the chat is online', () => { beforeEach(() => {