<commit_before>require 'feature_helper'

feature 'Creating an "I Will Write" question', js: true, suspend_cleaner: true do
  include Features::PqHelpers

  before(:all) do
    clear_sent_mail
    DBHelpers.load_feature_fixtures

    @uin      = PQA::QuestionLoader.new.load_and_import(1).first.uin
    @iww_uin  = "#{@uin}-IWW"
    @ao       = ActionOfficer.find_by(email: '<EMAIL>')
    @minister = Minister.first

    set_seen_by_finance
  end

  before(:each) do
    create_pq_session
  end

  after(:all) do
    DatabaseCleaner.clean
  end

  scenario "Parli-branch marks a question as 'I will write'" do
    commission_question(@uin, [@ao], @minister)
    accept_assignnment(@ao)
    in_pq_detail(@uin, 'PQ draft') { check 'I will write' }
    expect(page).to have_text('I will write')
  end

  scenario "Parli-branch creates an IWW follow-up question" do
    visit pq_path(@uin)
    click_on "Answer"
    click_on "Create 'I will write' follow up"

    expect_pq_in_progress_status(@iww_uin, 'Draft Pending')

    visit pq_path(@iww_uin)
    click_on "Answer"
    expect(page).not_to have_text("Create 'I will write' follow up")
    click_on "PQ commission"
    expect(page).to have_text(@ao.email)
  end

  scenario "Parli-branch clicks on the 'create IWW follow up button' for a second time" do
    visit pq_path(@uin)
    click_on "Answer"
    click_on "Create 'I will write' follow up"
    expect(page).to have_content(@iww_uin)
    expect(Pq.where(uin: @iww_uin).count).to eq(1)
  end
end<commit_msg>Ensure that the original PQ disappears from the dashboard<commit_after>require 'feature_helper'

feature 'Creating an "I Will Write" question', js: true, suspend_cleaner: true do
  include Features::PqHelpers

  before(:all) do
    clear_sent_mail
    DBHelpers.load_feature_fixtures

    @uin      = PQA::QuestionLoader.new.load_and_import(1).first.uin
    @iww_uin  = "#{@uin}-IWW"
    @ao       = ActionOfficer.find_by(email: '<EMAIL>')
    @minister = Minister.first

    set_seen_by_finance
  end

  before(:each) do
    create_pq_session
  end

  after(:all) do
    DatabaseCleaner.clean
  end

  scenario "Parli-branch marks a question as 'I will write'" do
    commission_question(@uin, [@ao], @minister)
    accept_assignnment(@ao)
    in_pq_detail(@uin, 'PQ draft') { check 'I will write' }
    expect(page).to have_text('I will write')
  end

  scenario "Parli-branch creates an IWW follow-up question" do
    visit pq_path(@uin)
    click_on "Answer"
    click_on "Create 'I will write' follow up"

    visit dashboard_path
    expect(page).not_to have_text(@uin)

    expect_pq_in_progress_status(@iww_uin, 'Draft Pending')

    visit pq_path(@iww_uin)
    click_on "Answer"
    expect(page).not_to have_text("Create 'I will write' follow up")
    click_on "PQ commission"
    expect(page).to have_text(@ao.email)
  end

  scenario "Parli-branch clicks on the 'create IWW follow up button' for a second time" do
    visit pq_path(@uin)
    click_on "Answer"
    click_on "Create 'I will write' follow up"
    expect(page).to have_content(@iww_uin)
    expect(Pq.where(uin: @iww_uin).count).to eq(1)
  end
end
{'fraction_non_alphanumeric': 0.10727969348659004, 'fraction_numerical': 0.001277139208173691, 'mean_word_length': 3.7254901960784315, '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': '116987', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1084, 'n_words': 285}