summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/3_create/repository/create_edit_delete_file_via_web_spec.rb
blob: 82d635065a0767bf7b408bef4f780cf8774bad34 (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
57
58
# frozen_string_literal: true

module QA
  context :create do
    describe 'Files management' do
      it 'user creates, edits and deletes a file via the Web' do
        Runtime::Browser.visit(:gitlab, Page::Main::Login)
        Page::Main::Login.act { sign_in_using_credentials }

        # Create
        file_name = 'QA Test - File name'
        file_content = 'QA Test - File content'
        commit_message_for_create = 'QA Test - Create new file'

        Factory::Resource::File.fabricate! do |file|
          file.name = file_name
          file.content = file_content
          file.commit_message = commit_message_for_create
        end

        expect(page).to have_content('The file has been successfully created.')
        expect(page).to have_content(file_name)
        expect(page).to have_content(file_content)
        expect(page).to have_content(commit_message_for_create)

        # Edit
        updated_file_content = 'QA Test - Updated file content'
        commit_message_for_update = 'QA Test - Update file'

        Page::File::Show.act { click_edit }

        Page::File::Form.act do
          remove_content
          add_content(updated_file_content)
          add_commit_message(commit_message_for_update)
          commit_changes
        end

        expect(page).to have_content('Your changes have been successfully committed.')
        expect(page).to have_content(updated_file_content)
        expect(page).to have_content(commit_message_for_update)

        # Delete
        commit_message_for_delete = 'QA Test - Delete file'

        Page::File::Show.act do
          click_delete
          add_commit_message(commit_message_for_delete)
          click_delete_file
        end

        expect(page).to have_content('The file has been successfully deleted.')
        expect(page).to have_content(commit_message_for_delete)
        expect(page).to have_no_content(file_name)
      end
    end
  end
end