debian-mirror-gitlab/spec/features/projects/ci/lint_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe 'CI Lint', :js, feature_category: :pipeline_composition do
2023-06-20 00:43:36 +05:30
include Features::SourceEditorSpecHelpers
2020-11-24 15:15:51 +05:30
2022-11-25 23:54:43 +05:30
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
2018-05-09 12:01:36 +05:30
2021-01-03 14:25:43 +05:30
let(:content_selector) { '.content .view-lines' }
2018-03-27 19:54:05 +05:30
2022-11-25 23:54:43 +05:30
before_all do
2021-01-03 14:25:43 +05:30
project.add_developer(user)
2022-11-25 23:54:43 +05:30
end
before do
2021-01-03 14:25:43 +05:30
sign_in(user)
2021-01-03 14:25:43 +05:30
visit project_ci_lint_path(project)
editor_set_value(yaml_content)
end
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
describe 'YAML parsing' do
shared_examples 'validates the YAML' do
before do
click_on 'Validate'
2022-08-27 11:52:29 +05:30
scroll_to(page.find('[data-testid="ci-lint-status"]'))
2021-01-03 14:25:43 +05:30
end
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
context 'YAML is correct' do
let(:yaml_content) do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
2020-10-24 23:57:45 +05:30
end
2021-01-03 14:25:43 +05:30
it 'parses Yaml and displays the jobs' do
2021-03-08 18:12:59 +05:30
expect(page).to have_content('Status: Syntax is correct')
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
within "table" do
aggregate_failures do
expect(page).to have_content('Job - rspec')
expect(page).to have_content('Job - spinach')
expect(page).to have_content('Deploy Job - staging')
expect(page).to have_content('Deploy Job - production')
end
end
end
end
2021-01-03 14:25:43 +05:30
context 'YAML is incorrect' do
let(:yaml_content) { 'value: cannot have :' }
2021-01-03 14:25:43 +05:30
it 'displays information about an error' do
2021-03-08 18:12:59 +05:30
expect(page).to have_content('Status: Syntax is incorrect')
2021-01-03 14:25:43 +05:30
expect(page).to have_selector(content_selector, text: yaml_content)
2020-11-24 15:15:51 +05:30
end
end
end
2021-01-03 14:25:43 +05:30
it_behaves_like 'validates the YAML'
context 'when Dry Run is checked' do
2020-10-24 23:57:45 +05:30
before do
2021-01-03 14:25:43 +05:30
check 'Simulate a pipeline created for the default branch'
end
2020-10-24 23:57:45 +05:30
2021-01-03 14:25:43 +05:30
it_behaves_like 'validates the YAML'
end
end
2018-03-27 19:54:05 +05:30
2021-01-03 14:25:43 +05:30
describe 'YAML clearing' do
before do
click_on 'Clear'
end
2018-03-27 19:54:05 +05:30
2021-01-03 14:25:43 +05:30
context 'YAML is present' do
let(:yaml_content) do
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
2020-11-24 15:15:51 +05:30
2021-01-03 14:25:43 +05:30
it 'YAML content is cleared' do
2021-01-29 00:20:46 +05:30
expect(page).to have_field(class: 'inputarea', with: '', visible: false, type: 'textarea')
2018-03-27 19:54:05 +05:30
end
end
end
end