<commit_before># Specifications for behavior common to all objects with executable attributes.
# It takes a `issuable_type`, and expect an `issuable`.

shared_examples 'issuable record that supports quick actions in its description and notes' do |issuable_type|
  include QuickActionsHelpers

  let(:master) { create(:user) }
  let(:project) do
    case issuable_type
    when :merge_request
      create(:project, :public, :repository)
    when :issue
      create(:project, :public)
    end
  end
  let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
  let!(:label_bug) { create(:label, project: project, title: 'bug') }
  let!(:label_feature) { create(:label, project: project, title: 'feature') }
  let(:new_url_opts) { {} }

  before do
    project.team << [master, :master]

    gitlab_sign_in(master)
  end

  after do
    # Ensure all outstanding Ajax requests are complete to avoid database deadlocks
    wait_for_requests
  end

  describe "new #{issuable_type}", :js do
    context 'with commands in the description' do
      it "creates the #{issuable_type} and interpret commands accordingly" do
        case issuable_type
        when :merge_request
          visit public_send("namespace_project_new_merge_request_path", project.namespace, project, new_url_opts)
        when :issue
          visit public_send("new_namespace_project_issue_path", project.namespace, project, new_url_opts)
        end
        fill_in "#{issuable_type}_title", with: 'bug 345'
        fill_in "#{issuable_type}_description", with: "bug description\n/label ~bug\n/milestone %\"ASAP\""
        click_button "Submit #{issuable_type}".humanize

        issuable = project.public_send(issuable_type.to_s.pluralize).first

        expect(issuable.description).to eq "bug description"
        expect(issuable.labels).to eq [label_bug]
        expect(issuable.milestone).to eq milestone
        expect(page).to have_content 'bug 345'
        expect(page).to have_content 'bug description'
      end
    end
  end

  describe "note on #{issuable_type}", :js do
    before do
      visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
    end

    context 'with a note containing commands' do
      it 'creates a note without the commands and interpret the commands accordingly' do
        assignee = create(:user, username: 'bob')
        write_note("Awesome!\n/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")

        expect(page).to have_content 'Awesome!'
        expect(page).not_to have_content '/assign @bob'
        expect(page).not_to have_content '/label ~bug'
        expect(page).not_to have_content '/milestone %"ASAP"'

        wait_for_requests
        issuable.reload
        note = issuable.notes.user.first

        expect(note.note).to eq "Awesome!"
        expect(issuable.assignees).to eq [assignee]
        expect(issuable.labels).to eq [label_bug]
        expect(issuable.milestone).to eq milestone
      end
    end

    context 'with a note containing only commands' do
      it 'does not create a note but interpret the commands accordingly' do
        assignee = create(:user, username: 'bob')
        write_note("/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")

        expect(page).not_to have_content '/assign @bob'
        expect(page).not_to have_content '/label ~bug'
        expect(page).not_to have_content '/milestone %"ASAP"'
        expect(page).to have_content 'Commands applied'

        issuable.reload

        expect(issuable.notes.user).to be_empty
        expect(issuable.assignees).to eq [assignee]
        expect(issuable.labels).to eq [label_bug]
        expect(issuable.milestone).to eq milestone
      end
    end
<commit_msg>fix flaky fill_in use in which return key would occasionally be intercepted by autocomplete<commit_after># Specifications for behavior common to all objects with executable attributes.
# It takes a `issuable_type`, and expect an `issuable`.

shared_examples 'issuable record that supports quick actions in its description and notes' do |issuable_type|
  include QuickActionsHelpers

  let(:master) { create(:user) }
  let(:project) do
    case issuable_type
    when :merge_request
      create(:project, :public, :repository)
    when :issue
      create(:project, :public)
    end
  end
  let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
  let!(:label_bug) { create(:label, project: project, title: 'bug') }
  let!(:label_feature) { create(:label, project: project, title: 'feature') }
  let(:new_url_opts) { {} }

  before do
    project.team << [master, :master]

    gitlab_sign_in(master)
  end

  after do
    # Ensure all outstanding Ajax requests are complete to avoid database deadlocks
    wait_for_requests
  end

  describe "new #{issuable_type}", :js do
    context 'with commands in the description' do
      it "creates the #{issuable_type} and interpret commands accordingly" do
        case issuable_type
        when :merge_request
          visit public_send("namespace_project_new_merge_request_path", project.namespace, project, new_url_opts)
        when :issue
          visit public_send("new_namespace_project_issue_path", project.namespace, project, new_url_opts)
        end
        fill_in "#{issuable_type}_title", with: 'bug 345'
        fill_in "#{issuable_type}_description", with: "bug description\n/label ~bug\n/milestone %\"ASAP\""
        click_button "Submit #{issuable_type}".humanize

        issuable = project.public_send(issuable_type.to_s.pluralize).first

        expect(issuable.description).to eq "bug description"
        expect(issuable.labels).to eq [label_bug]
        expect(issuable.milestone).to eq milestone
        expect(page).to have_content 'bug 345'
        expect(page).to have_content 'bug description'
      end
    end
  end

  describe "note on #{issuable_type}", :js do
    before do
      visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
    end

    context 'with a note containing commands' do
      it 'creates a note without the commands and interpret the commands accordingly' do
        assignee = create(:user, username: 'bob')
        write_note("Awesome!\n\n/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")

        expect(page).to have_content 'Awesome!'
        expect(page).not_to have_content '/assign @bob'
        expect(page).not_to have_content '/label ~bug'
        expect(page).not_to have_content '/milestone %"ASAP"'

        wait_for_requests
        issuable.reload
        note = issuable.notes.user.first

        expect(note.note).to eq "Awesome!"
        expect(issuable.assignees).to eq [assignee]
        expect(issuable.labels).to eq [label_bug]
        expect(issuable.milestone).to eq milestone
      end
    end

    context 'with a note containing only commands' do
      it 'does not create a note but interpret the commands accordingly' do
        assignee = create(:user, username: 'bob')
        write_note("/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")

        expect(page).not_to have_content '/assign @bob'
        expect(page).not_to have_content '/label ~bug'
        expect(page).not_to have_content '/milestone %"ASAP"'
        expect(page).to have_content 'Commands applied'

        issuable.reload

        expect(issuable.notes.user).to be_empty
        expect(issuable.assignees).to eq [assignee]
        expect(issuable.labels).to eq [label_bug]
        expect(issuable.milestone).to eq milestone
      end
    end

{'fraction_non_alphanumeric': 0.10259465184008472, 'fraction_numerical': 0.0015885623510722795, 'mean_word_length': 3.2611393119007333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5935778', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2187, 'n_words': 617}