<commit_before>require 'rails_helper'

feature 'SAR Internal Review Case can be edited', js:true do

  given(:responder)       { find_or_create(:sar_responder) }
  given(:responding_team) { create :responding_team, responders: [responder] }
  given(:manager)         { find_or_create :disclosure_bmt_user }
  given(:managing_team)   { create :managing_team, managers: [manager] }
  given(:approver)        { (find_or_create :team_dacu_disclosure).users.first }

  let(:sar_ir) { create(:sar_internal_review) }
  let(:approved_sar_ir) { create(:approved_sar_internal_review, approver: approver) }
  let(:responding_sar_ir) { create(:approved_sar_internal_review, responder: responder, responding_team: responding_team) }

  let(:new_message) { 'This is an updated message' }
  let(:new_name) { '<NAME>' }
  let(:new_third_party_relationship) { 'Barrister' }

  background do
    responding_team
    find_or_create :team_dacu_disclosure
  end

  context 'as a manager' do
    it 'will allow me to edit a SAR IR case details' do
      when_a_manager_logs_in
      and_they_edit_the_case_details(sar_ir)
      then_they_expect_the_new_details_to_be_reflected_on_the_case_show_page
    end
  end

  fcontext 'as an approver' do
    it 'will allow me to edit a SAR IR case details' do
      when_an_approver_logs_in
      and_they_edit_the_case_details(approved_sar_ir)
      then_they_expect_the_new_details_to_be_reflected_on_the_case_show_page
    end
  end

  context 'as a responder' do
    it 'won\'t allow me to edit a SAR IR case details' do
      when_a_responder_logs_in
      and_loads_the_case_show_page
      they_cannot_edit_the_case
    end
  end

  private

  def when_a_manager_logs_in
    login_as manager
    cases_page.load
  end

  def when_an_approver_logs_in
    login_as approver
    cases_page.load<commit_msg>Remove test focus that should have been removed already (#1845)<commit_after>require 'rails_helper'

feature 'SAR Internal Review Case can be edited', js:true do

  given(:responder)       { find_or_create(:sar_responder) }
  given(:responding_team) { create :responding_team, responders: [responder] }
  given(:manager)         { find_or_create :disclosure_bmt_user }
  given(:managing_team)   { create :managing_team, managers: [manager] }
  given(:approver)        { (find_or_create :team_dacu_disclosure).users.first }

  let(:sar_ir) { create(:sar_internal_review) }
  let(:approved_sar_ir) { create(:approved_sar_internal_review, approver: approver) }
  let(:responding_sar_ir) { create(:approved_sar_internal_review, responder: responder, responding_team: responding_team) }

  let(:new_message) { 'This is an updated message' }
  let(:new_name) { '<NAME>' }
  let(:new_third_party_relationship) { 'Barrister' }

  background do
    responding_team
    find_or_create :team_dacu_disclosure
  end

  context 'as a manager' do
    it 'will allow me to edit a SAR IR case details' do
      when_a_manager_logs_in
      and_they_edit_the_case_details(sar_ir)
      then_they_expect_the_new_details_to_be_reflected_on_the_case_show_page
    end
  end

  context 'as an approver' do
    it 'will allow me to edit a SAR IR case details' do
      when_an_approver_logs_in
      and_they_edit_the_case_details(approved_sar_ir)
      then_they_expect_the_new_details_to_be_reflected_on_the_case_show_page
    end
  end

  context 'as a responder' do
    it 'won\'t allow me to edit a SAR IR case details' do
      when_a_responder_logs_in
      and_loads_the_case_show_page
      they_cannot_edit_the_case
    end
  end

  private

  def when_a_manager_logs_in
    login_as manager
    cases_page.load
  end

  def when_an_approver_logs_in
    login_as approver
    cases_page.load
{'fraction_non_alphanumeric': 0.0693282978149447, 'fraction_numerical': 0.0010790396547073105, 'mean_word_length': 4.312320916905444, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7319234', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1254, 'n_words': 280}