2019-10-17 02:07:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-18 15:31:11 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
RSpec.describe 'Jobs (JavaScript fixtures)' do
|
|
|
|
include ApiHelpers
|
2016-11-18 15:31:11 -05:00
|
|
|
include JavaScriptFixturesHelpers
|
2022-06-28 14:08:20 -04:00
|
|
|
include GraphqlHelpers
|
2016-11-18 15:31:11 -05:00
|
|
|
|
2016-11-19 18:40:37 -05:00
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
|
2018-10-26 04:48:20 -04:00
|
|
|
let(:project) { create(:project, :repository, namespace: namespace, path: 'builds-project') }
|
2022-01-21 16:16:35 -05:00
|
|
|
let(:user) { project.first_owner }
|
2018-10-26 04:48:20 -04:00
|
|
|
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id) }
|
2022-06-28 14:08:20 -04:00
|
|
|
|
|
|
|
after do
|
|
|
|
remove_repository(project)
|
2018-10-26 04:48:20 -04:00
|
|
|
end
|
2016-11-18 15:31:11 -05:00
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
describe Projects::JobsController, type: :controller do
|
|
|
|
let!(:delayed) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'delayed job') }
|
2016-11-18 15:31:11 -05:00
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2016-11-18 15:31:11 -05:00
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
it 'jobs/delayed.json' do
|
|
|
|
get :show, params: {
|
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: delayed.to_param
|
|
|
|
}, format: :json
|
|
|
|
|
|
|
|
expect(response).to be_successful
|
|
|
|
end
|
2017-08-22 19:19:35 -04:00
|
|
|
end
|
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
describe GraphQL::Query, type: :request do
|
2022-07-05 11:08:48 -04:00
|
|
|
let(:artifact) { create(:ci_job_artifact, file_type: :archive, file_format: :zip) }
|
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
let!(:build) { create(:ci_build, :success, name: 'build', pipeline: pipeline) }
|
2022-07-05 11:08:48 -04:00
|
|
|
let!(:cancelable) { create(:ci_build, :cancelable, name: 'cancelable', pipeline: pipeline) }
|
2022-06-28 14:08:20 -04:00
|
|
|
let!(:created_by_tag) { create(:ci_build, :success, name: 'created_by_tag', tag: true, pipeline: pipeline) }
|
2022-07-05 11:08:48 -04:00
|
|
|
let!(:pending) { create(:ci_build, :pending, name: 'pending', pipeline: pipeline) }
|
|
|
|
let!(:playable) { create(:ci_build, :playable, name: 'playable', pipeline: pipeline) }
|
|
|
|
let!(:retryable) { create(:ci_build, :retryable, name: 'retryable', pipeline: pipeline) }
|
|
|
|
let!(:scheduled) { create(:ci_build, :scheduled, name: 'scheduled', pipeline: pipeline) }
|
|
|
|
let!(:with_artifact) { create(:ci_build, :success, name: 'with_artifact', job_artifacts: [artifact], pipeline: pipeline) }
|
2022-06-28 14:08:20 -04:00
|
|
|
let!(:with_coverage) { create(:ci_build, :success, name: 'with_coverage', coverage: 40.0, pipeline: pipeline) }
|
|
|
|
|
|
|
|
fixtures_path = 'graphql/jobs/'
|
|
|
|
get_jobs_query = 'get_jobs.query.graphql'
|
2022-07-05 11:08:48 -04:00
|
|
|
full_path = 'frontend-fixtures/builds-project'
|
2022-06-28 14:08:20 -04:00
|
|
|
|
|
|
|
let_it_be(:query) do
|
|
|
|
get_graphql_query_as_string("jobs/components/table/graphql/queries/#{get_jobs_query}")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "#{fixtures_path}#{get_jobs_query}.json" do
|
|
|
|
post_graphql(query, current_user: user, variables: {
|
2022-07-05 11:08:48 -04:00
|
|
|
fullPath: full_path
|
2022-06-28 14:08:20 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it "#{fixtures_path}#{get_jobs_query}.as_guest.json" do
|
|
|
|
guest = create(:user)
|
|
|
|
project.add_guest(guest)
|
|
|
|
|
|
|
|
post_graphql(query, current_user: guest, variables: {
|
2022-07-05 11:08:48 -04:00
|
|
|
fullPath: full_path
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it "#{fixtures_path}#{get_jobs_query}.paginated.json" do
|
|
|
|
post_graphql(query, current_user: user, variables: {
|
|
|
|
fullPath: full_path,
|
|
|
|
first: 2
|
|
|
|
})
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it "#{fixtures_path}#{get_jobs_query}.empty.json" do
|
|
|
|
post_graphql(query, current_user: user, variables: {
|
|
|
|
fullPath: full_path,
|
|
|
|
first: 0
|
2022-06-28 14:08:20 -04:00
|
|
|
})
|
2018-10-26 04:48:20 -04:00
|
|
|
|
2022-06-28 14:08:20 -04:00
|
|
|
expect_graphql_errors_to_be_empty
|
|
|
|
end
|
2018-10-26 04:48:20 -04:00
|
|
|
end
|
2016-11-18 15:31:11 -05:00
|
|
|
end
|