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

73 lines
2.6 KiB
Ruby
Raw Normal View History

2023-03-04 22:38:38 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Environments (JavaScript fixtures)', feature_category: :environment_management do
include ApiHelpers
include JavaScriptFixturesHelpers
include GraphqlHelpers
let_it_be(:admin) { create(:admin, username: 'administrator', email: 'admin@example.gitlab.com') }
let_it_be(:group) { create(:group, path: 'environments-group') }
let_it_be(:project) { create(:project, :repository, group: group, path: 'environments-project') }
let_it_be(:environment) { create(:environment, name: 'staging', project: project) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let_it_be(:build) { create(:ci_build, :success, pipeline: pipeline) }
let(:user) { create(:user) }
let(:role) { :developer }
2023-03-17 16:20:25 +05:30
describe GraphQL::Query, type: :request do
environment_details_query_path = 'environments/graphql/queries/environment_details.query.graphql'
2023-03-04 22:38:38 +05:30
2023-03-17 16:20:25 +05:30
context 'with no deployments' do
it "graphql/#{environment_details_query_path}.empty.json" do
query = get_graphql_query_as_string(environment_details_query_path)
puts project.full_path
puts environment.name
post_graphql(query, current_user: admin,
variables:
{
projectFullPath: project.full_path,
environmentName: environment.name,
pageSize: 10
})
expect_graphql_errors_to_be_empty
end
end
2023-03-04 22:38:38 +05:30
2023-03-17 16:20:25 +05:30
context 'with deployments' do
let_it_be(:deployment) do
create(:deployment, :success, environment: environment, deployable: nil)
end
2023-03-04 22:38:38 +05:30
2023-03-17 16:20:25 +05:30
let_it_be(:deployment_success) do
2023-07-09 08:55:56 +05:30
create(:deployment, :success, environment: environment, deployable: build, finished_at: 1.hour.since)
2023-03-17 16:20:25 +05:30
end
let_it_be(:deployment_failed) do
create(:deployment, :failed, environment: environment, deployable: build)
end
let_it_be(:deployment_running) do
create(:deployment, :running, environment: environment, deployable: build)
end
it "graphql/#{environment_details_query_path}.json" do
query = get_graphql_query_as_string(environment_details_query_path)
2023-03-04 22:38:38 +05:30
2023-03-17 16:20:25 +05:30
post_graphql(query, current_user: admin,
variables:
{
projectFullPath: project.full_path,
environmentName: environment.name,
pageSize: 10
})
expect_graphql_errors_to_be_empty
end
2023-03-04 22:38:38 +05:30
end
end
end