2016-01-14 18:37:52 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'CI Lint', :js do
|
2018-05-09 12:01:36 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
before do
|
2018-05-09 12:01:36 +05:30
|
|
|
project.add_developer(user)
|
|
|
|
sign_in(user)
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
visit project_ci_lint_path(project)
|
2018-03-27 19:54:05 +05:30
|
|
|
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
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe 'YAML parsing' do
|
|
|
|
before do
|
|
|
|
click_on 'Validate'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'YAML is correct' do
|
|
|
|
let(:yaml_content) do
|
|
|
|
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
|
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'parses Yaml' do
|
2016-01-14 18:37:52 +05:30
|
|
|
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-03-27 19:54:05 +05:30
|
|
|
let(:yaml_content) { 'value: cannot have :' }
|
2016-01-14 18:37:52 +05:30
|
|
|
|
|
|
|
it 'displays information about an error' do
|
|
|
|
expect(page).to have_content('Status: syntax is incorrect')
|
2018-03-27 19:54:05 +05:30
|
|
|
expect(page).to have_selector('.ace_content', text: yaml_content)
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'YAML revalidate' do
|
|
|
|
let(:yaml_content) { 'my yaml content' }
|
|
|
|
|
|
|
|
it 'loads previous YAML content after validation' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_field('content', with: 'my yaml content', visible: false, type: 'textarea')
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
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
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|