BigW Consortium Gitlab

ci_lint_spec.rb 1.46 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'CI Lint', :js do
4
  before do
5
    sign_in(create(:user))
6 7
  end

8
  describe 'YAML parsing' do
9 10
    before do
      visit ci_lint_path
11 12
      # Ace editor updates a hidden textarea and it happens asynchronously
      # `sleep 0.1` is actually needed here because of this
13
      find('#ci-editor')
14 15
      execute_script("ace.edit('ci-editor').setValue(" + yaml_content.to_json + ");")
      sleep 0.1
16
      click_on 'Validate'
17 18
    end

19 20 21 22 23
    context 'YAML is correct' do
      let(:yaml_content) do
        File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
      end

24
      it 'parses Yaml' do
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        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
      let(:yaml_content) { '' }

      it 'displays information about an error' do
        expect(page).to have_content('Status: syntax is incorrect')
        expect(page).to have_content('Error: Please provide content of .gitlab-ci.yml')
      end
    end
42 43 44 45 46

    describe 'YAML revalidate' do
      let(:yaml_content) { 'my yaml content' }

      it 'loads previous YAML content after validation' do
47
        expect(page).to have_field('content', with: 'my yaml content', visible: false, type: 'textarea')
48 49
      end
    end
50 51
  end
end