2015-08-26 01:42:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'CI Lint', :js do
|
2015-08-26 01:42:46 +00:00
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(create(:user))
|
2018-02-08 16:14:31 +00:00
|
|
|
|
|
|
|
visit ci_lint_path
|
|
|
|
find('#ci-editor')
|
|
|
|
execute_script("ace.edit('ci-editor').setValue(#{yaml_content.to_json});")
|
|
|
|
|
|
|
|
# Ace editor updates a hidden textarea and it happens asynchronously
|
|
|
|
wait_for('YAML content') do
|
|
|
|
find('.ace_content').text.present?
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2015-12-22 08:40:32 +00:00
|
|
|
describe 'YAML parsing' do
|
2015-12-22 07:47:23 +00:00
|
|
|
before do
|
|
|
|
click_on 'Validate'
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2015-12-22 07:47:23 +00:00
|
|
|
context 'YAML is correct' do
|
|
|
|
let(:yaml_content) do
|
|
|
|
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'parses Yaml' do
|
2015-12-22 07:47:23 +00:00
|
|
|
within "table" 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
|
|
|
|
|
|
|
|
context 'YAML is incorrect' do
|
2018-02-08 16:14:31 +00:00
|
|
|
let(:yaml_content) { 'value: cannot have :' }
|
2015-12-22 07:47:23 +00:00
|
|
|
|
|
|
|
it 'displays information about an error' do
|
|
|
|
expect(page).to have_content('Status: syntax is incorrect')
|
|
|
|
end
|
|
|
|
end
|
2016-01-11 12:34:12 +00:00
|
|
|
|
|
|
|
describe 'YAML revalidate' do
|
|
|
|
let(:yaml_content) { 'my yaml content' }
|
|
|
|
|
|
|
|
it 'loads previous YAML content after validation' do
|
2017-01-04 21:44:16 +00:00
|
|
|
expect(page).to have_field('content', with: 'my yaml content', visible: false, type: 'textarea')
|
2016-01-11 12:34:12 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
2018-02-08 16:14:31 +00:00
|
|
|
|
|
|
|
describe 'YAML clearing' do
|
|
|
|
before do
|
|
|
|
click_on 'Clear'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'YAML is present' do
|
|
|
|
let(:yaml_content) do
|
|
|
|
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'YAML content is cleared' do
|
|
|
|
expect(page).to have_field('content', with: '', visible: false, type: 'textarea')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|