Commit aeb79bc7 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'improve-form-spec-ee' into 'master'

Improve form spec (EE)

See merge request !2067
parents 65c3b156 05566379
require 'rails_helper'
describe 'New/edit issue (EE)', :feature, :js do
include GitlabRoutingHelper
include ActionView::Helpers::JavaScriptHelper
include FormHelper
let!(:project) { create(:project) }
let!(:user) { create(:user)}
let!(:user2) { create(:user)}
let!(:milestone) { create(:milestone, project: project) }
let!(:label) { create(:label, project: project) }
let!(:label2) { create(:label, project: project) }
let!(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) }
before do
project.team << [user, :master]
project.team << [user2, :master]
login_as(user)
end
context 'new issue' do
before do
visit new_namespace_project_issue_path(project.namespace, project)
end
describe 'shorten users API pagination limit (CE)' do
before do
# Using `allow_any_instance_of`/`and_wrap_original`, `original` would
# somehow refer to the very block we defined to _wrap_ that method, instead of
# the original method, resulting in infinite recurison when called.
# This is likely a bug with helper modules included into dynamically generated view classes.
# To work around this, we have to hold on to and call to the original implementation manually.
original_issue_dropdown_options = FormHelper.instance_method(:issue_dropdown_options)
allow_any_instance_of(FormHelper).to receive(:issue_dropdown_options).and_wrap_original do |original, *args|
options = original_issue_dropdown_options.bind(original.receiver).call(*args)
options[:data][:per_page] = 2
options
end
visit new_namespace_project_issue_path(project.namespace, project)
click_button 'Unassigned'
wait_for_requests
end
it 'should display selected users even if they are not part of the original API call' do
find('.dropdown-input-field').native.send_keys user2.name
page.within '.dropdown-menu-user' do
expect(page).to have_content user2.name
click_link user2.name
end
find('.js-dropdown-input-clear').click
page.within '.dropdown-menu-user' do
expect(page).to have_content user.name
expect(find('.dropdown-menu-user a.is-active').first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
end
end
end
describe 'multiple assignees' do
before do
click_button 'Unassigned'
wait_for_requests
end
it 'unselects other assignees when unassigned is selected' do
page.within '.dropdown-menu-user' do
click_link user2.name
end
page.within '.dropdown-menu-user' do
click_link 'Unassigned'
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match('0')
end
it 'toggles assign to me when current user is selected and unselected' do
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
page.within('.dropdown-menu-user') do
click_link user.name
end
expect(find('a', text: 'Assign to me')).to be_visible
end
end
end
end
......@@ -24,7 +24,7 @@ describe 'New/edit issue', :feature, :js do
visit new_namespace_project_issue_path(project.namespace, project)
end
describe 'single assignee' do
xdescribe 'shorten users API pagination limit (CE)' do
before do
# Using `allow_any_instance_of`/`and_wrap_original`, `original` would
# somehow refer to the very block we defined to _wrap_ that method, instead of
......@@ -54,6 +54,7 @@ describe 'New/edit issue', :feature, :js do
click_link user2.name
end
find('.js-assignee-search').click
find('.js-dropdown-input-clear').click
page.within '.dropdown-menu-user' do
......@@ -63,7 +64,7 @@ describe 'New/edit issue', :feature, :js do
end
end
describe 'multiple assignees' do
xdescribe 'single assignee (CE)' do
before do
click_button 'Unassigned'
......@@ -75,6 +76,8 @@ describe 'New/edit issue', :feature, :js do
click_link user2.name
end
click_button user2.name
page.within '.dropdown-menu-user' do
click_link 'Unassigned'
end
......@@ -89,11 +92,13 @@ describe 'New/edit issue', :feature, :js do
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
click_button user.name
page.within('.dropdown-menu-user') do
click_link user.name
end
expect(find('a', text: 'Assign to me')).to be_visible
expect(page.find('.dropdown-menu-user', visible: false)).not_to be_visible
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment