Commit 36168062 authored by Coung Ngo's avatar Coung Ngo Committed by Robert Speicher

Improve feature specs

parent 983e4443
......@@ -49,7 +49,7 @@ RSpec.describe 'Dashboard Issues' do
describe 'new issue dropdown' do
it 'shows projects only with issues feature enabled', :js do
find('.new-project-item-select-button').click
click_button 'Toggle project select'
page.within('.select2-results') do
expect(page).to have_content(project.full_name)
......@@ -58,7 +58,7 @@ RSpec.describe 'Dashboard Issues' do
end
it 'shows the new issue page', :js do
find('.new-project-item-select-button').click
click_button 'Toggle project select'
wait_for_requests
......
......@@ -34,7 +34,7 @@ RSpec.describe 'Dashboard Merge Requests' do
end
it 'shows projects only with merge requests feature enabled', :js do
find('.new-project-item-select-button').click
click_button 'Toggle project select'
page.within('.select2-results') do
expect(page).to have_content(project.full_name)
......
......@@ -35,7 +35,7 @@ RSpec.describe 'Dashboard > Milestones' do
describe 'new milestones dropdown', :js do
it 'takes user to a new milestone page', :js do
find('.new-project-item-select-button').click
click_button 'Toggle project select'
page.within('.select2-results') do
first('.select2-result-label').click
......
......@@ -101,7 +101,7 @@ RSpec.describe 'Group empty states' do
it "the new #{issuable_name} button opens a project dropdown" do
within '.empty-state' do
find('.new-project-item-select-button').click
click_button 'Toggle project select'
end
expect(page).to have_selector('.ajax-project-dropdown')
......
......@@ -119,8 +119,9 @@ RSpec.describe 'Group issues page' do
end
it 'shows projects only with issues feature enabled', :js do
find('.empty-state .js-lazy-loaded')
find('.empty-state .new-project-item-link').click
within '.empty-state' do
click_button 'Toggle project select'
end
page.within('.select2-results') do
expect(page).to have_content(project.full_name)
......@@ -158,9 +159,7 @@ RSpec.describe 'Group issues page' do
it 'each issue item has a user-can-drag css applied' do
visit issues_group_path(group, sort: 'relative_position')
page.within('.manual-ordering') do
expect(page).to have_selector('.issue.user-can-drag', count: 3)
end
expect(page).to have_selector('.issue.user-can-drag', count: 3)
end
it 'issues should be draggable and persist order' do
......@@ -224,7 +223,8 @@ RSpec.describe 'Group issues page' do
end
it 'shows the pagination' do
expect(page).to have_selector('.gl-pagination')
expect(page).to have_link 'Prev'
expect(page).to have_link 'Next'
end
it 'first pagination item is active' do
......
......@@ -197,17 +197,13 @@ RSpec.describe 'Sort Issuable List' do
click_button('Created date')
click_on('Last updated')
wait_for_requests
expect(first_issue).to include(last_updated_issuable.title)
expect(last_issue).to include(first_updated_issuable.title)
expect(page).to have_css('.issue:first-child', text: last_updated_issuable.title)
expect(page).to have_css('.issue:last-child', text: first_updated_issuable.title)
click_on 'Sort direction'
wait_for_requests
expect(first_issue).to include(first_updated_issuable.title)
expect(last_issue).to include(last_updated_issuable.title)
expect(page).to have_css('.issue:first-child', text: first_updated_issuable.title)
expect(page).to have_css('.issue:last-child', text: last_updated_issuable.title)
end
end
end
......
......@@ -12,6 +12,9 @@ RSpec.describe 'Issues > Labels bulk assignment' do
let!(:issue1) { create(:issue, project: project, title: "Issue 1", labels: [frontend]) }
let!(:issue2) { create(:issue, project: project, title: "Issue 2") }
let(:issue_1_selector) { "#issue_#{issue1.id}" }
let(:issue_2_selector) { "#issue_#{issue2.id}" }
context 'as an allowed user', :js do
before do
project.add_maintainer(user)
......@@ -44,10 +47,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'frontend'
expect(find("#issue_#{issue2.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).not_to have_content 'frontend'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'frontend'
expect(find(issue_2_selector)).to have_content 'bug'
expect(find(issue_2_selector)).not_to have_content 'frontend'
end
end
......@@ -60,10 +63,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'frontend'
expect(find("#issue_#{issue2.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).not_to have_content 'frontend'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'frontend'
expect(find(issue_2_selector)).to have_content 'bug'
expect(find(issue_2_selector)).not_to have_content 'frontend'
end
end
......@@ -75,10 +78,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'frontend'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).not_to have_content 'frontend'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'frontend'
expect(find(issue_2_selector)).not_to have_content 'bug'
expect(find(issue_2_selector)).not_to have_content 'frontend'
end
end
......@@ -90,10 +93,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'frontend'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).not_to have_content 'frontend'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'frontend'
expect(find(issue_2_selector)).not_to have_content 'bug'
expect(find(issue_2_selector)).not_to have_content 'frontend'
end
end
end
......@@ -107,10 +110,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'feature'
expect(find(issue_2_selector)).to have_content 'bug'
expect(find(issue_2_selector)).to have_content 'feature'
end
end
......@@ -122,10 +125,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'feature'
expect(find(issue_2_selector)).not_to have_content 'bug'
expect(find(issue_2_selector)).not_to have_content 'feature'
end
end
end
......@@ -144,8 +147,8 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_2_selector)).to have_content 'bug'
end
end
......@@ -164,10 +167,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue1.id}")).not_to have_content 'feature'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
expect(find(issue_1_selector)).not_to have_content 'bug'
expect(find(issue_1_selector)).not_to have_content 'feature'
expect(find(issue_2_selector)).not_to have_content 'bug'
expect(find(issue_2_selector)).not_to have_content 'feature'
end
end
......@@ -183,8 +186,8 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find(issue_1_selector)).not_to have_content 'bug'
expect(find(issue_2_selector)).to have_content 'feature'
end
end
......@@ -203,10 +206,10 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find(issue_1_selector)).not_to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'feature'
expect(find(issue_2_selector)).not_to have_content 'bug'
expect(find(issue_2_selector)).to have_content 'feature'
end
end
end
......@@ -222,18 +225,18 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it 'keeps labels' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_2_selector)).to have_content 'feature'
check 'Select all'
open_milestone_dropdown(['First Release'])
update_issues
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'First Release'
expect(find(issue_2_selector)).to have_content 'feature'
expect(find(issue_2_selector)).to have_content 'First Release'
end
end
......@@ -244,18 +247,18 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it 'keeps existing label and new label is present' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'bug'
check 'Select all'
open_milestone_dropdown ['First Release']
open_labels_dropdown ['feature']
update_issues
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'First Release'
expect(find(issue_2_selector)).to have_content 'feature'
expect(find(issue_2_selector)).to have_content 'First Release'
end
end
......@@ -269,9 +272,9 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it 'keeps existing label and new label is present' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_2_selector)).to have_content 'feature'
check 'Select all'
......@@ -279,11 +282,11 @@ RSpec.describe 'Issues > Labels bulk assignment' do
unmark_labels_in_dropdown ['feature']
update_issues
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).not_to have_content 'feature'
expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).not_to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'First Release'
expect(find(issue_2_selector)).not_to have_content 'feature'
expect(find(issue_2_selector)).to have_content 'First Release'
end
end
......@@ -300,19 +303,19 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it 'keeps labels' do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'First Release'
expect(find(issue_2_selector)).to have_content 'feature'
expect(find(issue_2_selector)).to have_content 'First Release'
check 'Select all'
open_milestone_dropdown(['No milestone'])
update_issues
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).not_to have_content 'First Release'
expect(find("#issue_#{issue2.id}")).to have_content 'feature'
expect(find("#issue_#{issue2.id}")).not_to have_content 'First Release'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).not_to have_content 'First Release'
expect(find(issue_2_selector)).to have_content 'feature'
expect(find(issue_2_selector)).not_to have_content 'First Release'
end
end
end
......@@ -324,7 +327,7 @@ RSpec.describe 'Issues > Labels bulk assignment' do
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'bug'
check_issue issue1
open_labels_dropdown ['feature']
......@@ -333,8 +336,8 @@ RSpec.describe 'Issues > Labels bulk assignment' do
update_issues
sleep 1 # needed
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'bug'
expect(find(issue_1_selector)).to have_content 'feature'
end
end
......@@ -350,7 +353,7 @@ RSpec.describe 'Issues > Labels bulk assignment' do
update_issues
expect(find("#issue_#{issue1.id}")).to have_content 'feature'
expect(find(issue_1_selector)).to have_content 'feature'
end
end
......@@ -381,12 +384,12 @@ RSpec.describe 'Issues > Labels bulk assignment' do
update_issues
first_issue = find("#issue_#{issue1.id}")
first_issue = find(issue_1_selector)
expect(first_issue).not_to have_content 'bug'
expect(first_issue).to have_content 'feature'
expect(first_issue).to have_content 'wontfix'
second_issue = find("#issue_#{issue2.id}")
second_issue = find(issue_2_selector)
expect(second_issue).not_to have_content 'bug'
expect(second_issue).not_to have_content 'feature'
expect(second_issue).to have_content 'wontfix'
......
......@@ -64,7 +64,7 @@ RSpec.describe 'Labels Hierarchy', :js do
end
else
expect_issues_list_count(1)
expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
expect(page).to have_selector('.issue-title', text: labeled_issue.title)
end
end
end
......@@ -74,7 +74,7 @@ RSpec.describe 'Labels Hierarchy', :js do
wait_for_requests
expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
expect(page).not_to have_link child_group_label.title
end
end
......@@ -107,9 +107,9 @@ RSpec.describe 'Labels Hierarchy', :js do
end
else
expect_issues_list_count(3)
expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
expect(page).to have_selector('span.issue-title-text', text: labeled_issue_2.title)
expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
expect(page).to have_selector('.issue-title', text: labeled_issue.title)
expect(page).to have_selector('.issue-title', text: labeled_issue_2.title)
expect(page).to have_selector('.issue-title', text: labeled_issue_3.title)
end
end
end
......@@ -129,7 +129,7 @@ RSpec.describe 'Labels Hierarchy', :js do
end
else
expect_issues_list_count(1)
expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
expect(page).to have_selector('.issue-title', text: labeled_issue_3.title)
end
end
......@@ -231,7 +231,7 @@ RSpec.describe 'Labels Hierarchy', :js do
wait_for_requests
expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
expect(page).not_to have_link child_group_label.title
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