diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/requests/api/graphql/ci | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/requests/api/graphql/ci')
-rw-r--r-- | spec/requests/api/graphql/ci/stages_spec.rb | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/spec/requests/api/graphql/ci/stages_spec.rb b/spec/requests/api/graphql/ci/stages_spec.rb index cd48a24b9c8..50d2cf75097 100644 --- a/spec/requests/api/graphql/ci/stages_spec.rb +++ b/spec/requests/api/graphql/ci/stages_spec.rb @@ -4,11 +4,13 @@ require 'spec_helper' RSpec.describe 'Query.project.pipeline.stages' do include GraphqlHelpers - let(:project) { create(:project, :repository, :public) } - let(:user) { create(:user) } - let(:pipeline) { create(:ci_pipeline, project: project, user: user) } - let(:stage_graphql_data) { graphql_data['project']['pipeline']['stages'] } + subject(:post_query) { post_graphql(query, current_user: user) } + let_it_be(:project) { create(:project, :repository, :public) } + let_it_be(:user) { create(:user) } + let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) } + + let(:stage_nodes) { graphql_data_at(:project, :pipeline, :stages, :nodes) } let(:params) { {} } let(:fields) do @@ -33,14 +35,42 @@ RSpec.describe 'Query.project.pipeline.stages' do ) end - before do + before_all do create(:ci_stage_entity, pipeline: pipeline, name: 'deploy') - post_graphql(query, current_user: user) + create_list(:ci_build, 2, pipeline: pipeline, stage: 'deploy') end - it_behaves_like 'a working graphql query' + it_behaves_like 'a working graphql query' do + before do + post_query + end + end it 'returns the stage of a pipeline' do - expect(stage_graphql_data['nodes'].first['name']).to eq('deploy') + post_query + + expect(stage_nodes.first['name']).to eq('deploy') + end + + describe 'job pagination' do + let(:job_nodes) { graphql_dig_at(stage_nodes, :jobs, :nodes) } + + it 'returns up to default limit jobs per stage' do + post_query + + expect(job_nodes.count).to eq(2) + end + + context 'when the limit is manually set' do + before do + stub_application_setting(jobs_per_stage_page_size: 1) + end + + it 'returns up to custom limit jobs per stage' do + post_query + + expect(job_nodes.count).to eq(1) + end + end end end |