From da21d6872c9e735852202e117e63facd062a8b3a Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 28 Jan 2020 11:41:28 +0000 Subject: [PATCH] Updated redirect attribute so that it reflected correct yaml entry and payload attribute to default to json remove payload as request defeaults to json remove payload as request defeaults to json --- app/assets/javascripts/webchat/library.js | 4 +--- app/models/webchat.rb | 3 +-- app/views/shared/_webchat.html.erb | 2 +- spec/javascripts/webchat.spec.js | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index 738191702..e3417edfd 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -24,7 +24,6 @@ var webchatStateClass = 'js-webchat-advisers-' var intervalID = null var lastRecordedState = null - var response_datatype = $el.attr('data-redirect') function init () { if (!availabilityUrl || !openUrl) throw 'urls for webchat not defined' @@ -35,7 +34,7 @@ function handleOpenChat (evt) { evt.preventDefault() - this.dataset.redirect =="true" ? window.location.href = openUrl : global.open(openUrl, 'newwin', 'width=366,height=516') + this.dataset.redirect == "true" ? window.location.href = openUrl : global.open(openUrl, 'newwin', 'width=366,height=516') trackEvent('opened') } @@ -43,7 +42,6 @@ var ajaxConfig = { url: availabilityUrl, type: 'GET', - dataType: response_datatype, timeout: AJAX_TIMEOUT, success: apiSuccess, error: apiError diff --git a/app/models/webchat.rb b/app/models/webchat.rb index b3ebecd32..d25f2d3eb 100644 --- a/app/models/webchat.rb +++ b/app/models/webchat.rb @@ -5,14 +5,13 @@ class Webchat validates_presence_of :base_path, :open_url, :availability_url - attr_reader :base_path, :open_url, :availability_url, :open_url_redirect, :availability_payload_format + attr_reader :base_path, :open_url, :availability_url, :open_url_redirect def initialize(attrs) @base_path = attrs["base_path"] if attrs["base_path"].present? @open_url = attrs["open_url"] if attrs["open_url"].present? @availability_url = attrs["availability_url"] if attrs["availability_url"].present? @open_url_redirect = attrs.fetch("open_url_redirect", nil) - @availability_payload_format = attrs.fetch("availability_payload_format", nil) validate! end diff --git a/app/views/shared/_webchat.html.erb b/app/views/shared/_webchat.html.erb index a67af394f..d0261df32 100644 --- a/app/views/shared/_webchat.html.erb +++ b/app/views/shared/_webchat.html.erb @@ -4,7 +4,7 @@ <% if webchat_unavailable? %> <%= unavailability_message %> diff --git a/spec/javascripts/webchat.spec.js b/spec/javascripts/webchat.spec.js index 436cf4324..42b8f6fe5 100644 --- a/spec/javascripts/webchat.spec.js +++ b/spec/javascripts/webchat.spec.js @@ -10,7 +10,7 @@ describe('Webchat', function () { GOVUK.analytics.trackEvent = function () {} var CHILD_BENEFIT_API_URL = 'https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006859&siteID=10006719&businessUnitID=19001235' - var INSERTION_HOOK = '
' + + var INSERTION_HOOK = '
' + '
Error
' + '' + '' + @@ -68,7 +68,7 @@ describe('Webchat', function () { mount() expect( $.ajax - ).toHaveBeenCalledWith({ url: CHILD_BENEFIT_API_URL, type: 'GET', dataType: "jsonp" ,timeout: jasmine.any(Number), success: jasmine.any(Function), error: jasmine.any(Function) }) + ).toHaveBeenCalledWith({ url: CHILD_BENEFIT_API_URL, type: 'GET' ,timeout: jasmine.any(Number), success: jasmine.any(Function), error: jasmine.any(Function) }) }) it('should inform user whether advisors are available', function () {