summaryrefslogtreecommitdiff
path: root/spec/features/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb
blob: 6308acb41f517ba0da48d188707c0820bded2db3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
  before do
    project = create(:project, :repository)
    sign_in project.owner
    stub_experiment(ci_syntax_templates: experiment_active)
    stub_experiment_for_subject(ci_syntax_templates: in_experiment_group)

    visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml')
  end

  context 'when experiment is not active' do
    let(:experiment_active) { false }
    let(:in_experiment_group) { false }

    it 'does not show the "Learn CI/CD syntax" template dropdown' do
      expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector')
    end
  end

  context 'when experiment is active and the user is in the control group' do
    let(:experiment_active) { true }
    let(:in_experiment_group) { false }

    it 'does not show the "Learn CI/CD syntax" template dropdown' do
      expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector')
    end
  end

  context 'when experiment is active and the user is in the experimental group' do
    let(:experiment_active) { true }
    let(:in_experiment_group) { true }

    it 'allows the user to pick a "Learn CI/CD syntax" template from the dropdown', :js,
       { quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/297347' } } do
      expect(page).to have_css('.gitlab-ci-syntax-yml-selector')

      find('.js-gitlab-ci-syntax-yml-selector').click

      wait_for_requests

      within '.gitlab-ci-syntax-yml-selector' do
        find('.dropdown-input-field').set('Artifacts example')
        find('.dropdown-content .is-focused', text: 'Artifacts example').click
      end

      wait_for_requests

      expect(page).to have_css('.gitlab-ci-syntax-yml-selector .dropdown-toggle-text', text: 'Learn CI/CD syntax')
      expect(page).to have_content('You can use artifacts to pass data to jobs in later stages.')
    end
  end
end