Commit a300808e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix flaky spec when filtering boards with swimlane

We assert that the issue lists are loaded and visible because we cannot
rely on wait_for_all_requests. We may be calling wait_for_all_requests
before the GraphQL request is started.
parent a47d17f6
...@@ -29,12 +29,18 @@ RSpec.describe 'epics swimlanes filtering', :js do ...@@ -29,12 +29,18 @@ RSpec.describe 'epics swimlanes filtering', :js do
let_it_be(:issue7) { create(:labeled_issue, project: project, title: 'ggg', description: '777', labels: [development], relative_position: 2) } let_it_be(:issue7) { create(:labeled_issue, project: project, title: 'ggg', description: '777', labels: [development], relative_position: 2) }
let_it_be(:issue8) { create(:closed_issue, project: project, title: 'hhh', description: '888') } let_it_be(:issue8) { create(:closed_issue, project: project, title: 'hhh', description: '888') }
let(:all_issues) { [confidential_issue, issue1, issue2, issue3, issue4, issue5, issue6, issue7, issue8] }
before_all do
project.add_maintainer(user)
project.add_maintainer(user2)
end
context 'filtering' do context 'filtering' do
before do before do
project.add_maintainer(user) stub_const("Gitlab::QueryLimiting::Transaction::THRESHOLD", 200)
project.add_maintainer(user2)
stub_licensed_features(epics: true, swimlanes: true) stub_licensed_features(epics: true, swimlanes: true)
sign_in(user) sign_in(user)
visit_board_page visit_board_page
...@@ -43,60 +49,43 @@ RSpec.describe 'epics swimlanes filtering', :js do ...@@ -43,60 +49,43 @@ RSpec.describe 'epics swimlanes filtering', :js do
page.find('.dropdown-item', text: 'Epic').click page.find('.dropdown-item', text: 'Epic').click
end end
wait_for_all_requests wait_for_all_issues
stub_const("Gitlab::QueryLimiting::Transaction::THRESHOLD", 200)
end end
it 'filters by author' do it 'filters by author' do
wait_for_all_requests
set_filter("author", user2.username) set_filter("author", user2.username)
click_filter_link(user2.username) click_filter_link(user2.username)
submit_filter submit_filter
wait_for_all_requests
wait_for_board_cards(2, 1) wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4)) wait_for_empty_boards((3..4))
end end
it 'filters by assignee', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/266990' do it 'filters by assignee' do
wait_for_all_requests
set_filter("assignee", user.username) set_filter("assignee", user.username)
click_filter_link(user.username) click_filter_link(user.username)
submit_filter submit_filter
wait_for_all_requests
wait_for_board_cards(2, 1) wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4)) wait_for_empty_boards((3..4))
end end
it 'filters by milestone' do it 'filters by milestone' do
wait_for_all_requests
set_filter("milestone", "\"#{milestone.title}") set_filter("milestone", "\"#{milestone.title}")
click_filter_link(milestone.title) click_filter_link(milestone.title)
submit_filter submit_filter
wait_for_all_requests
wait_for_board_cards(2, 1) wait_for_board_cards(2, 1)
wait_for_board_cards(3, 0) wait_for_board_cards(3, 0)
wait_for_board_cards(4, 0) wait_for_board_cards(4, 0)
end end
it 'filters by label' do it 'filters by label' do
wait_for_all_requests
set_filter("label", testing.title) set_filter("label", testing.title)
click_filter_link(testing.title) click_filter_link(testing.title)
submit_filter submit_filter
wait_for_all_requests
wait_for_board_cards(2, 1) wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4)) wait_for_empty_boards((3..4))
end end
...@@ -104,7 +93,7 @@ RSpec.describe 'epics swimlanes filtering', :js do ...@@ -104,7 +93,7 @@ RSpec.describe 'epics swimlanes filtering', :js do
def visit_board_page def visit_board_page
visit project_boards_path(project) visit project_boards_path(project)
wait_for_all_requests wait_for_all_issues
end end
def wait_for_board_cards(board_number, expected_cards) def wait_for_board_cards(board_number, expected_cards)
...@@ -123,6 +112,12 @@ RSpec.describe 'epics swimlanes filtering', :js do ...@@ -123,6 +112,12 @@ RSpec.describe 'epics swimlanes filtering', :js do
end end
end end
def wait_for_all_issues
all_issues.each do |i|
page.has_content?(i.title)
end
end
def set_filter(type, text) def set_filter(type, text)
find('.filtered-search').native.send_keys("#{type}:=#{text}") find('.filtered-search').native.send_keys("#{type}:=#{text}")
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