Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb55
1 files changed, 24 insertions, 31 deletions
diff --git a/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb b/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb
index feb3ba46353..f26af6cb766 100644
--- a/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/graphql/group_and_project_boards_query_shared_examples.rb
@@ -45,44 +45,37 @@ RSpec.shared_examples 'group and project boards query' do
end
describe 'sorting and pagination' do
+ let(:data_path) { [board_parent_type, :boards] }
+
+ def pagination_query(params, page_info)
+ graphql_query_for(
+ board_parent_type,
+ { 'fullPath' => board_parent.full_path },
+ query_graphql_field('boards', params, "#{page_info} edges { node { id } }")
+ )
+ end
+
+ def pagination_results_data(data)
+ data.map { |board| board.dig('node', 'id') }
+ end
+
context 'when using default sorting' do
let!(:board_B) { create(:board, resource_parent: board_parent, name: 'B') }
let!(:board_C) { create(:board, resource_parent: board_parent, name: 'C') }
let!(:board_a) { create(:board, resource_parent: board_parent, name: 'a') }
let!(:board_A) { create(:board, resource_parent: board_parent, name: 'A') }
-
- before do
- post_graphql(query, current_user: current_user)
- end
-
- it_behaves_like 'a working graphql query'
+ let(:boards) { [board_a, board_A, board_B, board_C] }
context 'when ascending' do
- let(:boards) { [board_a, board_A, board_B, board_C] }
- let(:expected_boards) do
- if board_parent.multiple_issue_boards_available?
- boards
- else
- [boards.first]
- end
- end
-
- it 'sorts boards' do
- expect(grab_names).to eq expected_boards.map(&:name)
- end
-
- context 'when paginating' do
- let(:params) { 'first: 2' }
-
- it 'sorts boards' do
- expect(grab_names).to eq expected_boards.first(2).map(&:name)
-
- cursored_query = query("after: \"#{end_cursor}\"")
- post_graphql(cursored_query, current_user: current_user)
-
- response_data = Gitlab::Json.parse(response.body)['data'][board_parent_type]['boards']['edges']
-
- expect(grab_names(response_data)).to eq expected_boards.drop(2).first(2).map(&:name)
+ it_behaves_like 'sorted paginated query' do
+ let(:sort_param) { }
+ let(:first_param) { 2 }
+ let(:expected_results) do
+ if board_parent.multiple_issue_boards_available?
+ boards.map { |board| board.to_global_id.to_s }
+ else
+ [boards.first.to_global_id.to_s]
+ end
end
end
end