diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-21 15:09:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-21 15:09:30 +0300 |
commit | af28a89d5e6a62811b462ca7d3adcccf8c03e213 (patch) | |
tree | be14cd6b4adc411fe7f179c236ec0c2d2e472025 /qa | |
parent | 5bd4297fd759a14ad9ab9232cb985d28bf44ac49 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 6 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 11 | ||||
-rw-r--r-- | qa/qa/page/component/new_snippet.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/component/snippet.rb | 10 | ||||
-rw-r--r-- | qa/qa/page/merge_request/show.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/menu.rb | 1 | ||||
-rw-r--r-- | qa/qa/page/project/operations/kubernetes/show.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/packages/index.rb | 28 | ||||
-rw-r--r-- | qa/qa/page/project/packages/show.rb | 27 | ||||
-rw-r--r-- | qa/qa/page/project/snippet/new.rb | 1 | ||||
-rw-r--r-- | qa/qa/page/project/sub_menus/packages.rb | 29 | ||||
-rw-r--r-- | qa/qa/page/project/web_ide/edit.rb | 1 | ||||
-rw-r--r-- | qa/qa/page/settings/common.rb | 1 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb | 103 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb | 76 | ||||
-rw-r--r-- | qa/qa/support/page/logging.rb | 2 | ||||
-rw-r--r-- | qa/qa/support/wait_for_requests.rb | 13 | ||||
-rw-r--r-- | qa/spec/support/wait_for_requests_spec.rb | 27 |
19 files changed, 314 insertions, 30 deletions
@@ -277,6 +277,11 @@ module QA autoload :Show, 'qa/page/project/job/show' end + module Packages + autoload :Index, 'qa/page/project/packages/index' + autoload :Show, 'qa/page/project/packages/show' + end + module Settings autoload :Advanced, 'qa/page/project/settings/advanced' autoload :Main, 'qa/page/project/settings/main' @@ -315,6 +320,7 @@ module QA autoload :Repository, 'qa/page/project/sub_menus/repository' autoload :Settings, 'qa/page/project/sub_menus/settings' autoload :Project, 'qa/page/project/sub_menus/project' + autoload :Packages, 'qa/page/project/sub_menus/packages' end module Issue diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index f0d4ae45ef8..caf90dc137d 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -169,7 +169,7 @@ module QA end def has_element?(name, **kwargs) - wait_for_requests + wait_for_requests(skip_finished_loading_check: !!kwargs.delete(:skip_finished_loading_check)) disabled = kwargs.delete(:disabled) @@ -209,15 +209,6 @@ module QA has_text?(text.gsub(/\s+/, " "), wait: wait) end - def finished_loading? - wait_for_requests - - # The number of selectors should be able to be reduced after - # migration to the new spinner is complete. - # https://gitlab.com/groups/gitlab-org/-/epics/956 - has_no_css?('.gl-spinner, .fa-spinner, .spinner', wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME) - end - def finished_loading_block? wait_for_requests diff --git a/qa/qa/page/component/new_snippet.rb b/qa/qa/page/component/new_snippet.rb index 18f2e237097..3e5ae29177a 100644 --- a/qa/qa/page/component/new_snippet.rb +++ b/qa/qa/page/component/new_snippet.rb @@ -55,12 +55,10 @@ module QA end def fill_file_name(name) - finished_loading? fill_element :file_name_field, name end def fill_file_content(content) - finished_loading? text_area.set content end diff --git a/qa/qa/page/component/snippet.rb b/qa/qa/page/component/snippet.rb index 4ff19c01f1f..443ec3c34d5 100644 --- a/qa/qa/page/component/snippet.rb +++ b/qa/qa/page/component/snippet.rb @@ -100,19 +100,16 @@ module QA end def has_file_content?(file_content) - finished_loading? within_element(:file_content) do has_text?(file_content) end end def click_edit_button - finished_loading? click_element(:snippet_action_button, action: 'Edit') end def click_delete_button - finished_loading? click_element(:snippet_action_button, action: 'Delete') click_element(:delete_snippet_button) # wait for the page to reload after deletion @@ -123,32 +120,27 @@ module QA end def get_repository_uri_http - finished_loading? click_element(:clone_button) Git::Location.new(find_element(:copy_http_url_button)['data-clipboard-text']).uri.to_s end def get_repository_uri_ssh - finished_loading? click_element(:clone_button) Git::Location.new(find_element(:copy_ssh_url_button)['data-clipboard-text']).uri.to_s end def add_comment(comment) - finished_loading? fill_element(:note_field, comment) click_element(:comment_button) end def has_comment_author?(author_username) - finished_loading? within_element(:note_author_content) do has_text?('@' + author_username) end end def has_comment_content?(comment_content) - finished_loading? within_element(:note_content) do has_text?(comment_content) end @@ -161,14 +153,12 @@ module QA end def edit_comment(comment) - finished_loading? click_element(:edit_comment_button) fill_element(:edit_note_field, comment) click_element(:save_comment_button) end def delete_comment(comment) - finished_loading? click_element(:more_actions_dropdown) accept_alert do click_element(:delete_comment_button) diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb index b9a2bf4ee69..365818054f6 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -275,7 +275,7 @@ module QA end def wait_for_loading - finished_loading? && has_no_element?(:skeleton_note) + has_no_element?(:skeleton_note) end def click_open_in_web_ide diff --git a/qa/qa/page/project/menu.rb b/qa/qa/page/project/menu.rb index 9faf1bd5f8f..16c66ea5761 100644 --- a/qa/qa/page/project/menu.rb +++ b/qa/qa/page/project/menu.rb @@ -11,6 +11,7 @@ module QA include SubMenus::Operations include SubMenus::Repository include SubMenus::Settings + include SubMenus::Packages view 'app/views/layouts/nav/sidebar/_project.html.haml' do element :activity_link diff --git a/qa/qa/page/project/operations/kubernetes/show.rb b/qa/qa/page/project/operations/kubernetes/show.rb index e1612718883..11a5c106bfc 100644 --- a/qa/qa/page/project/operations/kubernetes/show.rb +++ b/qa/qa/page/project/operations/kubernetes/show.rb @@ -56,7 +56,7 @@ module QA def await_installed(application_name) within_element(application_name) do - has_element?(:uninstall_button, application: application_name, wait: 300) + has_element?(:uninstall_button, application: application_name, wait: 300, skip_finished_loading_check: true) end end diff --git a/qa/qa/page/project/packages/index.rb b/qa/qa/page/project/packages/index.rb new file mode 100644 index 00000000000..3f8cc6035bc --- /dev/null +++ b/qa/qa/page/project/packages/index.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module Packages + class Index < QA::Page::Base + view 'app/views/projects/packages/packages/_legacy_package_list.html.haml' do + element :package_row + element :package_link + end + + def click_package(name) + click_element(:package_link, text: name) + end + + def has_package?(name) + has_element?(:package_link, text: name) + end + + def has_no_package?(name) + has_no_element?(:package_link, text: name) + end + end + end + end + end +end diff --git a/qa/qa/page/project/packages/show.rb b/qa/qa/page/project/packages/show.rb new file mode 100644 index 00000000000..59e9a3752c7 --- /dev/null +++ b/qa/qa/page/project/packages/show.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module Packages + class Show < QA::Page::Base + view 'app/assets/javascripts/packages/details/components/app.vue' do + element :delete_button + element :delete_modal_button + element :package_information_content + end + + def has_package_info?(name, version) + has_element?(:package_information_content, text: /#{name}.*#{version}/) + end + + def click_delete + click_element(:delete_button) + wait_for_animated_element(:delete_modal_button) + click_element(:delete_modal_button) + end + end + end + end + end +end diff --git a/qa/qa/page/project/snippet/new.rb b/qa/qa/page/project/snippet/new.rb index 7431d6c1bf8..47200ba5fda 100644 --- a/qa/qa/page/project/snippet/new.rb +++ b/qa/qa/page/project/snippet/new.rb @@ -14,6 +14,7 @@ module QA def click_create_first_snippet finished_loading? + # The svg takes a fraction of a second to load after which the # "New snippet" button shifts up a bit. This can cause # webdriver to miss the hit so we wait for the svg to load before diff --git a/qa/qa/page/project/sub_menus/packages.rb b/qa/qa/page/project/sub_menus/packages.rb new file mode 100644 index 00000000000..9ea045a99f5 --- /dev/null +++ b/qa/qa/page/project/sub_menus/packages.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module QA + module Page + module Project + module SubMenus + module Packages + extend QA::Page::PageConcern + + def self.included(base) + super + + base.class_eval do + view 'app/views/layouts/nav/sidebar/_project_packages_link.html.haml' do + element :packages_link + end + end + end + + def click_packages_link + within_sidebar do + click_element :packages_link + end + end + end + end + end + end +end diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb index b46d2d32f1f..faa3f2cf595 100644 --- a/qa/qa/page/project/web_ide/edit.rb +++ b/qa/qa/page/project/web_ide/edit.rb @@ -136,7 +136,6 @@ module QA end def create_first_file(file_name) - finished_loading? click_element(:first_file_button, Page::Component::WebIDE::Modal::CreateNewFile) fill_element(:file_name_field, file_name) click_button('Create file') diff --git a/qa/qa/page/settings/common.rb b/qa/qa/page/settings/common.rb index 6989e8125d3..f5d13cbbabe 100644 --- a/qa/qa/page/settings/common.rb +++ b/qa/qa/page/settings/common.rb @@ -14,7 +14,6 @@ module QA click_button 'Expand' unless has_css?('button', text: 'Collapse', wait: 1) has_content?('Collapse') - finished_loading? end yield if block_given? diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb index e41024e5d14..91fd2579fcd 100644 --- a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb +++ b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb @@ -19,7 +19,7 @@ module QA end end - it 'closes an issue' do + it 'closes an issue', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/225303', type: :bug } do closed_issue.visit! Page::Project::Issue::Show.perform do |issue_page| 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 new file mode 100644 index 00000000000..19003614f1a --- /dev/null +++ b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Package', :docker, :orchestrated, :packages do + describe 'Maven Repository' do + include Runtime::Fixtures + + let(:group_id) { 'com.gitlab.qa' } + let(:artifact_id) { 'maven' } + let(:package_name) { "#{group_id}/#{artifact_id}".tr('.', '/') } + let(:auth_token) do + unless Page::Main::Menu.perform(&:signed_in?) + Flow::Login.sign_in + end + + Resource::PersonalAccessToken.fabricate!.access_token + end + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'maven-package-project' + end + end + + it 'publishes a maven package and deletes it' do + uri = URI.parse(Runtime::Scenario.gitlab_address) + gitlab_address_with_port = "#{uri.scheme}://#{uri.host}:#{uri.port}" + pom_xml = { + file_path: 'pom.xml', + content: <<~XML + <project> + <groupId>#{group_id}</groupId> + <artifactId>#{artifact_id}</artifactId> + <version>1.0</version> + <modelVersion>4.0.0</modelVersion> + <repositories> + <repository> + <id>#{project.name}</id> + <url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url> + </repository> + </repositories> + <distributionManagement> + <repository> + <id>#{project.name}</id> + <url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url> + </repository> + <snapshotRepository> + <id>#{project.name}</id> + <url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url> + </snapshotRepository> + </distributionManagement> + </project> + XML + } + settings_xml = { + file_path: 'settings.xml', + content: <<~XML + <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> + <servers> + <server> + <id>#{project.name}</id> + <configuration> + <httpHeaders> + <property> + <name>Private-Token</name> + <value>#{auth_token}</value> + </property> + </httpHeaders> + </configuration> + </server> + </servers> + </settings> + XML + } + + # Use a maven docker container to deploy the package + with_fixtures([pom_xml, settings_xml]) do |dir| + Service::DockerRun::Maven.new(dir).publish! + end + + project.visit! + Page::Project::Menu.perform(&:click_packages_link) + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_package(package_name) + + index.click_package(package_name) + end + + Page::Project::Packages::Show.perform do |show| + expect(show).to have_package_info(package_name, "1.0") + + show.click_delete + end + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_content("Package was removed") + expect(index).to have_no_package(package_name) + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb new file mode 100644 index 00000000000..1118ab02fe8 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Package', :docker, :orchestrated, :packages do + describe 'NPM registry' do + include Runtime::Fixtures + + let(:registry_scope) { project.group.sandbox.path } + let(:package_name) { "@#{registry_scope}/#{project.name}" } + let(:auth_token) do + unless Page::Main::Menu.perform(&:signed_in?) + Flow::Login.sign_in + end + + Resource::PersonalAccessToken.fabricate!.access_token + end + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'npm-registry-project' + end + end + + it 'publishes an npm package and then deletes it' do + uri = URI.parse(Runtime::Scenario.gitlab_address) + gitlab_host_with_port = "#{uri.host}:#{uri.port}" + gitlab_address_with_port = "#{uri.scheme}://#{uri.host}:#{uri.port}" + package_json = { + file_path: 'package.json', + content: <<~JSON + { + "name": "#{package_name}", + "version": "1.0.0", + "description": "Example package for GitLab NPM registry", + "publishConfig": { + "@#{registry_scope}:registry": "#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/npm/" + } + } + JSON + } + npmrc = { + file_path: '.npmrc', + content: <<~NPMRC + //#{gitlab_host_with_port}/api/v4/projects/#{project.id}/packages/npm/:_authToken=#{auth_token} + //#{gitlab_host_with_port}/api/v4/packages/npm/:_authToken=#{auth_token} + @#{registry_scope}:registry=#{gitlab_address_with_port}/api/v4/packages/npm/ + NPMRC + } + + # Use a node docker container to publish the package + with_fixtures([npmrc, package_json]) do |dir| + Service::DockerRun::NodeJs.new(dir).publish! + end + + project.visit! + Page::Project::Menu.perform(&:click_packages_link) + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_package(package_name) + + index.click_package(package_name) + end + + Page::Project::Packages::Show.perform do |show| + expect(show).to have_package_info(package_name, "1.0.0") + + show.click_delete + end + + Page::Project::Packages::Index.perform do |index| + expect(index).to have_content("Package was removed") + expect(index).to have_no_package(package_name) + end + end + end + end +end diff --git a/qa/qa/support/page/logging.rb b/qa/qa/support/page/logging.rb index 281e1b85cc3..36056029abe 100644 --- a/qa/qa/support/page/logging.rb +++ b/qa/qa/support/page/logging.rb @@ -120,7 +120,7 @@ module QA found end - def finished_loading? + def finished_loading?(wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME) log('waiting for loading to complete...') now = Time.now diff --git a/qa/qa/support/wait_for_requests.rb b/qa/qa/support/wait_for_requests.rb index c58882a11ea..d2451b6c6e5 100644 --- a/qa/qa/support/wait_for_requests.rb +++ b/qa/qa/support/wait_for_requests.rb @@ -5,9 +5,11 @@ module QA module WaitForRequests module_function - def wait_for_requests + DEFAULT_MAX_WAIT_TIME = 60 + + def wait_for_requests(skip_finished_loading_check: false) Waiter.wait_until(log: false) do - finished_all_ajax_requests? && finished_all_axios_requests? + finished_all_ajax_requests? && finished_all_axios_requests? && (!skip_finished_loading_check ? finished_loading?(wait: 1) : true) end end @@ -20,6 +22,13 @@ module QA Capybara.page.evaluate_script('jQuery.active').zero? end + + def finished_loading?(wait: DEFAULT_MAX_WAIT_TIME) + # The number of selectors should be able to be reduced after + # migration to the new spinner is complete. + # https://gitlab.com/groups/gitlab-org/-/epics/956 + Capybara.page.has_no_css?('.gl-spinner, .fa-spinner, .spinner', wait: wait) + end end end end diff --git a/qa/spec/support/wait_for_requests_spec.rb b/qa/spec/support/wait_for_requests_spec.rb new file mode 100644 index 00000000000..79ee3eb5099 --- /dev/null +++ b/qa/spec/support/wait_for_requests_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +describe QA::Support::WaitForRequests do + describe '.wait_for_requests' do + before do + allow(subject).to receive(:finished_all_axios_requests?).and_return(true) + allow(subject).to receive(:finished_all_ajax_requests?).and_return(true) + allow(subject).to receive(:finished_loading?).and_return(true) + end + + context 'when skip_finished_loading_check is defaulted to false' do + it 'calls finished_loading?' do + expect(subject).to receive(:finished_loading?).with(hash_including(wait: 1)) + + subject.wait_for_requests + end + end + + context 'when skip_finished_loading_check is true' do + it 'does not call finished_loading?' do + expect(subject).not_to receive(:finished_loading?) + + subject.wait_for_requests(skip_finished_loading_check: true) + end + end + end +end |