debian-mirror-gitlab/spec/frontend/fixtures/runner.rb

175 lines
5.4 KiB
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Runner (JavaScript fixtures)' do
include AdminModeHelper
include ApiHelpers
include JavaScriptFixturesHelpers
include GraphqlHelpers
let_it_be(:admin) { create(:admin) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :repository, :public) }
2022-04-04 11:22:00 +05:30
let_it_be(:project_2) { create(:project, :repository, :public) }
2021-09-04 01:27:46 +05:30
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') }
2021-11-11 11:23:49 +05:30
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') }
2022-04-04 11:22:00 +05:30
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) }
2021-09-04 01:27:46 +05:30
query_path = 'runner/graphql/'
fixtures_path = 'graphql/runner/'
after(:all) do
remove_repository(project)
end
2022-03-02 08:16:31 +05:30
describe do
2021-11-11 11:23:49 +05:30
before do
sign_in(admin)
enable_admin_mode!(admin)
end
2022-03-02 08:16:31 +05:30
describe GraphQL::Query, type: :request do
get_runners_query_name = 'get_runners.query.graphql'
2021-09-04 01:27:46 +05:30
2022-03-02 08:16:31 +05:30
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runners_query_name}")
end
2021-09-04 01:27:46 +05:30
2022-03-02 08:16:31 +05:30
it "#{fixtures_path}#{get_runners_query_name}.json" do
post_graphql(query, current_user: admin, variables: {})
2021-09-04 01:27:46 +05:30
2022-03-02 08:16:31 +05:30
expect_graphql_errors_to_be_empty
end
2021-09-04 01:27:46 +05:30
2022-03-02 08:16:31 +05:30
it "#{fixtures_path}#{get_runners_query_name}.paginated.json" do
post_graphql(query, current_user: admin, variables: { first: 2 })
expect_graphql_errors_to_be_empty
end
2021-09-04 01:27:46 +05:30
end
2022-03-02 08:16:31 +05:30
describe GraphQL::Query, type: :request do
get_runners_count_query_name = 'get_runners_count.query.graphql'
2021-09-04 01:27:46 +05:30
2022-03-02 08:16:31 +05:30
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runners_count_query_name}")
end
it "#{fixtures_path}#{get_runners_count_query_name}.json" do
post_graphql(query, current_user: admin, variables: {})
2021-11-11 11:23:49 +05:30
2022-03-02 08:16:31 +05:30
expect_graphql_errors_to_be_empty
end
2021-09-04 01:27:46 +05:30
end
2022-03-02 08:16:31 +05:30
describe GraphQL::Query, type: :request do
get_runner_query_name = 'get_runner.query.graphql'
2021-09-04 01:27:46 +05:30
2022-03-02 08:16:31 +05:30
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runner_query_name}")
end
it "#{fixtures_path}#{get_runner_query_name}.json" do
post_graphql(query, current_user: admin, variables: {
id: instance_runner.to_global_id.to_s
})
expect_graphql_errors_to_be_empty
end
2022-04-04 11:22:00 +05:30
it "#{fixtures_path}#{get_runner_query_name}.with_group.json" do
post_graphql(query, current_user: admin, variables: {
id: group_runner.to_global_id.to_s
})
expect_graphql_errors_to_be_empty
end
end
describe GraphQL::Query, type: :request do
get_runner_projects_query_name = 'get_runner_projects.query.graphql'
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runner_projects_query_name}")
end
it "#{fixtures_path}#{get_runner_projects_query_name}.json" do
post_graphql(query, current_user: admin, variables: {
id: project_runner.to_global_id.to_s
})
expect_graphql_errors_to_be_empty
end
end
describe GraphQL::Query, type: :request do
get_runner_jobs_query_name = 'get_runner_jobs.query.graphql'
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_runner_jobs_query_name}")
end
it "#{fixtures_path}#{get_runner_jobs_query_name}.json" do
post_graphql(query, current_user: admin, variables: {
id: instance_runner.to_global_id.to_s
})
expect_graphql_errors_to_be_empty
end
2021-09-04 01:27:46 +05:30
end
end
2021-11-11 11:23:49 +05:30
2022-03-02 08:16:31 +05:30
describe do
2021-11-11 11:23:49 +05:30
let_it_be(:group_owner) { create(:user) }
before do
group.add_owner(group_owner)
end
2022-03-02 08:16:31 +05:30
describe GraphQL::Query, type: :request do
get_group_runners_query_name = 'get_group_runners.query.graphql'
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_group_runners_query_name}")
end
2021-11-11 11:23:49 +05:30
2022-03-02 08:16:31 +05:30
it "#{fixtures_path}#{get_group_runners_query_name}.json" do
post_graphql(query, current_user: group_owner, variables: {
groupFullPath: group.full_path
})
2021-11-11 11:23:49 +05:30
2022-03-02 08:16:31 +05:30
expect_graphql_errors_to_be_empty
end
it "#{fixtures_path}#{get_group_runners_query_name}.paginated.json" do
post_graphql(query, current_user: group_owner, variables: {
groupFullPath: group.full_path,
first: 1
})
expect_graphql_errors_to_be_empty
end
2021-11-11 11:23:49 +05:30
end
2022-03-02 08:16:31 +05:30
describe GraphQL::Query, type: :request do
get_group_runners_count_query_name = 'get_group_runners_count.query.graphql'
let_it_be(:query) do
get_graphql_query_as_string("#{query_path}#{get_group_runners_count_query_name}")
end
it "#{fixtures_path}#{get_group_runners_count_query_name}.json" do
post_graphql(query, current_user: group_owner, variables: {
groupFullPath: group.full_path
})
2021-11-11 11:23:49 +05:30
2022-03-02 08:16:31 +05:30
expect_graphql_errors_to_be_empty
end
2021-11-11 11:23:49 +05:30
end
end
2021-09-04 01:27:46 +05:30
end