diff options
Diffstat (limited to 'qa/qa/page')
-rw-r--r-- | qa/qa/page/admin/settings/component/sign_up_restrictions.rb | 6 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 44 | ||||
-rw-r--r-- | qa/qa/page/component/snippet.rb | 42 | ||||
-rw-r--r-- | qa/qa/page/project/job/show.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/members.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/pipeline/show.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/settings/advanced.rb | 1 | ||||
-rw-r--r-- | qa/qa/page/project/web_ide/edit.rb | 49 |
8 files changed, 129 insertions, 19 deletions
diff --git a/qa/qa/page/admin/settings/component/sign_up_restrictions.rb b/qa/qa/page/admin/settings/component/sign_up_restrictions.rb index 8c5b4bf506b..9526faf4126 100644 --- a/qa/qa/page/admin/settings/component/sign_up_restrictions.rb +++ b/qa/qa/page/admin/settings/component/sign_up_restrictions.rb @@ -8,6 +8,7 @@ module QA class SignUpRestrictions < Page::Base view 'app/views/admin/application_settings/_signup.html.haml' do element :require_admin_approval_after_user_signup_checkbox + element :signup_enabled_checkbox element :save_changes_button end @@ -15,6 +16,11 @@ module QA check_element :require_admin_approval_after_user_signup_checkbox click_element :save_changes_button end + + def disable_signups + uncheck_element :signup_enabled_checkbox + click_element :save_changes_button + end end end end diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index 00b48dc7fe9..99f73bbba48 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -135,8 +135,11 @@ module QA def check_element(name) retry_until(sleep_interval: 1) do find_element(name).set(true) + checked = find_element(name).checked? - find_element(name).checked? + QA::Runtime::Logger.debug(checked ? "#{name} was checked" : "#{name} was not checked") + + checked end end @@ -185,19 +188,31 @@ module QA end def has_element?(name, **kwargs) - wait_for_requests(skip_finished_loading_check: !!kwargs.delete(:skip_finished_loading_check)) - disabled = kwargs.delete(:disabled) + original_kwargs = kwargs.dup + wait = kwargs.delete(:wait) || Capybara.default_max_wait_time + text = kwargs.delete(:text) + klass = kwargs.delete(:class) - if disabled.nil? - wait = kwargs.delete(:wait) || Capybara.default_max_wait_time - text = kwargs.delete(:text) - klass = kwargs.delete(:class) - - has_css?(element_selector_css(name, kwargs), text: text, wait: wait, class: klass) - else - find_element(name, kwargs).disabled? == disabled + try_find_element = ->(wait) do + if disabled.nil? + has_css?(element_selector_css(name, kwargs), text: text, wait: wait, class: klass) + else + find_element(name, original_kwargs).disabled? == disabled + end end + + # Check for the element before waiting for requests, just in case unrelated requests are in progress. + # This is to avoid waiting unnecessarily after the element we're interested in has already appeared. + return true if try_find_element.call(wait) + + # If the element didn't appear, wait for requests and then check again + wait_for_requests(skip_finished_loading_check: !!kwargs.delete(:skip_finished_loading_check)) + + # We only wait one second now because we previously waited the full expected duration, + # plus however long it took for requests to complete. One second should be enough + # for the UI to update after requests complete. + try_find_element.call(1) end def has_no_element?(name, **kwargs) @@ -274,8 +289,11 @@ module QA sleep 1 end - def within_element(name, text: nil) - page.within(element_selector_css(name), text: text) do + def within_element(name, **kwargs) + wait_for_requests + text = kwargs.delete(:text) + + page.within(element_selector_css(name, kwargs), text: text) do yield end end diff --git a/qa/qa/page/component/snippet.rb b/qa/qa/page/component/snippet.rb index 459c02ec883..b98c429df8c 100644 --- a/qa/qa/page/component/snippet.rb +++ b/qa/qa/page/component/snippet.rb @@ -78,6 +78,11 @@ module QA base.view 'app/assets/javascripts/snippets/components/embed_dropdown.vue' do element :copy_button end + + base.view 'app/assets/javascripts/blob/components/blob_header_default_actions.vue' do + element :default_actions_container + element :copy_contents_button + end end def has_snippet_title?(snippet_title) @@ -182,7 +187,10 @@ module QA def add_comment(comment) fill_element(:note_field, comment) click_element(:comment_button) - wait_until(reload: false) { has_element?(:note_author_content) } + + unless has_element?(:note_author_content) + raise ElementNotFound, "Comment did not appear as expected" + end end def has_comment_author?(author_username) @@ -207,7 +215,10 @@ module QA click_element(:edit_comment_button) fill_element(:edit_note_field, comment) click_element(:save_comment_button) - wait_until(reload: false) { has_element?(:note_author_content) } + + unless has_element?(:note_author_content) + raise ElementNotFound, "Comment did not appear as expected" + end end def delete_comment(comment) @@ -215,7 +226,32 @@ module QA accept_alert do click_element(:delete_comment_button) end - wait_until(reload: false) { has_no_text?(comment) } + + unless has_no_element?(:note_content, text: comment) + raise ElementNotFound, "Comment was not removed as expected" + end + end + + def click_copy_file_contents(file_number = nil) + if file_number + within_element_by_index(:default_actions_container, file_number - 1) do + click_element(:copy_contents_button) + end + else + within_element(:default_actions_container) do + click_element(:copy_contents_button) + end + end + end + + def copy_file_contents_to_comment(file_number = nil) + click_copy_file_contents(file_number) + send_keys_to_element(:note_field, [:shift, :insert]) + click_element(:comment_button) + + unless has_element?(:note_author_content) + raise ElementNotFound, "Comment did not appear as expected" + end end end end diff --git a/qa/qa/page/project/job/show.rb b/qa/qa/page/project/job/show.rb index 2ecb27e05b2..8c70d0874c4 100644 --- a/qa/qa/page/project/job/show.rb +++ b/qa/qa/page/project/job/show.rb @@ -12,7 +12,7 @@ module QA end view 'app/assets/javascripts/jobs/components/stages_dropdown.vue' do - element :pipeline_path + element :pipeline_path, required: true end view 'app/assets/javascripts/jobs/components/sidebar.vue' do diff --git a/qa/qa/page/project/members.rb b/qa/qa/page/project/members.rb index 88b05ceb1d1..447049ce22a 100644 --- a/qa/qa/page/project/members.rb +++ b/qa/qa/page/project/members.rb @@ -17,6 +17,7 @@ module QA view 'app/views/projects/project_members/index.html.haml' do element :invite_group_tab + element :groups_list_tab end view 'app/views/shared/members/_invite_group.html.haml' do @@ -48,6 +49,7 @@ module QA def remove_group(group_name) click_element :invite_group_tab + click_element :groups_list_tab page.accept_alert do within_element(:group_row, text: group_name) do click_element :delete_group_access_link diff --git a/qa/qa/page/project/pipeline/show.rb b/qa/qa/page/project/pipeline/show.rb index 7f96b896c1d..994b1c02a3d 100644 --- a/qa/qa/page/project/pipeline/show.rb +++ b/qa/qa/page/project/pipeline/show.rb @@ -77,7 +77,7 @@ module QA end def click_job(job_name) - click_element(:job_link, text: job_name) + click_element(:job_link, Project::Job::Show, text: job_name) end def expand_child_pipeline diff --git a/qa/qa/page/project/settings/advanced.rb b/qa/qa/page/project/settings/advanced.rb index 757084fc5b9..9c4b3a3c1c3 100644 --- a/qa/qa/page/project/settings/advanced.rb +++ b/qa/qa/page/project/settings/advanced.rb @@ -26,6 +26,7 @@ module QA view 'app/views/projects/_export.html.haml' do element :export_project_link element :download_export_link + element :export_project_content end def update_project_path_to(path) diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb index fc33c753230..a8b30922bd2 100644 --- a/qa/qa/page/project/web_ide/edit.rb +++ b/qa/qa/page/project/web_ide/edit.rb @@ -57,6 +57,7 @@ module QA view 'app/assets/javascripts/vue_shared/components/file_row.vue' do element :file_name_content + element :file_row_container end view 'app/assets/javascripts/ide/components/new_dropdown/index.vue' do @@ -77,9 +78,29 @@ module QA element :ide_commit_message_field end + view 'app/assets/javascripts/vue_shared/components/changed_file_icon.vue' do + element :changed_file_icon_content + end + + view 'app/assets/javascripts/vue_shared/components/content_viewer/content_viewer.vue' do + element :preview_container + end + + view 'app/assets/javascripts/vue_shared/components/content_viewer/viewers/download_viewer.vue' do + element :download_button + end + + view 'app/assets/javascripts/vue_shared/components/content_viewer/viewers/image_viewer.vue' do + element :image_viewer_container + end + + view 'app/assets/javascripts/ide/components/new_dropdown/upload.vue' do + element :file_upload_field + end + def has_file?(file_name) within_element(:file_list) do - page.has_content? file_name + has_text?(file_name) end end @@ -87,6 +108,26 @@ module QA has_element?(:project_path_content, project_path: project_path) end + def has_file_addition_icon?(file_name) + within_element(:file_row_container, file_name: file_name) do + has_element?(:changed_file_icon_content, title: 'Added') + end + end + + def has_download_button?(file_name) + click_element(:file_row_container, file_name: file_name) + within_element(:preview_container) do + has_element?(:download_button) + end + end + + def has_image_viewer?(file_name) + click_element(:file_row_container, file_name: file_name) + within_element(:preview_container) do + has_element?(:image_viewer_container) + end + end + def go_to_project click_element(:project_path_content, Page::Project::Show) end @@ -212,6 +253,12 @@ module QA has_element?(:file_list) end end + + def upload_file(file_path) + within_element(:file_list) do + find_element(:file_upload_field, visible: false).send_keys(file_path) + end + end end end end |