1# frozen_string_literal: true
2
3module QA
4  RSpec.describe 'Create' do
5    describe 'Git push over HTTP' do
6      it 'user pushes code to the repository', :smoke, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347747' do
7        Flow::Login.sign_in
8
9        Resource::Repository::ProjectPush.fabricate! do |push|
10          push.file_name = 'README.md'
11          push.file_content = '# This is a test project'
12          push.commit_message = 'Add README.md'
13        end.project.visit!
14
15        Page::Project::Show.perform do |project|
16          expect(project).to have_file('README.md')
17          expect(project).to have_readme_content('This is a test project')
18        end
19      end
20
21      it 'pushes to a project using a specific Praefect repository storage', :smoke, :requires_admin, :requires_praefect, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347789' do
22        Flow::Login.sign_in_as_admin
23
24        project = Resource::Project.fabricate_via_api! do |storage_project|
25          storage_project.name = 'specific-repository-storage'
26          storage_project.repository_storage = QA::Runtime::Env.praefect_repository_storage
27        end
28
29        Resource::Repository::Push.fabricate! do |push|
30          push.repository_http_uri = project.repository_http_location.uri
31          push.file_name = 'README.md'
32          push.file_content = "# This is a test project named #{project.name}"
33          push.commit_message = 'Add README.md'
34          push.new_branch = true
35        end
36
37        project.visit!
38
39        Page::Project::Show.perform do |project_page|
40          expect(project_page).to have_file('README.md')
41          expect(project_page).to have_readme_content("This is a test project named #{project.name}")
42        end
43      end
44    end
45  end
46end
47