<commit_before>class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedIssuable
  include SharedProject
  include SharedNote
  include SharedPaths
  include SharedMarkdown
  include SharedDiffNote
  include SharedUser

  step 'I click link "New Merge Request"' do
    click_link "New Merge Request"
  end

  step 'I click link "Bug NS-04"' do
    click_link "Bug NS-04"
  end

  step 'I click link "Feature NS-05"' do
    click_link "Feature NS-05"
  end

  step 'I click link "All"' do
    click_link "All"
    # Waits for load
    expect(find('.issues-state-filters > .active')).to have_content 'All'
  end

  step 'I click link "Merged"' do
    click_link "Merged"
  end

  step 'I click link "Closed"' do
    page.within('.issues-state-filters') do
      click_link "Closed"
    end
  end

  step 'I should see merge request "Wiki Feature"' do
    page.within '.merge-request' do
      expect(page).to have_content "Wiki Feature"
    end
  end

  step 'I should see closed merge request "Bug NS-04"' do
    merge_request = MergeRequest.find_by!(title: "Bug NS-04")
    expect(merge_request).to be_closed
    expect(page).to have_content "Closed by"
  end

  step 'I should see merge request "Bug NS-04"' do
    expect(page).to have_content "Bug NS-04"
  end

  step 'I should see merge request "Feature NS-05"' do
    expect(page).to have_content "Feature NS-05"
  end

  step 'I should not see "master" branch' do
    expect(find('.merge-request-info')).not_to have_content "master"
  end

  step 'I should see "feature_conflict" branch' do
    expect(page).to have_content "feature_conflict"
  end

  step 'I should see "Bug NS-04" in merge requests' do
    expect(page).to have_content "Bug NS-04"
  end

  step 'I should see "Feature NS-03" in merge requests' do
    expect(page).to have_content "Feature NS-03"
  end

  step 'I should not see "Feature NS-03" in merge requests' do
    expect(page).not_to have_content "Feature NS-03"
  end

  step 'I should not see "Bug NS-04" in merge requests' do
    expect(page).not_to have_content "Bug NS-04"
  end

  step 'I should see that I am subscribed' do
    expect(find('.issuable-subscribe-button span')).to have_content 'Unsubscribe'
  end

  step 'I should see that I am unsubscribed' do
    expect(find('.issuable-subscribe-button span')).to have_content 'Subscribe'
  end

  step 'I click button "Unsubscribe"' do
    click_on "Unsubscribe"
  end

  step 'I click link "Close"' do
    first(:css, '.close-mr-link').click
  end

  step 'I submit new merge request "Wiki Feature"' do
    find('.js-source-branch').click
    find('.dropdown-source-branch .dropdown-content a', text: 'fix').click

    find('.js-target-branch').click
    first('.dropdown-target-branch .dropdown-content a', text: 'feature').click

    click_button "Compare branches"
    fill_in "merge_request_title", with: "Wiki Feature"
    click_button "Submit merge request"
  end

  step 'project "Shop" have "Bug NS-04" open merge request' do
    create(:merge_request,
           title: "Bug NS-04",
           source_project: project,
           target_project: project,
           source_branch: 'fix',
           target_branch: 'merge-test',
           author: project.users.first,<commit_msg>Wait for ajax call in merge request unsubscribe test<commit_after>class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedIssuable
  include SharedProject
  include SharedNote
  include SharedPaths
  include SharedMarkdown
  include SharedDiffNote
  include SharedUser
  include WaitForAjax

  step 'I click link "New Merge Request"' do
    click_link "New Merge Request"
  end

  step 'I click link "Bug NS-04"' do
    click_link "Bug NS-04"
  end

  step 'I click link "Feature NS-05"' do
    click_link "Feature NS-05"
  end

  step 'I click link "All"' do
    click_link "All"
    # Waits for load
    expect(find('.issues-state-filters > .active')).to have_content 'All'
  end

  step 'I click link "Merged"' do
    click_link "Merged"
  end

  step 'I click link "Closed"' do
    page.within('.issues-state-filters') do
      click_link "Closed"
    end
  end

  step 'I should see merge request "Wiki Feature"' do
    page.within '.merge-request' do
      expect(page).to have_content "Wiki Feature"
    end
  end

  step 'I should see closed merge request "Bug NS-04"' do
    merge_request = MergeRequest.find_by!(title: "Bug NS-04")
    expect(merge_request).to be_closed
    expect(page).to have_content "Closed by"
  end

  step 'I should see merge request "Bug NS-04"' do
    expect(page).to have_content "Bug NS-04"
  end

  step 'I should see merge request "Feature NS-05"' do
    expect(page).to have_content "Feature NS-05"
  end

  step 'I should not see "master" branch' do
    expect(find('.merge-request-info')).not_to have_content "master"
  end

  step 'I should see "feature_conflict" branch' do
    expect(page).to have_content "feature_conflict"
  end

  step 'I should see "Bug NS-04" in merge requests' do
    expect(page).to have_content "Bug NS-04"
  end

  step 'I should see "Feature NS-03" in merge requests' do
    expect(page).to have_content "Feature NS-03"
  end

  step 'I should not see "Feature NS-03" in merge requests' do
    expect(page).not_to have_content "Feature NS-03"
  end

  step 'I should not see "Bug NS-04" in merge requests' do
    expect(page).not_to have_content "Bug NS-04"
  end

  step 'I should see that I am subscribed' do
    expect(find('.issuable-subscribe-button span')).to have_content 'Unsubscribe'
  end

  step 'I should see that I am unsubscribed' do
    expect(find('.issuable-subscribe-button span')).to have_content 'Subscribe'
  end

  step 'I click button "Unsubscribe"' do
    click_on "Unsubscribe"
    wait_for_ajax
  end

  step 'I click link "Close"' do
    first(:css, '.close-mr-link').click
  end

  step 'I submit new merge request "Wiki Feature"' do
    find('.js-source-branch').click
    find('.dropdown-source-branch .dropdown-content a', text: 'fix').click

    find('.js-target-branch').click
    first('.dropdown-target-branch .dropdown-content a', text: 'feature').click

    click_button "Compare branches"
    fill_in "merge_request_title", with: "Wiki Feature"
    click_button "Submit merge request"
  end

  step 'project "Shop" have "Bug NS-04" open merge request' do
    create(:merge_request,
           title: "Bug NS-04",
           source_project: project,
           target_project: project,
           source_branch: 'fix',
           target_branch: 'merge-test',
           author: project.users.first,
{'fraction_non_alphanumeric': 0.10151674425589428, 'fraction_numerical': 0.012013815888271513, 'mean_word_length': 3.263764404609475, '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': '4139399', 'n_tokens_mistral': 2215, 'n_tokens_neox': 2063, 'n_words': 704}