add_file_template_spec.rb 1.86 KB
Newer Older
1
2
3
# frozen_string_literal: true

module QA
4
  context 'Create' do
5
6
7
8
    describe 'Web IDE file templates' do
      include Runtime::Fixtures

      before(:all) do
9
        @project = Resource::Project.fabricate_via_api! do |project|
10
11
          project.name = 'file-template-project'
          project.description = 'Add file templates via the Web IDE'
Mark Lapierre's avatar
Mark Lapierre committed
12
          project.initialize_with_readme = true
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
        end
      end

      templates = [
        {
          file_name: '.gitignore',
          name: 'Android',
          api_path: 'gitignores',
          api_key: 'Android'
        },
        {
          file_name: '.gitlab-ci.yml',
          name: 'Julia',
          api_path: 'gitlab_ci_ymls',
          api_key: 'Julia'
        },
        {
          file_name: 'Dockerfile',
          name: 'Python',
          api_path: 'dockerfiles',
          api_key: 'Python'
        },
        {
          file_name: 'LICENSE',
          name: 'Mozilla Public License 2.0',
          api_path: 'licenses',
          api_key: 'mpl-2.0'
        }
      ]

      templates.each do |template|
        it "user adds #{template[:file_name]} via file template #{template[:name]}" do
          content = fetch_template_from_api(template[:api_path], template[:api_key])

47
48
          Flow::Login.sign_in

49
50
          @project.visit!

51
          Page::Project::Show.perform(&:open_web_ide!)
52
53
          Page::Project::WebIDE::Edit.perform do |ide|
            ide.create_new_file_from_template template[:file_name], template[:name]
54

55
            expect(ide.has_file?(template[:file_name])).to be_truthy
56

57
58
            expect(ide).to have_button('Undo')
            expect(ide).to have_normalized_ws_text(content[0..100])
59

60
            ide.commit_changes
61

62
63
64
            expect(ide).to have_content(template[:file_name])
            expect(ide).to have_normalized_ws_text(content[0..100])
          end
65
66
67
68
69
        end
      end
    end
  end
end