2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file', :js do
|
|
|
|
include Spec::Support::Helpers::Features::EditorLiteSpecHelpers
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
let(:params) { {} }
|
|
|
|
let(:filename) { '.gitlab-ci.yml' }
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
before do
|
2018-10-15 14:42:47 +05:30
|
|
|
sign_in project.owner
|
2021-04-29 21:17:54 +05:30
|
|
|
visit project_new_blob_path(project, 'master', file_name: filename, **params)
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
it 'user can pick a template from the dropdown' do
|
2016-06-22 15:30:34 +05:30
|
|
|
expect(page).to have_css('.gitlab-ci-yml-selector')
|
|
|
|
|
|
|
|
find('.js-gitlab-ci-yml-selector').click
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
within '.gitlab-ci-yml-selector' do
|
2016-08-24 12:49:21 +05:30
|
|
|
find('.dropdown-input-field').set('Jekyll')
|
|
|
|
find('.dropdown-content li', text: 'Jekyll').click
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template')
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(editor_get_value).to have_content('This file is a template, and might need editing before it works on your project')
|
|
|
|
expect(editor_get_value).to have_content('jekyll build -d test')
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
context 'when template param is provided' do
|
|
|
|
let(:params) { { template: 'Jekyll' } }
|
|
|
|
|
|
|
|
it 'uses the given template' do
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template')
|
|
|
|
expect(editor_get_value).to have_content('This file is a template, and might need editing before it works on your project')
|
|
|
|
expect(editor_get_value).to have_content('jekyll build -d test')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when provided template param is not a valid template name' do
|
|
|
|
let(:params) { { template: 'non-existing-template' } }
|
|
|
|
|
|
|
|
it 'leaves the editor empty' do
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template')
|
|
|
|
expect(editor_get_value).to have_content('')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when template is not available for the given file' do
|
|
|
|
let(:filename) { 'Dockerfile' }
|
|
|
|
let(:params) { { template: 'Jekyll' } }
|
|
|
|
|
|
|
|
it 'leaves the editor empty' do
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(editor_get_value).to have_content('')
|
|
|
|
end
|
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|