debian-mirror-gitlab/spec/features/jira_connect/branches_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.5 KiB
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Create GitLab branches from Jira', :js, feature_category: :integrations do
2023-03-17 16:20:25 +05:30
include ListboxHelpers
2021-10-27 15:23:28 +05:30
let_it_be(:alice) { create(:user, name: 'Alice') }
let_it_be(:bob) { create(:user, name: 'Bob') }
let_it_be(:project1) { create(:project, :repository, namespace: alice.namespace, title: 'foo') }
let_it_be(:project2) { create(:project, :repository, namespace: alice.namespace, title: 'bar') }
let_it_be(:project3) { create(:project, namespace: bob.namespace) }
let(:source_branch) { 'my-source-branch' }
let(:new_branch) { 'my-new-branch' }
before do
project2.repository.add_branch(alice, source_branch, 'master')
sign_in(alice)
end
def within_dropdown(&block)
within('.dropdown-menu', &block)
end
it 'select project and branch and submit the form' do
visit new_jira_connect_branch_path(issue_key: 'ACME-123', issue_summary: 'My issue !@#$% title')
expect(page).to have_button('Create branch', disabled: true)
2022-04-04 11:22:00 +05:30
# initially, branch field should be hidden.
expect(page).not_to have_field('Branch name')
2021-10-27 15:23:28 +05:30
# Select project1
click_on 'Select a project'
within_dropdown do
expect(page).to have_text('Alice / foo')
expect(page).to have_text('Alice / bar')
expect(page).not_to have_text('Bob /')
fill_in 'Search', with: 'foo'
expect(page).not_to have_text('Alice / bar')
2023-03-17 16:20:25 +05:30
find('span', text: 'Alice / foo', match: :first).click
2021-10-27 15:23:28 +05:30
end
2022-04-04 11:22:00 +05:30
expect(page).to have_field('Branch name', with: 'ACME-123-my-issue-title')
2021-10-27 15:23:28 +05:30
expect(page).to have_button('Create branch', disabled: false)
click_on 'master'
2023-03-04 22:38:38 +05:30
fill_in 'Search', with: source_branch
expect(page).not_to have_text(source_branch)
2021-10-27 15:23:28 +05:30
2023-03-04 22:38:38 +05:30
fill_in 'Search', with: 'master'
expect(page).to have_text('master')
2021-10-27 15:23:28 +05:30
# Switch to project2
2023-03-17 16:20:25 +05:30
find('span', text: 'Alice / foo', match: :first).click
2021-10-27 15:23:28 +05:30
within_dropdown do
fill_in 'Search', with: ''
2023-03-17 16:20:25 +05:30
find('span', text: 'Alice / bar', match: :first).click
2021-10-27 15:23:28 +05:30
end
click_on 'master'
2023-03-04 22:38:38 +05:30
wait_for_requests
2021-10-27 15:23:28 +05:30
2023-03-04 22:38:38 +05:30
fill_in 'Search', with: source_branch
wait_for_requests
2023-03-17 16:20:25 +05:30
select_listbox_item(source_branch)
2021-10-27 15:23:28 +05:30
fill_in 'Branch name', with: new_branch
click_on 'Create branch'
expect(page).to have_text('New branch was successfully created. You can now close this window and return to Jira.')
expect(project1.commit(new_branch)).to be_nil
expect(project2.commit(new_branch)).not_to be_nil
expect(project2.commit(new_branch)).to eq(project2.commit(source_branch))
end
end