Commit b612d01f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'boards-sidebar-spec-refactor' into 'master'

Refactor boards sidebar spec

Closes #28310

See merge request !9330
parents a255abe8 8094bcaa
...@@ -15,8 +15,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -15,8 +15,11 @@ describe 'Issue Boards', feature: true, js: true do
let!(:issue2) { create(:labeled_issue, project: project, labels: [development, stretch]) } let!(:issue2) { create(:labeled_issue, project: project, labels: [development, stretch]) }
let(:board) { create(:board, project: project) } let(:board) { create(:board, project: project) }
let!(:list) { create(:list, board: board, label: development, position: 0) } let!(:list) { create(:list, board: board, label: development, position: 0) }
let(:card) { first('.board').first('.card') }
before do before do
Timecop.freeze
project.team << [user, :master] project.team << [user, :master]
login_as(user) login_as(user)
...@@ -25,32 +28,28 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -25,32 +28,28 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
end end
after do
Timecop.return
end
it 'shows sidebar when clicking issue' do it 'shows sidebar when clicking issue' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
expect(page).to have_selector('.issue-boards-sidebar') expect(page).to have_selector('.issue-boards-sidebar')
end end
it 'closes sidebar when clicking issue' do it 'closes sidebar when clicking issue' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
expect(page).to have_selector('.issue-boards-sidebar') expect(page).to have_selector('.issue-boards-sidebar')
page.within(first('.board')) do click_card(card)
first('.card').click
end
expect(page).not_to have_selector('.issue-boards-sidebar') expect(page).not_to have_selector('.issue-boards-sidebar')
end end
it 'closes sidebar when clicking close button' do it 'closes sidebar when clicking close button' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
expect(page).to have_selector('.issue-boards-sidebar') expect(page).to have_selector('.issue-boards-sidebar')
...@@ -60,9 +59,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -60,9 +59,7 @@ describe 'Issue Boards', feature: true, js: true do
end end
it 'shows issue details when sidebar is open' do it 'shows issue details when sidebar is open' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.issue-boards-sidebar') do page.within('.issue-boards-sidebar') do
expect(page).to have_content(issue2.title) expect(page).to have_content(issue2.title)
...@@ -70,15 +67,15 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -70,15 +67,15 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
it 'removes card from board when clicking remove button' do it 'removes card from board when clicking ' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.issue-boards-sidebar') do page.within('.issue-boards-sidebar') do
click_button 'Remove from board' click_button 'Remove from board'
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
end end
...@@ -86,9 +83,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -86,9 +83,7 @@ describe 'Issue Boards', feature: true, js: true do
context 'assignee' do context 'assignee' do
it 'updates the issues assignee' do it 'updates the issues assignee' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.assignee') do page.within('.assignee') do
click_link 'Edit' click_link 'Edit'
...@@ -104,17 +99,12 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -104,17 +99,12 @@ describe 'Issue Boards', feature: true, js: true do
expect(page).to have_content(user.name) expect(page).to have_content(user.name)
end end
page.within(first('.board')) do expect(card).to have_selector('.avatar')
page.within(first('.card')) do
expect(page).to have_selector('.avatar')
end
end
end end
it 'removes the assignee' do it 'removes the assignee' do
page.within(first('.board')) do card_two = first('.board').find('.card:nth-child(2)')
find('.card:nth-child(2)').click click_card(card_two)
end
page.within('.assignee') do page.within('.assignee') do
click_link 'Edit' click_link 'Edit'
...@@ -130,17 +120,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -130,17 +120,11 @@ describe 'Issue Boards', feature: true, js: true do
expect(page).to have_content('No assignee') expect(page).to have_content('No assignee')
end end
page.within(first('.board')) do expect(card_two).not_to have_selector('.avatar')
page.within(find('.card:nth-child(2)')) do
expect(page).not_to have_selector('.avatar')
end
end
end end
it 'assignees to current user' do it 'assignees to current user' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within(find('.assignee')) do page.within(find('.assignee')) do
expect(page).to have_content('No assignee') expect(page).to have_content('No assignee')
...@@ -152,17 +136,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -152,17 +136,11 @@ describe 'Issue Boards', feature: true, js: true do
expect(page).to have_content(user.name) expect(page).to have_content(user.name)
end end
page.within(first('.board')) do expect(card).to have_selector('.avatar')
page.within(first('.card')) do
expect(page).to have_selector('.avatar')
end
end
end end
it 'resets assignee dropdown' do it 'resets assignee dropdown' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.assignee') do page.within('.assignee') do
click_link 'Edit' click_link 'Edit'
...@@ -192,9 +170,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -192,9 +170,7 @@ describe 'Issue Boards', feature: true, js: true do
context 'milestone' do context 'milestone' do
it 'adds a milestone' do it 'adds a milestone' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.milestone') do page.within('.milestone') do
click_link 'Edit' click_link 'Edit'
...@@ -212,9 +188,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -212,9 +188,7 @@ describe 'Issue Boards', feature: true, js: true do
end end
it 'removes a milestone' do it 'removes a milestone' do
page.within(first('.board')) do click_card(card)
find('.card:nth-child(2)').click
end
page.within('.milestone') do page.within('.milestone') do
click_link 'Edit' click_link 'Edit'
...@@ -234,9 +208,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -234,9 +208,7 @@ describe 'Issue Boards', feature: true, js: true do
context 'due date' do context 'due date' do
it 'updates due date' do it 'updates due date' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.due_date') do page.within('.due_date') do
click_link 'Edit' click_link 'Edit'
...@@ -252,9 +224,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -252,9 +224,7 @@ describe 'Issue Boards', feature: true, js: true do
context 'labels' do context 'labels' do
it 'adds a single label' do it 'adds a single label' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.labels') do page.within('.labels') do
click_link 'Edit' click_link 'Edit'
...@@ -273,18 +243,12 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -273,18 +243,12 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
page.within(first('.board')) do expect(card).to have_selector('.label', count: 2)
page.within(first('.card')) do expect(card).to have_content(bug.title)
expect(page).to have_selector('.label', count: 2)
expect(page).to have_content(bug.title)
end
end
end end
it 'adds a multiple labels' do it 'adds a multiple labels' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.labels') do page.within('.labels') do
click_link 'Edit' click_link 'Edit'
...@@ -305,19 +269,13 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -305,19 +269,13 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
page.within(first('.board')) do expect(card).to have_selector('.label', count: 3)
page.within(first('.card')) do expect(card).to have_content(bug.title)
expect(page).to have_selector('.label', count: 3) expect(card).to have_content(regression.title)
expect(page).to have_content(bug.title)
expect(page).to have_content(regression.title)
end
end
end end
it 'removes a label' do it 'removes a label' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.labels') do page.within('.labels') do
click_link 'Edit' click_link 'Edit'
...@@ -336,20 +294,14 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -336,20 +294,14 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
page.within(first('.board')) do expect(card).not_to have_selector('.label')
page.within(first('.card')) do expect(card).not_to have_content(stretch.title)
expect(page).not_to have_selector('.label')
expect(page).not_to have_content(stretch.title)
end
end
end end
end end
context 'subscription' do context 'subscription' do
it 'changes issue subscription' do it 'changes issue subscription' do
page.within(first('.board')) do click_card(card)
first('.card').click
end
page.within('.subscription') do page.within('.subscription') do
click_button 'Subscribe' click_button 'Subscribe'
...@@ -358,4 +310,19 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -358,4 +310,19 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
end end
def click_card(card)
page.within(card) do
first('.card-number').click
end
wait_for_sidebar
end
def wait_for_sidebar
# loop until the CSS transition is complete
Timeout.timeout(0.5) do
loop until evaluate_script('$(".right-sidebar").outerWidth()') == 290
end
end
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