diff options
Diffstat (limited to 'spec/frontend/fixtures')
-rw-r--r-- | spec/frontend/fixtures/integrations.rb | 2 | ||||
-rw-r--r-- | spec/frontend/fixtures/issues.rb | 40 | ||||
-rw-r--r-- | spec/frontend/fixtures/namespaces.rb | 46 | ||||
-rw-r--r-- | spec/frontend/fixtures/prometheus_integration.rb | 2 | ||||
-rw-r--r-- | spec/frontend/fixtures/runner.rb | 44 |
5 files changed, 111 insertions, 23 deletions
diff --git a/spec/frontend/fixtures/integrations.rb b/spec/frontend/fixtures/integrations.rb index 1bafb0bfe78..45d1c400f5d 100644 --- a/spec/frontend/fixtures/integrations.rb +++ b/spec/frontend/fixtures/integrations.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Projects::Settings::IntegrationsController, '(JavaScript fixtures)', type: :controller do include JavaScriptFixturesHelpers - let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} + let(:namespace) { create(:namespace, name: 'frontend-fixtures' ) } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'integrations-project') } let!(:service) { create(:custom_issue_tracker_integration, project: project) } let(:user) { project.first_owner } diff --git a/spec/frontend/fixtures/issues.rb b/spec/frontend/fixtures/issues.rb index 8bedb802242..cde796497d4 100644 --- a/spec/frontend/fixtures/issues.rb +++ b/spec/frontend/fixtures/issues.rb @@ -106,3 +106,43 @@ RSpec.describe API::Issues, '(JavaScript fixtures)', type: :request do expect(response).to be_successful end end + +RSpec.describe GraphQL::Query, type: :request do + include ApiHelpers + include GraphqlHelpers + include JavaScriptFixturesHelpers + + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:issue_type) { 'issue' } + + before_all do + project.add_reporter(user) + end + + issue_popover_query_path = 'issuable/popover/queries/issue.query.graphql' + + it "graphql/#{issue_popover_query_path}.json" do + query = get_graphql_query_as_string(issue_popover_query_path, ee: Gitlab.ee?) + + issue = create( + :issue, + project: project, + confidential: true, + created_at: Time.parse('2020-07-01T04:08:01Z'), + due_date: Date.new(2020, 7, 5), + milestone: create( + :milestone, + project: project, + title: '15.2', + start_date: Date.new(2020, 7, 1), + due_date: Date.new(2020, 7, 30) + ), + issue_type: issue_type + ) + + post_graphql(query, current_user: user, variables: { projectPath: project.full_path, iid: issue.iid.to_s }) + + expect_graphql_errors_to_be_empty + end +end diff --git a/spec/frontend/fixtures/namespaces.rb b/spec/frontend/fixtures/namespaces.rb new file mode 100644 index 00000000000..b11f661fe09 --- /dev/null +++ b/spec/frontend/fixtures/namespaces.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Jobs (JavaScript fixtures)' do + include ApiHelpers + include JavaScriptFixturesHelpers + include GraphqlHelpers + + describe GraphQL::Query, type: :request do + let_it_be(:user) { create(:user) } + let_it_be(:groups) { create_list(:group, 4) } + + before_all do + groups.each { |group| group.add_owner(user) } + end + + query_name = 'search_namespaces_where_user_can_transfer_projects' + query_extension = '.query.graphql' + + full_input_path = "projects/settings/graphql/queries/#{query_name}#{query_extension}" + base_output_path = "graphql/projects/settings/#{query_name}" + + it "#{base_output_path}_page_1#{query_extension}.json" do + query = get_graphql_query_as_string(full_input_path) + + post_graphql(query, current_user: user, variables: { first: 2 }) + + expect_graphql_errors_to_be_empty + end + + it "#{base_output_path}_page_2#{query_extension}.json" do + query = get_graphql_query_as_string(full_input_path) + + post_graphql(query, current_user: user, variables: { first: 2 }) + + post_graphql( + query, + current_user: user, + variables: { first: 2, after: graphql_data_at('currentUser', 'groups', 'pageInfo', 'endCursor') } + ) + + expect_graphql_errors_to_be_empty + end + end +end diff --git a/spec/frontend/fixtures/prometheus_integration.rb b/spec/frontend/fixtures/prometheus_integration.rb index 883dbb929a2..250c50bc8bb 100644 --- a/spec/frontend/fixtures/prometheus_integration.rb +++ b/spec/frontend/fixtures/prometheus_integration.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Projects::Settings::IntegrationsController, '(JavaScript fixtures)', type: :controller do include JavaScriptFixturesHelpers - let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} + let(:namespace) { create(:namespace, name: 'frontend-fixtures' ) } let(:project) { create(:project_empty_repo, namespace: namespace, path: 'integrations-project') } let!(:integration) { create(:prometheus_integration, project: project) } let(:user) { project.first_owner } diff --git a/spec/frontend/fixtures/runner.rb b/spec/frontend/fixtures/runner.rb index 36281af0219..b523650dda5 100644 --- a/spec/frontend/fixtures/runner.rb +++ b/spec/frontend/fixtures/runner.rb @@ -13,11 +13,12 @@ RSpec.describe 'Runner (JavaScript fixtures)' do let_it_be(:project) { create(:project, :repository, :public) } let_it_be(:project_2) { create(:project, :repository, :public) } - let_it_be(:instance_runner) { create(:ci_runner, :instance, version: '1.0.0', revision: '123', description: 'Instance runner', ip_address: '127.0.0.1') } - let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group], active: false, version: '2.0.0', revision: '456', description: 'Group runner', ip_address: '127.0.0.1') } - let_it_be(:group_runner_2) { create(:ci_runner, :group, groups: [group], active: false, version: '2.0.0', revision: '456', description: 'Group runner 2', ip_address: '127.0.0.1') } - let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project, project_2], active: false, version: '2.0.0', revision: '456', description: 'Project runner', ip_address: '127.0.0.1') } - let_it_be(:build) { create(:ci_build, runner: instance_runner) } + let_it_be(:runner) { create(:ci_runner, :instance, description: 'My Runner', version: '1.0.0') } + let_it_be(:group_runner) { create(:ci_runner, :group, groups: [group], version: '2.0.0') } + let_it_be(:group_runner_2) { create(:ci_runner, :group, groups: [group], version: '2.0.0') } + let_it_be(:project_runner) { create(:ci_runner, :project, projects: [project, project_2], version: '2.0.0') } + + let_it_be(:build) { create(:ci_build, runner: runner) } query_path = 'runner/graphql/' fixtures_path = 'graphql/runner/' @@ -27,18 +28,19 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end before do - allow(Gitlab::Ci::RunnerUpgradeCheck.instance) - .to receive(:check_runner_upgrade_status) - .and_return({ not_available: nil }) + allow_next_instance_of(::Gitlab::Ci::RunnerUpgradeCheck) do |instance| + allow(instance).to receive(:check_runner_upgrade_suggestion) + .and_return([nil, :not_available]) + end end - describe do + describe 'as admin', GraphQL::Query do before do sign_in(admin) enable_admin_mode!(admin) end - describe GraphQL::Query, type: :request do + describe 'all_runners.query.graphql', type: :request do all_runners_query = 'list/all_runners.query.graphql' let_it_be(:query) do @@ -58,7 +60,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end end - describe GraphQL::Query, type: :request do + describe 'all_runners_count.query.graphql', type: :request do all_runners_count_query = 'list/all_runners_count.query.graphql' let_it_be(:query) do @@ -72,7 +74,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end end - describe GraphQL::Query, type: :request do + describe 'runner.query.graphql', type: :request do runner_query = 'show/runner.query.graphql' let_it_be(:query) do @@ -81,7 +83,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do it "#{fixtures_path}#{runner_query}.json" do post_graphql(query, current_user: admin, variables: { - id: instance_runner.to_global_id.to_s + id: runner.to_global_id.to_s }) expect_graphql_errors_to_be_empty @@ -96,7 +98,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end end - describe GraphQL::Query, type: :request do + describe 'runner_projects.query.graphql', type: :request do runner_projects_query = 'show/runner_projects.query.graphql' let_it_be(:query) do @@ -112,7 +114,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end end - describe GraphQL::Query, type: :request do + describe 'runner_jobs.query.graphql', type: :request do runner_jobs_query = 'show/runner_jobs.query.graphql' let_it_be(:query) do @@ -121,14 +123,14 @@ RSpec.describe 'Runner (JavaScript fixtures)' do it "#{fixtures_path}#{runner_jobs_query}.json" do post_graphql(query, current_user: admin, variables: { - id: instance_runner.to_global_id.to_s + id: runner.to_global_id.to_s }) expect_graphql_errors_to_be_empty end end - describe GraphQL::Query, type: :request do + describe 'runner_form.query.graphql', type: :request do runner_jobs_query = 'edit/runner_form.query.graphql' let_it_be(:query) do @@ -137,7 +139,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do it "#{fixtures_path}#{runner_jobs_query}.json" do post_graphql(query, current_user: admin, variables: { - id: instance_runner.to_global_id.to_s + id: runner.to_global_id.to_s }) expect_graphql_errors_to_be_empty @@ -145,14 +147,14 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end end - describe do + describe 'as group owner', GraphQL::Query do let_it_be(:group_owner) { create(:user) } before do group.add_owner(group_owner) end - describe GraphQL::Query, type: :request do + describe 'group_runners.query.graphql', type: :request do group_runners_query = 'list/group_runners.query.graphql' let_it_be(:query) do @@ -177,7 +179,7 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end end - describe GraphQL::Query, type: :request do + describe 'group_runners_count.query.graphql', type: :request do group_runners_count_query = 'list/group_runners_count.query.graphql' let_it_be(:query) do |