diff --git a/.k8s/live/api-sandbox/app-config.yaml b/.k8s/live/api-sandbox/app-config.yaml index 4d7b9cbfa1..0e346feeda 100644 --- a/.k8s/live/api-sandbox/app-config.yaml +++ b/.k8s/live/api-sandbox/app-config.yaml @@ -18,6 +18,5 @@ data: SETTINGS__AWS__POLL_MESSAGE_COUNT: '10' SETTINGS__AWS__POLL_MESSAGE_WAIT_TIME: '0' SETTINGS__AWS__S3__REGION: 'eu-west-2' - SURVEY_MONKEY_COLLECTOR_ID: '330288407' LAA_FEE_CALCULATOR_HOST: https://laa-fee-calculator.service.justice.gov.uk/api/v1 ALLOW_FUTURE_DATES: 'true' diff --git a/.k8s/live/production/app-config.yaml b/.k8s/live/production/app-config.yaml index 48da81dc5c..e9ac74e5e4 100644 --- a/.k8s/live/production/app-config.yaml +++ b/.k8s/live/production/app-config.yaml @@ -19,7 +19,6 @@ data: SETTINGS__AWS__POLL_MESSAGE_COUNT: '10' SETTINGS__AWS__POLL_MESSAGE_WAIT_TIME: '0' SETTINGS__AWS__S3__REGION: 'eu-west-2' - SURVEY_MONKEY_COLLECTOR_ID: '330288407' SURVEY_MONKEY_COURT_DATA_COLLECTOR_ID: '330346602' LAA_FEE_CALCULATOR_HOST: https://laa-fee-calculator.service.justice.gov.uk/api/v1 ALLOW_FUTURE_DATES: 'false' diff --git a/.k8s/live/staging/app-config.yaml b/.k8s/live/staging/app-config.yaml index 1ff9ce33c3..fcd8639804 100644 --- a/.k8s/live/staging/app-config.yaml +++ b/.k8s/live/staging/app-config.yaml @@ -19,7 +19,6 @@ data: SETTINGS__AWS__POLL_MESSAGE_COUNT: '10' SETTINGS__AWS__POLL_MESSAGE_WAIT_TIME: '0' SETTINGS__AWS__S3__REGION: 'eu-west-2' - SURVEY_MONKEY_COLLECTOR_ID: '330289923' SURVEY_MONKEY_COURT_DATA_COLLECTOR_ID: '330346602' LAA_FEE_CALCULATOR_HOST: https://staging.laa-fee-calculator.service.justice.gov.uk/api/v1 ALLOW_FUTURE_DATES: 'false' diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb index 3105da276f..5ed878a8bc 100644 --- a/app/controllers/feedback_controller.rb +++ b/app/controllers/feedback_controller.rb @@ -1,7 +1,6 @@ class FeedbackController < ApplicationController skip_load_and_authorize_resource only: %i[new create] before_action :suppress_hotline_link - before_action :setup_page def new @feedback = Feedback.new(type:, referrer: referrer_path) @@ -21,13 +20,7 @@ def create private - def sender - if params['feedback']['type'] == 'feedback' && !Settings.zendesk_feedback_enabled? - SurveyMonkeySender::Feedback - else - ZendeskSender - end - end + def sender = ZendeskSender def type %w[feedback bug_report].include?(params[:type]) ? params[:type] : 'feedback' @@ -70,8 +63,4 @@ def feedback_params reason: [] ) end - - def setup_page - @feedback_form = FeedbackForm.new if type == 'feedback' - end end diff --git a/app/forms/feedback_form.rb b/app/forms/feedback_form.rb deleted file mode 100644 index 1fb217bfa5..0000000000 --- a/app/forms/feedback_form.rb +++ /dev/null @@ -1,68 +0,0 @@ -class FeedbackForm - Section = Struct.new(:id, :format, :answers) - Answer = Struct.new(:key, :label, :id, :other) do - def formatted_id - return { id:, other: true } if other - - id - end - end - - def name = :feedback - def id = 26_019_002 - def collector = :feedback - - def template - { - tasks: template_for(tasks), - ratings: template_for(ratings), - reasons: template_for(reasons), - comments: { id: 62_469_815, format: :text } - } - end - - def tasks - Section.new( - 62_469_808, :radio, - [ - Answer.new('3', 'Yes', 519_552_297), - Answer.new('2', 'No', 519_552_298), - Answer.new('1', 'Partially', 519_552_299) - ] - ) - end - - def ratings - Section.new( - 62_469_811, :radio, - [ - Answer.new('5', 'Very satisfied', 519_552_314), - Answer.new('4', 'Satisfied', 519_552_335), - Answer.new('3', 'Neither satisfied nor dissatisfied', 519_552_315), - Answer.new('2', 'Dissatisfied', 519_552_316), - Answer.new('1', 'Very dissatisfied', 519_552_317) - ] - ) - end - - def reasons - Section.new( - 62_469_839, :checkboxes, - [ - Answer.new('3', 'Submit a LGFS claim', 519_552_475), - Answer.new('2', 'Submit an AGFS claim', 519_552_476), - Answer.new('1', 'Other (please specify)', 519_552_477, other: true) - ] - ) - end - - private - - def template_for(section) - { - id: section.id, - format: section.format, - answers: section.answers.to_h { |answer| [answer.key, answer.formatted_id] } - } - end -end diff --git a/app/models/feedback.rb b/app/models/feedback.rb index 7c0a01b18c..33d296cc40 100644 --- a/app/models/feedback.rb +++ b/app/models/feedback.rb @@ -3,10 +3,9 @@ class Feedback include ActiveModel::Validations attr_accessor :email, :referrer, :user_agent, :type, - :event, :outcome, :case_number, - :task, :rating, :comment, :reason, :other_reason, :response_message + :event, :outcome, :case_number, :response_message - validates :type, inclusion: { in: %w[feedback bug_report] } + validates :type, inclusion: { in: %w[bug_report] } validates :event, :outcome, presence: true, if: -> { is?(:bug_report) } def initialize(attributes = {}) diff --git a/app/services/survey_monkey_sender/feedback.rb b/app/services/survey_monkey_sender/feedback.rb deleted file mode 100644 index 1a3144f0a4..0000000000 --- a/app/services/survey_monkey_sender/feedback.rb +++ /dev/null @@ -1,22 +0,0 @@ -module SurveyMonkeySender - class Feedback < Base - private - - def page_name = :feedback - - def payload - { - tasks: @answers.task, - ratings: @answers.rating, - comments: @answers.comment, - reasons: reasons(@answers.reason, @answers.other_reason) - }.compact_blank - end - - def reasons(reason, other_reason) - return if reason.blank? - - reason + [{ other: other_reason }] - end - end -end diff --git a/app/views/feedback/feedback.html.haml b/app/views/feedback/feedback.html.haml index c43e0ffaa1..e69e646364 100644 --- a/app/views/feedback/feedback.html.haml +++ b/app/views/feedback/feedback.html.haml @@ -1,46 +1,16 @@ = content_for :page_title, flush: true do = t('.page_title') -= render partial: 'layouts/header', locals: { page_heading: t('.page_heading') } - -.govuk-grid-row - .govuk-grid-column-two-thirds - = form_for @feedback, url: feedback_index_path(email: params[:email]), html: { novalidate: 'novalidate' } do |f| - = f.hidden_field :type - = f.hidden_field :referrer - = hidden_field_tag 'ga_client_id', '', class: 'ga-client-id' - - = f.govuk_error_summary - - = govuk_inset_text do - %p - = t('.callout') - = render partial: 'feedback/claim_edit_alert' if referrer_is_claim?(@feedback.referrer) - - = f.govuk_radio_buttons_fieldset :task, legend: { text: t('.task_legend'), size: 'm' } do - - @feedback_form.tasks.answers.map do |task| - = f.govuk_radio_button :task, task.key, label: { text: task.label } do - - if task.label.eql?('No') || task.label.eql?('Partially') - %p.govuk-body{class: 'govuk-!-margin-bottom-6'} - = t('.report_fault_html', bug_report_link: new_feedback_path(type: 'bug_report')) - - = f.govuk_collection_radio_buttons :rating, - @feedback_form.ratings.answers, :key, :label, - legend: { text: t('.rating') } - - = f.govuk_text_area :comment, - label: { text: t('.comment'), size: 'm' }, - hint: { text: t('.comment_hint') } - - = f.govuk_check_boxes_fieldset :reason, legend: { text: t('.reason'), size: "m" } do - - - @feedback_form.reasons.answers.map do |reason| - = f.govuk_check_box :reason, - reason.key, - label: { text: reason.label } do - - - if reason.other - = f.govuk_text_field :other_reason, - label: { text: t('.reason_other') } - - = f.govuk_submit(t('.send')) +- title(t('.page_heading')) unless content_for?(:page_title) + += javascript_tag nonce: true, id: 'ss-embed-2909982' do + :plain + (function(d,w){ + var s,ss; + ss=d.createElement('script'); + ss.type='text/javascript'; + ss.async=true; + ss.src=('https:'==d.location.protocol?'https://':'http://')+'www.smartsurvey.co.uk/s/embed/2909982/js/'; + s=d.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(ss, s); + })(document,window); diff --git a/config/initializers/survey_monkey.rb b/config/initializers/survey_monkey.rb index f2434f3a28..081f9428b2 100644 --- a/config/initializers/survey_monkey.rb +++ b/config/initializers/survey_monkey.rb @@ -5,11 +5,8 @@ config.logger = Rails.logger config.verbose_logging = true - config.register_collector(:feedback, id: ENV['SURVEY_MONKEY_COLLECTOR_ID']) config.register_collector(:court_data, id: ENV['SURVEY_MONKEY_COURT_DATA_COLLECTOR_ID']) - feedback_page = FeedbackForm.new - config.register_page(feedback_page.name, id: feedback_page.id, collector: feedback_page.collector, questions: feedback_page.template) court_data_page = CourtDataForm.new config.register_page(court_data_page.name, id: court_data_page.id, collector: court_data_page.collector, questions: court_data_page.template) end diff --git a/features/feedback.feature b/features/feedback.feature deleted file mode 100644 index 95b224f1ac..0000000000 --- a/features/feedback.feature +++ /dev/null @@ -1,72 +0,0 @@ -@javascript @no-seed -Feature: A user can provide feedback - @stub_survey_monkey_feedback_success - Scenario: A user can successfully submit feedback - Given I visit "/" - And Zendesk Feedback is 'Disabled' - When I click the link 'Provide feedback' - Then I should see a page title "Help us improve this service" - Then the page should be accessible skipping 'aria-allowed-attr' - - And I choose govuk radio 'Yes' for 'Were you able to complete the tasks you aimed to on Claim for crown court defence today?' - And I choose govuk radio 'Very satisfied' for 'How satisfied have you been in your experience of Claim for crown court defence today?' - And I fill in 'Tell us about your experience of using the service today' with 'This is great!' - And I click govuk checkbox 'Other (please specify)' - And I fill in 'Enter your comment' with 'Something Else' - And I click the button 'Send' - - Then I see confirmation that my 'feedback' was received - And I should be on the sign in page - - @stub_zendesk_feedback_success - Scenario: A user can successfully submit feedback - Given I visit "/" - And Zendesk Feedback is 'Enabled' - When I click the link 'Provide feedback' - Then I should see a page title "Help us improve this service" - Then the page should be accessible skipping 'aria-allowed-attr' - - And I choose govuk radio 'Yes' for 'Were you able to complete the tasks you aimed to on Claim for crown court defence today?' - And I choose govuk radio 'Very satisfied' for 'How satisfied have you been in your experience of Claim for crown court defence today?' - And I fill in 'Tell us about your experience of using the service today' with 'This is great!' - And I click govuk checkbox 'Other (please specify)' - And I fill in 'Enter your comment' with 'Something Else' - And I click the button 'Send' - - Then I see confirmation that my 'feedback' was received - And I should be on the sign in page - - @stub_survey_monkey_feedback_failure - Scenario: A user receives notification of a failure to submit feedback - Given I visit "/" - And Zendesk Feedback is 'Disabled' - When I click the link 'Provide feedback' - Then I should see a page title "Help us improve this service" - Then the page should be accessible skipping 'aria-allowed-attr' - - And I choose govuk radio 'Yes' for 'Were you able to complete the tasks you aimed to on Claim for crown court defence today?' - And I choose govuk radio 'Very satisfied' for 'How satisfied have you been in your experience of Claim for crown court defence today?' - And I fill in 'Tell us about your experience of using the service today' with 'This is great!' - And I click govuk checkbox 'Other (please specify)' - And I fill in 'Enter your comment' with 'Something Else' - And I click the button 'Send' - - Then I see a warning that my feedback was not submitted successfully - And I should be on the feedback page - - @stub_zendesk_feedback_failure - Scenario: A user receives notification of a failure to submit feedback - Given I visit "/" - And Zendesk Feedback is 'Enabled' - When I click the link 'Provide feedback' - Then I should see a page title "Help us improve this service" - Then the page should be accessible skipping 'aria-allowed-attr' - - And I choose govuk radio 'Yes' for 'Were you able to complete the tasks you aimed to on Claim for crown court defence today?' - And I choose govuk radio 'Very satisfied' for 'How satisfied have you been in your experience of Claim for crown court defence today?' - And I fill in 'Tell us about your experience of using the service today' with 'This is great!' - And I click govuk checkbox 'Other (please specify)' - And I fill in 'Enter your comment' with 'Something Else' - And I click the button 'Send' - Then I see a warning that my feedback was not submitted successfully - And I should be on the feedback page diff --git a/spec/forms/feedback_form_spec.rb b/spec/forms/feedback_form_spec.rb deleted file mode 100644 index d566e62ab0..0000000000 --- a/spec/forms/feedback_form_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rails_helper' - -RSpec.describe FeedbackForm do - subject(:form) { described_class.new } - - describe '#name' do - subject { form.name } - - it { is_expected.to eq :feedback } - end - - describe '#id' do - subject { form.id } - - it { is_expected.to eq 26_019_002 } - end - - describe '#collector' do - subject { form.collector } - - it { is_expected.to eq :feedback } - end - - describe '#template' do - subject(:template) { form.template } - - it { is_expected.to be_a Hash } - it { expect(template.values).to all(be_instance_of(Hash)) } - end -end diff --git a/spec/models/feedback_spec.rb b/spec/models/feedback_spec.rb index aab6c77387..c38b92341b 100644 --- a/spec/models/feedback_spec.rb +++ b/spec/models/feedback_spec.rb @@ -8,26 +8,24 @@ } end - it { is_expected.to validate_inclusion_of(:type).in_array(%w[feedback bug_report]) } + it { is_expected.to validate_inclusion_of(:type).in_array(%w[bug_report]) } shared_examples 'Feedback submission' do let(:feedback_params) do params.merge( - type: 'feedback', - task: '1', - sender:, - rating: '4', - comment: 'lorem ipsum', - reason: ['', '1', '2'], - other_reason: 'dolor sit' + type: 'bug_report', + case_number: 'XXX', + event: 'lorem', + outcome: 'ipsum', + email: 'example@example.com', + sender: ) end - it { expect(feedback.task).to eq '1' } - it { expect(feedback.rating).to eq '4' } - it { expect(feedback.comment).to eq 'lorem ipsum' } - it { expect(feedback.reason).to eq %w[1 2] } - it { expect(feedback.other_reason).to eq 'dolor sit' } + it { expect(feedback.case_number).to eq 'XXX' } + it { expect(feedback.event).to eq 'lorem' } + it { expect(feedback.outcome).to eq 'ipsum' } + it { expect(feedback.email).to eq 'example@example.com' } describe '#save' do let(:save) { feedback.save } @@ -70,23 +68,15 @@ describe '#is?' do context 'with feedback type' do - it { expect(feedback.is?(:feedback)).to be true } + it { expect(feedback.is?(:feedback)).to be false } end context 'with bug_report type' do - it { expect(feedback.is?(:bug_report)).to be false } + it { expect(feedback.is?(:bug_report)).to be true } end end end - context 'with SurveyMonkey Feedback' do - subject(:feedback) { described_class.new(feedback_params) } - - let(:sender) { SurveyMonkeySender::Feedback } - - include_examples 'Feedback submission' - end - context 'with Zendesk Feedback' do subject(:feedback) { described_class.new(feedback_params) } @@ -100,12 +90,11 @@ let(:feedback_params) do params.merge( - type: 'feedback', - task: '1', - rating: '4', - comment: 'lorem ipsum', - reason: ['', '1', '2'], - other_reason: 'dolor sit' + type: 'bug_report', + case_number: 'XXX', + event: 'lorem', + outcome: 'ipsum', + email: 'test@example.com' ) end @@ -135,7 +124,6 @@ it { expect(bug_report.user_agent).to eq('Firefox') } it { expect(bug_report.referrer).to eq('/index') } - it { is_expected.not_to validate_inclusion_of(:rating).in_array(('1'..'5').to_a) } it { is_expected.to validate_presence_of(:event) } it { is_expected.to validate_presence_of(:outcome) } it { is_expected.not_to validate_presence_of(:case_number) } diff --git a/spec/requests/feedback_spec.rb b/spec/requests/feedback_spec.rb index e7e6acc584..086264769f 100644 --- a/spec/requests/feedback_spec.rb +++ b/spec/requests/feedback_spec.rb @@ -31,91 +31,6 @@ end end - describe 'POST /feedback (for feedback)' do - subject(:post_feedback) { post feedback_index_url, params: { feedback: params } } - - let(:params) do - { - type: 'feedback', - task: '1', - rating: '4', - comment: 'lorem ipsum', - reason: ['', '1', '2'], - other_reason: 'dolor sit' - } - end - - context 'with Zendesk feedback enabled' do - let(:sender_instance) { instance_double(ZendeskSender) } - - before do - allow(Settings).to receive(:zendesk_feedback_enabled?).and_return(true) - allow(Feedback).to receive(:new).and_call_original - allow(ZendeskSender).to receive(:new).and_return(sender_instance) - allow(sender_instance).to receive(:call).and_return({ success: true, response_message: 'Test' }) - - post_feedback - end - - it 'Uses the Zendesk sender' do - expect(Feedback).to have_received(:new).with(hash_including(sender: ZendeskSender)) - end - end - - context 'with Zendesk feedback disabled' do - let(:sender_instance) { instance_double(SurveyMonkeySender::Feedback) } - - before do - allow(Settings).to receive(:zendesk_feedback_enabled?).and_return(false) - allow(Feedback).to receive(:new).and_call_original - allow(SurveyMonkeySender::Feedback).to receive(:new).and_return(sender_instance) - allow(sender_instance).to receive(:call).and_return({ success: true, response_message: 'Test' }) - - post_feedback - end - - it 'Uses the SurveyMonkey sender' do - expect(Feedback).to have_received(:new).with(hash_including(sender: SurveyMonkeySender::Feedback)) - end - end - - context 'when posting to Survey Monkey is successful' do - before { allow(SurveyMonkeySender::Feedback).to receive(:call).and_return({ id: 123, success: true }) } - - context 'when the user is signed in' do - let(:advocate) { create(:external_user) } - - before do - sign_in advocate.user - post_feedback - end - - it 'redirects to the users home' do - expect(response).to redirect_to(external_users_root_url) - end - end - - context 'when the user is not signed in' do - before { post_feedback } - - it 'redirects to the sign in page' do - expect(response).to redirect_to(new_user_session_url) - end - end - end - - context 'when posting to Survey Monkey is unsuccessful' do - before do - allow(SurveyMonkeySender::Feedback).to receive(:call).and_return({ success: false, error_code: '1020' }) - post_feedback - end - - it 'renders the new template' do - expect(response).to render_template('feedback/feedback') - end - end - end - describe 'POST /feedback (for a bug report)' do subject(:post_feedback) { post feedback_index_url, params: { feedback: params } } diff --git a/spec/services/survey_monkey_sender/feedback_spec.rb b/spec/services/survey_monkey_sender/feedback_spec.rb deleted file mode 100644 index 874c414dc8..0000000000 --- a/spec/services/survey_monkey_sender/feedback_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -RSpec.describe SurveyMonkeySender::Feedback do - subject(:sender) { described_class.new(feedback) } - - let(:feedback) { Feedback.new } - let(:survey_monkey) { instance_double(SurveyMonkey::Response) } - - before do - allow(SurveyMonkey::Response).to receive(:new).and_return(survey_monkey) - allow(survey_monkey).to receive(:add_page) - end - - describe '.new' do - subject(:sender) { described_class.new(feedback) } - - let(:survey_monkey) { instance_double(SurveyMonkey::Response) } - - before { sender } - - context 'with all feedback options' do - let(:feedback) do - Feedback.new(task: '1', rating: '1', comment: 'A comment', - reason: %w[1 3], other_reason: 'Another reason') - end - - it do - expect(survey_monkey).to have_received(:add_page) - .with( - :feedback, tasks: '1', ratings: '1', comments: 'A comment', - reasons: ['1', '3', { other: 'Another reason' }] - ) - end - end - - context 'with only a comment' do - let(:feedback) do - Feedback.new(task: nil, rating: nil, comment: 'A comment', reason: [], other_reason: nil) - end - - it { expect(survey_monkey).to have_received(:add_page).with(:feedback, comments: 'A comment') } - end - - context 'with a nil reason' do - let(:feedback) do - Feedback.new(task: nil, rating: nil, comment: 'A comment', reason: nil, other_reason: nil) - end - - it { expect(survey_monkey).to have_received(:add_page).with(:feedback, comments: 'A comment') } - end - end - - describe '#call' do - subject(:call) { sender.call } - - context 'with a successful submission' do - before { allow(survey_monkey).to receive(:submit).and_return({ id: 123, success: true }) } - - it { is_expected.to eq({ success: true, response_message: 'Feedback submitted' }) } - end - - context 'with an unsuccessful submission' do - before { allow(survey_monkey).to receive(:submit).and_return({ success: false, error_code: 1011 }) } - - it { is_expected.to eq({ success: false, response_message: 'Unable to submit feedback [1011]' }) } - end - end -end