<commit_before>require "rails_helper"

RSpec.feature "Custody Suite Officers changing interview time for a defence request" do
  # TODO: check new interview time it rendered when the below story is done:
  # https://trello.com/c/RtWUhXVc/8-3-as-a-cso-i-d-like-to-add-the-interview-time-so-that-the-solicitor-knows-when-the-interview-starts

  specify "can change interview time to an arbitrary date" do
    login_create_and_submit_defence_request

    # navigate to the defence request details page
    find(".cso-defence-requests tbody tr:first-child td.actions a").click

    within "div#interview" do
      fill_in "Hour", with: "14"
      fill_in "Min", with: "05"
      fill_in "defence_request_interview_start_time_date", with: "4 June 2015"
    end

    click_button "Save interview time"

    expect(page).to have_content("Interview start time updated")
  end

  def login_create_and_submit_defence_request
    login_as_cso

    click_link "New request"
    fill_in_defence_request_form
    click_button "Create request"
    click_button "Submit request"
  end
end<commit_msg>Create feature test for interview time scenarios<commit_after>require "rails_helper"

RSpec.feature "Custody Suite Officers changing interview time for a defence request" do
  context "with javascript enabled", js: true do
    specify "can set new interview time to an arbitrary date" do
      create_and_display_defence_request

      within "div#interview" do
        fill_in "Hour", with: "14"
        fill_in "Min", with: "05"
        fill_in "defence_request_interview_start_time_date", with: "4 June 2015"
      end

      click_button "Save interview time"

      expect(page).to have_content("Interview at 14:05 4 June 2015")
    end

    specify "can change interview time to an arbitrary date" do
      create_and_display_defence_request(true)

      within "div#interview" do
        click_link "Change this"

        fill_in "Hour", with: "16"
        fill_in "Min", with: "05"
        fill_in "defence_request_interview_start_time_date", with: "5 June 2015"
      end

      click_button "Save interview time"

      expect(page).to have_content("Interview at 16:05 5 June 2015")
    end
  end

  context "with javascript disabled" do
    specify "can set new interview time to an arbitrary date" do
      create_and_display_defence_request

      within "div#interview" do
        fill_in "Hour", with: "14"
        fill_in "Min", with: "05"
        fill_in "defence_request_interview_start_time_date", with: "4 June 2015"
      end

      click_button "Save interview time"

      expect(page).to have_content("Interview at 14:05 4 June 2015")
    end

    specify "can change interview time to an arbitrary date" do
      create_and_display_defence_request(true)

      within "div#interview" do
        click_link "Change this"
      end

      fill_in "Hour", with: "16"
      fill_in "Min", with: "05"
      fill_in "defence_request_interview_start_time_date", with: "5 June 2015"

      click_button "Save interview time"

      expect(page).to have_content("Interview at 16:05 5 June 2015")
    end
  end

  def create_and_display_defence_request(interview_time_set = false)
    traits = [ :acknowledged ]
    traits << :interview_start_time if interview_time_set
    dr = create :defence_request, *traits

    login_as_cso

    visit "/defence_requests/#{dr.id}"
  end
end
{'fraction_non_alphanumeric': 0.07874481941977501, 'fraction_numerical': 0.02457075192421551, 'mean_word_length': 3.411227154046997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '2396077', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1044, 'n_words': 317}