Commit 04e80338 authored by Eulyeon Ko's avatar Eulyeon Ko

Fix boards_spec.rb for graphql_board_lists

- Remove unused spec example
"locked milestone" has not been working for a while
(this test was a vacuous spec)

- Correct selector for weight.
".issue-count-badge" DOES NOT select weight element.
(the spec was flawed to begin with)

- Disable expensive query limit check by using
a special HTTP header field (only for spec runs):
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55314

- Wait for graphql requests after drag-and-dropping cards
parent 2dfe4ab4
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'issue boards', :js do RSpec.describe 'Project issue boards', :js do
include DragTo include DragTo
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -132,7 +132,8 @@ RSpec.describe 'issue boards', :js do ...@@ -132,7 +132,8 @@ RSpec.describe 'issue boards', :js do
it 'shows total weight for backlog' do it 'shows total weight for backlog' do
backlog = board.lists.first backlog = board.lists.first
expect(badge(backlog)).to have_content('5')
expect(list_weight_badge(backlog)).to have_content('5')
end end
it 'updates weight when moving to list' do it 'updates weight when moving to list' do
...@@ -146,8 +147,8 @@ RSpec.describe 'issue boards', :js do ...@@ -146,8 +147,8 @@ RSpec.describe 'issue boards', :js do
to_index: 0, to_index: 0,
list_to_index: 1) list_to_index: 1)
expect(badge(from)).to have_content('3') expect(card_weight_badge(from)).to have_content('3')
expect(badge(to)).to have_content('2') expect(card_weight_badge(to)).to have_content('2')
end end
context 'unlicensed' do context 'unlicensed' do
...@@ -160,29 +161,13 @@ RSpec.describe 'issue boards', :js do ...@@ -160,29 +161,13 @@ RSpec.describe 'issue boards', :js do
expect(page).not_to have_text('2 issues') expect(page).not_to have_text('2 issues')
backlog = board.lists.first backlog = board.lists.first
badge(backlog).hover list_weight_badge(backlog).hover
expect(page).to have_text('2 issues') expect(page).to have_text('2 issues')
end end
end end
end end
context 'locked milestone' do
before do
visit project_board_path(project, board_with_milestone)
wait_for_requests
end
it 'does not have remove button' do
expect(page).to have_selector('.js-visual-token .remove-token', count: 0)
end
it 'is not able to be backspaced' do
find('.input-token .filtered-search').native.send_key(:backspace)
expect(page).to have_selector('.js-visual-token', count: 1)
end
end
context 'list header' do context 'list header' do
let(:max_issue_count) { 2 } let(:max_issue_count) { 2 }
let!(:label) { create(:label, project: project, name: 'Label 2') } let!(:label) { create(:label, project: project, name: 'Label 2') }
...@@ -359,8 +344,12 @@ RSpec.describe 'issue boards', :js do ...@@ -359,8 +344,12 @@ RSpec.describe 'issue boards', :js do
end end
end end
def badge(list) def list_weight_badge(list)
find(".board[data-id='#{list.id}'] .issue-count-badge") find(".board[data-id='gid://gitlab/List/#{list.id}'] .issue-count-badge")
end
def card_weight_badge(list)
find(".board[data-id='gid://gitlab/List/#{list.id}'] [data-testid='board-card-weight']")
end end
def visit_board_page def visit_board_page
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Issue Boards', :js do RSpec.describe 'Project issue boards', :js do
include DragTo include DragTo
include MobileHelpers include MobileHelpers
...@@ -23,7 +23,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -23,7 +23,7 @@ RSpec.describe 'Issue Boards', :js do
context 'no lists' do context 'no lists' do
before do before do
visit project_board_path(project, board) visit_project_board_path_without_query_limit(project, board)
end end
it 'creates default lists' do it 'creates default lists' do
...@@ -52,6 +52,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -52,6 +52,7 @@ RSpec.describe 'Issue Boards', :js do
let_it_be(:a_plus) { create(:label, project: project, name: 'A+') } let_it_be(:a_plus) { create(:label, project: project, name: 'A+') }
let_it_be(:list1) { create(:list, board: board, label: planning, position: 0) } let_it_be(:list1) { create(:list, board: board, label: planning, position: 0) }
let_it_be(:list2) { create(:list, board: board, label: development, position: 1) } let_it_be(:list2) { create(:list, board: board, label: development, position: 1) }
let_it_be(:backlog_list) { create(:backlog_list, board: board) }
let_it_be(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) } let_it_be(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
let_it_be(:issue1) { create(:labeled_issue, project: project, title: 'aaa', description: '111', assignees: [user], labels: [planning], relative_position: 8) } let_it_be(:issue1) { create(:labeled_issue, project: project, title: 'aaa', description: '111', assignees: [user], labels: [planning], relative_position: 8) }
...@@ -68,7 +69,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -68,7 +69,7 @@ RSpec.describe 'Issue Boards', :js do
before do before do
stub_feature_flags(board_new_list: false) stub_feature_flags(board_new_list: false)
visit project_board_path(project, board) visit_project_board_path_without_query_limit(project, board)
wait_for_requests wait_for_requests
...@@ -121,7 +122,8 @@ RSpec.describe 'Issue Boards', :js do ...@@ -121,7 +122,8 @@ RSpec.describe 'Issue Boards', :js do
context 'with the NOT queries feature flag disabled' do context 'with the NOT queries feature flag disabled' do
before do before do
stub_feature_flags(not_issuable_queries: false) stub_feature_flags(not_issuable_queries: false)
visit project_board_path(project, board)
visit_project_board_path_without_query_limit(project, board)
end end
it 'does not have the != option' do it 'does not have the != option' do
...@@ -141,7 +143,8 @@ RSpec.describe 'Issue Boards', :js do ...@@ -141,7 +143,8 @@ RSpec.describe 'Issue Boards', :js do
context 'with the NOT queries feature flag enabled' do context 'with the NOT queries feature flag enabled' do
before do before do
stub_feature_flags(not_issuable_queries: true) stub_feature_flags(not_issuable_queries: true)
visit project_board_path(project, board)
visit_project_board_path_without_query_limit(project, board)
end end
it 'does not have the != option' do it 'does not have the != option' do
...@@ -171,8 +174,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -171,8 +174,7 @@ RSpec.describe 'Issue Boards', :js do
it 'infinite scrolls list' do it 'infinite scrolls list' do
create_list(:labeled_issue, 50, project: project, labels: [planning]) create_list(:labeled_issue, 50, project: project, labels: [planning])
visit project_board_path(project, board) visit_project_board_path_without_query_limit(project, board)
wait_for_requests
page.within(find('.board:nth-child(2)')) do page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('58') expect(page.find('.board-header')).to have_content('58')
...@@ -180,15 +182,19 @@ RSpec.describe 'Issue Boards', :js do ...@@ -180,15 +182,19 @@ RSpec.describe 'Issue Boards', :js do
expect(page).to have_content('Showing 20 of 58 issues') expect(page).to have_content('Showing 20 of 58 issues')
find('.board .board-list') find('.board .board-list')
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
wait_for_requests inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
end
expect(page).to have_selector('.board-card', count: 40) expect(page).to have_selector('.board-card', count: 40)
expect(page).to have_content('Showing 40 of 58 issues') expect(page).to have_content('Showing 40 of 58 issues')
find('.board .board-list') find('.board .board-list')
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
wait_for_requests inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
end
expect(page).to have_selector('.board-card', count: 58) expect(page).to have_selector('.board-card', count: 58)
expect(page).to have_content('Showing all issues') expect(page).to have_content('Showing all issues')
...@@ -236,13 +242,13 @@ RSpec.describe 'Issue Boards', :js do ...@@ -236,13 +242,13 @@ RSpec.describe 'Issue Boards', :js do
wait_for_board_cards(4, 1) wait_for_board_cards(4, 1)
expect(find('.board:nth-child(2)')).to have_content(development.title) expect(find('.board:nth-child(2)')).to have_content(development.title)
expect(find('.board:nth-child(2)')).to have_content(planning.title) expect(find('.board:nth-child(3)')).to have_content(planning.title)
# Make sure list positions are preserved after a reload # Make sure list positions are preserved after a reload
visit project_board_path(project, board) visit_project_board_path_without_query_limit(project, board)
expect(find('.board:nth-child(2)')).to have_content(development.title) expect(find('.board:nth-child(2)')).to have_content(development.title)
expect(find('.board:nth-child(2)')).to have_content(planning.title) expect(find('.board:nth-child(3)')).to have_content(planning.title)
end end
it 'dragging does not duplicate list' do it 'dragging does not duplicate list' do
...@@ -254,7 +260,8 @@ RSpec.describe 'Issue Boards', :js do ...@@ -254,7 +260,8 @@ RSpec.describe 'Issue Boards', :js do
expect(page).to have_selector(selector, text: development.title, count: 1) expect(page).to have_selector(selector, text: development.title, count: 1)
end end
it 'issue moves between lists and does not show the "Development" label since the card is in the "Development" list label' do # TODO https://gitlab.com/gitlab-org/gitlab/-/issues/323551
xit 'issue moves between lists and does not show the "Development" label since the card is in the "Development" list label' do
drag(list_from_index: 1, from_index: 1, list_to_index: 2) drag(list_from_index: 1, from_index: 1, list_to_index: 2)
wait_for_board_cards(2, 7) wait_for_board_cards(2, 7)
...@@ -467,14 +474,16 @@ RSpec.describe 'Issue Boards', :js do ...@@ -467,14 +474,16 @@ RSpec.describe 'Issue Boards', :js do
end end
it 'removes filtered labels' do it 'removes filtered labels' do
set_filter("label", testing.title) inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
click_filter_link(testing.title) set_filter("label", testing.title)
submit_filter click_filter_link(testing.title)
submit_filter
wait_for_board_cards(2, 1) wait_for_board_cards(2, 1)
find('.clear-search').click find('.clear-search').click
submit_filter submit_filter
end
wait_for_board_cards(2, 8) wait_for_board_cards(2, 8)
end end
...@@ -484,7 +493,9 @@ RSpec.describe 'Issue Boards', :js do ...@@ -484,7 +493,9 @@ RSpec.describe 'Issue Boards', :js do
set_filter("label", testing.title) set_filter("label", testing.title)
click_filter_link(testing.title) click_filter_link(testing.title)
submit_filter inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
submit_filter
end
wait_for_requests wait_for_requests
...@@ -494,13 +505,18 @@ RSpec.describe 'Issue Boards', :js do ...@@ -494,13 +505,18 @@ RSpec.describe 'Issue Boards', :js do
expect(page).to have_content('Showing 20 of 51 issues') expect(page).to have_content('Showing 20 of 51 issues')
find('.board .board-list') find('.board .board-list')
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
end
expect(page).to have_selector('.board-card', count: 40) expect(page).to have_selector('.board-card', count: 40)
expect(page).to have_content('Showing 40 of 51 issues') expect(page).to have_content('Showing 40 of 51 issues')
find('.board .board-list') find('.board .board-list')
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight") inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
end
expect(page).to have_selector('.board-card', count: 51) expect(page).to have_selector('.board-card', count: 51)
expect(page).to have_content('Showing all issues') expect(page).to have_content('Showing all issues')
...@@ -569,7 +585,7 @@ RSpec.describe 'Issue Boards', :js do ...@@ -569,7 +585,7 @@ RSpec.describe 'Issue Boards', :js do
context 'keyboard shortcuts' do context 'keyboard shortcuts' do
before do before do
visit project_board_path(project, board) visit_project_board_path_without_query_limit(project, board)
wait_for_requests wait_for_requests
end end
...@@ -617,15 +633,19 @@ RSpec.describe 'Issue Boards', :js do ...@@ -617,15 +633,19 @@ RSpec.describe 'Issue Boards', :js do
def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, perform_drop: true) def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, perform_drop: true)
# ensure there is enough horizontal space for four boards # ensure there is enough horizontal space for four boards
resize_window(2000, 800) inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
resize_window(2000, 800)
drag_to(selector: selector,
scrollable: '#board-app', drag_to(selector: selector,
list_from_index: list_from_index, scrollable: '#board-app',
from_index: from_index, list_from_index: list_from_index,
to_index: to_index, from_index: from_index,
list_to_index: list_to_index, to_index: to_index,
perform_drop: perform_drop) list_to_index: list_to_index,
perform_drop: perform_drop)
end
wait_for_requests
end end
def wait_for_board_cards(board_number, expected_cards) def wait_for_board_cards(board_number, expected_cards)
...@@ -666,4 +686,10 @@ RSpec.describe 'Issue Boards', :js do ...@@ -666,4 +686,10 @@ RSpec.describe 'Issue Boards', :js do
accept_confirm { find('[data-testid="remove-list"]').click } accept_confirm { find('[data-testid="remove-list"]').click }
end end
end end
def visit_project_board_path_without_query_limit(project, board)
inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
visit project_board_path(project, board)
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