2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-09-29 11:11:47 -04:00
|
|
|
RSpec.describe 'CI Lint', :js do
|
2021-06-18 17:10:06 -04:00
|
|
|
include Spec::Support::Helpers::Features::SourceEditorSpecHelpers
|
2020-09-11 14:08:42 -04:00
|
|
|
|
2018-03-13 13:57:16 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
let(:content_selector) { '.content .view-lines' }
|
2018-02-08 11:14:31 -05:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
visit project_ci_lint_path(project)
|
|
|
|
editor_set_value(yaml_content)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
wait_for('YAML content') do
|
|
|
|
find(content_selector).text.present?
|
|
|
|
end
|
|
|
|
end
|
2020-08-12 11:10:02 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
describe 'YAML parsing' do
|
|
|
|
shared_examples 'validates the YAML' do
|
|
|
|
before do
|
|
|
|
click_on 'Validate'
|
|
|
|
end
|
2020-08-12 11:10:02 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
context 'YAML is correct' do
|
|
|
|
let(:yaml_content) do
|
|
|
|
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
2020-08-12 11:10:02 -04:00
|
|
|
end
|
2015-12-22 02:47:23 -05:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
it 'parses Yaml and displays the jobs' do
|
2020-12-22 10:09:51 -05:00
|
|
|
expect(page).to have_content('Status: Syntax is correct')
|
2020-08-12 11:10:02 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
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
|
2015-12-22 02:47:23 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
context 'YAML is incorrect' do
|
|
|
|
let(:yaml_content) { 'value: cannot have :' }
|
2015-12-22 02:47:23 -05:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
it 'displays information about an error' do
|
2020-12-22 10:09:51 -05:00
|
|
|
expect(page).to have_content('Status: Syntax is incorrect')
|
2020-10-14 08:08:58 -04:00
|
|
|
expect(page).to have_selector(content_selector, text: yaml_content)
|
2020-09-11 14:08:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
it_behaves_like 'validates the YAML'
|
|
|
|
|
|
|
|
context 'when Dry Run is checked' do
|
2020-08-12 11:10:02 -04:00
|
|
|
before do
|
2020-10-14 08:08:58 -04:00
|
|
|
check 'Simulate a pipeline created for the default branch'
|
2015-12-22 02:47:23 -05:00
|
|
|
end
|
2020-08-12 11:10:02 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
it_behaves_like 'validates the YAML'
|
2015-12-22 02:47:23 -05:00
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
2018-02-08 11:14:31 -05:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
describe 'YAML clearing' do
|
|
|
|
before do
|
|
|
|
click_on 'Clear'
|
|
|
|
end
|
2018-02-08 11:14:31 -05:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
context 'YAML is present' do
|
|
|
|
let(:yaml_content) do
|
|
|
|
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
|
|
|
end
|
2020-09-11 14:08:42 -04:00
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
it 'YAML content is cleared' do
|
2020-11-07 04:08:52 -05:00
|
|
|
expect(page).to have_field(class: 'inputarea', with: '', visible: false, type: 'textarea')
|
2018-02-08 11:14:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|