Commit f304ff90 authored by Alex Kalderimis's avatar Alex Kalderimis

Remove custom pagination spec

Prefer to use the pagination shared examples
parent 1b99ac21
...@@ -75,56 +75,21 @@ RSpec.describe 'Getting issues for an epic' do ...@@ -75,56 +75,21 @@ RSpec.describe 'Getting issues for an epic' do
end end
context 'pagination' do context 'pagination' do
def epic_fields(after) let(:data_path) { %i[group epics nodes] + [0] + %i[issues] }
<<~NODE
edges {
node {
iid
issues(#{attributes_to_graphql(first: 1, after: after)}) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
},
edges {
node {
id
}
}
}
}
}
NODE
end
let(:params) { { iid: epic.iid } }
def get_page(after) def pagination_query(args)
query = epic_query(params, epic_fields(after)) epic_query({ iid: epic.iid }, epic_fields(args))
post_graphql(query, current_user: user)
expect(response).to have_gitlab_http_status(:success)
data = ::Gitlab::Json.parse(response.body)
expect(data['errors']).to be_blank
epics = data.dig('data', 'group', 'epics', 'edges')
issues = issue_ids(epics)[epic.iid]
page = epics.dig(0, 'node', 'issues', 'pageInfo')
[issues, page]
end end
it 'paginates correctly' do def epic_fields(args)
issues, page_1 = get_page(nil) query_graphql_field(:nodes, query_nodes(:issues, :id, args: args, include_pagination_info: true))
end
expect(issues).to contain_exactly(global_id_of(issue))
expect(page_1).to include("hasNextPage" => true, "hasPreviousPage" => false)
next_issues, page_2 = get_page(page_1['endCursor'])
expect(next_issues).to contain_exactly(global_id_of(confidential_issue)) it_behaves_like 'sorted paginated query' do
expect(page_2).to include("hasNextPage" => false, "hasPreviousPage" => true) let(:current_user) { user }
let(:sort_param) { }
let(:first_param) { 1 }
let(:expected_results) { [issue, confidential_issue].map { |i| global_id_of(i) } }
end end
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