From 6438df3a1e0fb944485cebf07976160184697d72 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 20 Jan 2021 13:34:23 -0600 Subject: Add latest changes from gitlab-org/gitlab@13-8-stable-ee --- .../api/3_create/gitaly/gitaly_mtls_spec.rb | 43 ++++++++++ .../repository/project_archive_compare_spec.rb | 7 -- .../1_manage/group/transfer_project_spec.rb | 4 +- .../browser_ui/1_manage/login/register_spec.rb | 34 +++++--- .../1_manage/project/create_project_spec.rb | 3 +- .../snippet/copy_snippet_file_contents_spec.rb | 75 +++++++++++++++++ .../3_create/snippet/share_snippet_spec.rb | 2 +- .../web_ide/upload_new_file_in_web_ide_spec.rb | 89 ++++++++++++++++++++ .../browser_ui/5_package/maven_repository_spec.rb | 94 +++++++++++++++++----- .../6_release/pages/pages_pipeline_spec.rb | 45 +++++++++++ 10 files changed, 353 insertions(+), 43 deletions(-) create mode 100644 qa/qa/specs/features/api/3_create/gitaly/gitaly_mtls_spec.rb create mode 100644 qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb create mode 100644 qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb create mode 100644 qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb (limited to 'qa/qa/specs') diff --git a/qa/qa/specs/features/api/3_create/gitaly/gitaly_mtls_spec.rb b/qa/qa/specs/features/api/3_create/gitaly/gitaly_mtls_spec.rb new file mode 100644 index 00000000000..8c3b8d88a29 --- /dev/null +++ b/qa/qa/specs/features/api/3_create/gitaly/gitaly_mtls_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + context 'Gitaly', :orchestrated, :mtls do + describe 'Using mTLS' do + let(:intial_commit_message) { 'Initial commit' } + let(:first_added_commit_message) { 'commit over git' } + let(:second_added_commit_message) { 'commit over api' } + + it 'pushes to gitaly', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1118' do + project = Resource::Project.fabricate! do |project| + project.name = "mTLS" + project.initialize_with_readme = true + end + + Resource::Repository::ProjectPush.fabricate! do |push| + push.project = project + push.new_branch = false + push.commit_message = first_added_commit_message + push.file_content = 'First commit' + end + + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = second_added_commit_message + commit.add_files([ + { + file_path: "file-#{SecureRandom.hex(8)}", + content: 'Second commit' + } + ]) + end + + expect(project.commits.map { |commit| commit[:message].chomp }) + .to include(intial_commit_message) + .and include(first_added_commit_message) + .and include(second_added_commit_message) + end + end + end + end +end diff --git a/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb b/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb index 548933d2cde..4bd99b4820e 100644 --- a/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb +++ b/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb @@ -28,13 +28,6 @@ module QA end end - after do - # Delete the .netrc file created during this test so that subsequent tests don't try to use the logins - Git::Repository.perform do |repository| - repository.delete_netrc - end - end - it 'download archives of each user project then check they are different', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/427' do archive_checksums = {} diff --git a/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb index b9e1ee53246..5f38907f89f 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/group/transfer_project_spec.rb @@ -43,7 +43,9 @@ module QA end end - it 'user transfers a project between groups', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/406' do + it 'user transfers a project between groups', + testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/406', + quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/283925', type: :investigating, only: :production } do # Retry is needed here as the target group is not avaliable for transfer right away. QA::Support::Retrier.retry_on_exception(reload_page: page) do Page::File::Show.perform(&:go_to_general_settings) diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb index d58857f6da2..d9b246fc458 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb @@ -98,8 +98,10 @@ module QA before do enable_require_admin_approval_after_user_signup_via_ui - @user = Resource::User.fabricate_via_browser_ui! do |user| - user.expect_fabrication_success = false + Support::Retrier.retry_on_exception do + @user = Resource::User.fabricate_via_browser_ui! do |user| + user.expect_fabrication_success = false + end end end @@ -148,26 +150,34 @@ module QA end def set_require_admin_approval_after_user_signup_via_api(enable_or_disable) - return if Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] == enable_or_disable + return if get_require_admin_approval_after_user_signup_via_api == enable_or_disable Runtime::ApplicationSettings.set_application_settings(require_admin_approval_after_user_signup: enable_or_disable) sleep 10 # It takes a moment for the setting to come into effect end + def get_require_admin_approval_after_user_signup_via_api + Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] + end + def enable_require_admin_approval_after_user_signup_via_ui - unless Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] - Flow::Login.while_signed_in_as_admin do - Page::Main::Menu.perform(&:go_to_admin_area) - QA::Page::Admin::Menu.perform(&:go_to_general_settings) - Page::Admin::Settings::General.perform do |setting| - setting.expand_sign_up_restrictions do |settings| - settings.require_admin_approval_after_user_signup + unless get_require_admin_approval_after_user_signup_via_api + QA::Support::Retrier.retry_until do + Flow::Login.while_signed_in_as_admin do + Page::Main::Menu.perform(&:go_to_admin_area) + QA::Page::Admin::Menu.perform(&:go_to_general_settings) + Page::Admin::Settings::General.perform do |setting| + setting.expand_sign_up_restrictions do |settings| + settings.require_admin_approval_after_user_signup + end end end - end - sleep 10 # It takes a moment for the setting to come into effect + sleep 15 # It takes a moment for the setting to come into effect + + get_require_admin_approval_after_user_signup_via_api + end end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb index ff13b769e3a..a2e01398c94 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb @@ -4,8 +4,7 @@ module QA RSpec.describe 'Manage', :smoke do describe 'Project creation' do it 'user creates a new project', - testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/429', - quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/283925', type: :investigating } do + testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/429' do Flow::Login.sign_in created_project = Resource::Project.fabricate_via_browser_ui! do |project| diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb new file mode 100644 index 00000000000..1670ba56064 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Multiple file snippet' do + let(:first_file_content) { 'First file content' } + let(:second_file_content) { 'Second file content' } + let(:third_file_content) { 'Third file content' } + + let(:personal_snippet) do + Resource::Snippet.fabricate_via_api! do |snippet| + snippet.title = 'Personal snippet to copy file contents from' + snippet.file_name = 'First file name' + snippet.file_content = first_file_content + + snippet.add_files do |files| + files.append(name: 'Second file name', content: second_file_content) + files.append(name: 'Third file name', content: third_file_content) + end + end + end + + let(:project_snippet) do + Resource::ProjectSnippet.fabricate_via_api! do |snippet| + snippet.title = 'Project snippet to copy file contents from' + snippet.file_name = 'First file name' + snippet.file_content = first_file_content + + snippet.add_files do |files| + files.append(name: 'Second file name', content: second_file_content) + files.append(name: 'Third file name', content: third_file_content) + end + end + end + + let(:files) do + [ + { + number: 1, + content: first_file_content + }, + { + number: 2, + content: second_file_content + }, + { + number: 3, + content: third_file_content + } + ] + end + + before do + Flow::Login.sign_in + end + + shared_examples 'copying snippet file contents' do |snippet_type| + it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them" do + send(snippet_type).visit! + + files.each do |files| + Page::Dashboard::Snippet::Show.perform do |snippet| + snippet.copy_file_contents_to_comment(files[:number]) + expect(snippet).to have_comment_content(files[:content]) + snippet.delete_comment(files[:content]) + end + end + end + end + + it_behaves_like 'copying snippet file contents', :personal_snippet + it_behaves_like 'copying snippet file contents', :project_snippet + end + end +end diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb index 971c5371d44..751424222ba 100644 --- a/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb +++ b/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb @@ -7,7 +7,7 @@ module QA Resource::Snippet.fabricate! do |snippet| snippet.title = 'Shared snippet' snippet.visibility = 'Public' - snippet.file_content = 'code.py' + snippet.file_name = 'code.py' snippet.file_content = 'code to be shared' end end diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb new file mode 100644 index 00000000000..d62f894279f --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Upload a file in Web IDE' do + let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', file_name)) } + + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'upload-file-project' + project.initialize_with_readme = true + end + end + + before do + Flow::Login.sign_in + + project.visit! + Page::Project::Show.perform(&:open_web_ide!) + end + + context 'when a file with the same name already exists' do + let(:file_name) { 'README.md' } + + it 'throws an error' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + end + + expect(page).to have_content('The name "README.md" is already taken in this directory.') + end + end + + context 'when the file is a text file' do + let(:file_name) { 'text_file.txt' } + + it 'shows the Edit tab with the text' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + + expect(ide).to have_file(file_name) + expect(ide).to have_file_addition_icon(file_name) + expect(ide).to have_text('Simple text') + + ide.commit_changes + + expect(ide).to have_file(file_name) + end + end + end + + context 'when the file is binary' do + let(:file_name) { 'logo_sample.svg' } + + it 'shows a Download button' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + + expect(ide).to have_file(file_name) + expect(ide).to have_file_addition_icon(file_name) + expect(ide).to have_download_button(file_name) + + ide.commit_changes + + expect(ide).to have_file(file_name) + end + end + end + + context 'when the file is an image' do + let(:file_name) { 'dk.png' } + + it 'shows an image viewer' do + Page::Project::WebIDE::Edit.perform do |ide| + ide.upload_file(file_path) + + expect(ide).to have_file(file_name) + expect(ide).to have_file_addition_icon(file_name) + expect(ide).to have_image_viewer(file_name) + + ide.commit_changes + + expect(ide).to have_file(file_name) + end + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb index 5410b5023d9..605248e33f7 100644 --- a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb @@ -22,10 +22,22 @@ module QA end end - it 'publishes a maven package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/943' do + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.name = "qa-runner-#{Time.now.to_i}" + runner.tags = ["runner-for-#{project.name}"] + runner.executor = :docker + runner.project = project + end + end + + let!(:gitlab_address_with_port) do uri = URI.parse(Runtime::Scenario.gitlab_address) - gitlab_address_with_port = "#{uri.scheme}://#{uri.host}:#{uri.port}" - pom_xml = { + "#{uri.scheme}://#{uri.host}:#{uri.port}" + end + + let(:pom_xml) do + { file_path: 'pom.xml', content: <<~XML @@ -52,28 +64,33 @@ module QA XML } - settings_xml = { + end + + let(:settings_xml) do + { file_path: 'settings.xml', content: <<~XML - - - - #{project.name} - - - - Private-Token - #{auth_token} - - - - - - + + + + #{project.name} + + + + Private-Token + #{auth_token} + + + + + + XML } + end + it 'publishes a maven package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/943' do # Use a maven docker container to deploy the package with_fixtures([pom_xml, settings_xml]) do |dir| Service::DockerRun::Maven.new(dir).publish! @@ -99,6 +116,43 @@ module QA expect(index).not_to have_package(package_name) end end + + it 'publishes and downloads a maven package via CI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1115' do + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([ + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + deploy: + image: maven:3.6-jdk-11 + script: + - 'mvn deploy -s settings.xml' + - "mvn dependency:get -Dartifact=#{group_id}:#{artifact_id}:1.0" + only: + - "#{project.default_branch}" + tags: + - "runner-for-#{project.name}" + YAML + }, + settings_xml, + pom_xml + ]) + end + + project.visit! + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('deploy') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end + end end end end diff --git a/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb b/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb new file mode 100644 index 00000000000..17c53b3ddc9 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/6_release/pages/pages_pipeline_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Release', :smoke, :runner do + describe 'Pages' do + let!(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'jekyll-pages-project' + project.template_name = :jekyll + end + end + + let(:pipeline) do + Resource::Pipeline.fabricate_via_api! do |pipeline| + pipeline.project = project + pipeline.variables = + { key: :CI_PAGES_DOMAIN, value: 'nip.io', variable_type: :env_var }, + { key: :CI_PAGES_URL, value: 'http://127.0.0.1.nip.io', variable_type: :env_var } + end + end + + before do + Flow::Login.sign_in + + Resource::Runner.fabricate_via_api! do |runner| + runner.project = project + runner.executor = :docker + end + + pipeline.visit! + end + + it 'runs a Pages-specific pipeline', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/296937' do + Page::Project::Pipeline::Show.perform do |show| + expect(show).to have_job(:pages) + show.click_job(:pages) + end + + Page::Project::Job::Show.perform do |show| + expect(show).to have_passed(timeout: 300) + end + end + end + end +end -- cgit v1.2.1