diff options
Diffstat (limited to 'qa/qa/page')
-rw-r--r-- | qa/qa/page/admin/overview/users/show.rb | 10 | ||||
-rw-r--r-- | qa/qa/page/admin/settings/component/outbound_requests.rb | 33 | ||||
-rw-r--r-- | qa/qa/page/admin/settings/network.rb | 7 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 52 | ||||
-rw-r--r-- | qa/qa/page/component/select2.rb | 8 | ||||
-rw-r--r-- | qa/qa/page/dashboard/projects.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/dashboard/welcome.rb | 17 | ||||
-rw-r--r-- | qa/qa/page/element.rb | 10 | ||||
-rw-r--r-- | qa/qa/page/file/shared/commit_button.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/group/show.rb | 10 | ||||
-rw-r--r-- | qa/qa/page/main/menu.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/issue/index.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/project/issue/show.rb | 14 | ||||
-rw-r--r-- | qa/qa/page/project/pipeline/index.rb | 12 | ||||
-rw-r--r-- | qa/qa/page/project/settings/ci_cd.rb | 2 | ||||
-rw-r--r-- | qa/qa/page/project/sub_menus/settings.rb | 9 |
16 files changed, 189 insertions, 9 deletions
diff --git a/qa/qa/page/admin/overview/users/show.rb b/qa/qa/page/admin/overview/users/show.rb index 11ea7bcabc8..f15ef0492fc 100644 --- a/qa/qa/page/admin/overview/users/show.rb +++ b/qa/qa/page/admin/overview/users/show.rb @@ -10,9 +10,19 @@ module QA element :impersonate_user_link end + view 'app/views/admin/users/show.html.haml' do + element :confirm_user_button + end + def click_impersonate_user click_element(:impersonate_user_link) end + + def confirm_user + accept_confirm do + click_element :confirm_user_button + end + end end end end diff --git a/qa/qa/page/admin/settings/component/outbound_requests.rb b/qa/qa/page/admin/settings/component/outbound_requests.rb new file mode 100644 index 00000000000..248ea5b6715 --- /dev/null +++ b/qa/qa/page/admin/settings/component/outbound_requests.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module QA + module Page + module Admin + module Settings + module Component + class OutboundRequests < Page::Base + view 'app/views/admin/application_settings/_outbound.html.haml' do + element :allow_requests_from_services_checkbox + element :save_changes_button + end + + def allow_requests_to_local_network_from_services + check_allow_requests_to_local_network_from_services_checkbox + click_save_changes_button + end + + private + + def check_allow_requests_to_local_network_from_services_checkbox + check_element :allow_requests_from_services_checkbox + end + + def click_save_changes_button + click_element :save_changes_button + end + end + end + end + end + end +end diff --git a/qa/qa/page/admin/settings/network.rb b/qa/qa/page/admin/settings/network.rb index fdb8fcda281..83566d3d1ca 100644 --- a/qa/qa/page/admin/settings/network.rb +++ b/qa/qa/page/admin/settings/network.rb @@ -9,6 +9,7 @@ module QA view 'app/views/admin/application_settings/network.html.haml' do element :ip_limits_section + element :outbound_requests_section end def expand_ip_limits(&block) @@ -16,6 +17,12 @@ module QA Component::IpLimits.perform(&block) end end + + def expand_outbound_requests(&block) + expand_section(:outbound_requests_section) do + Component::OutboundRequests.perform(&block) + end + end end end end diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index 71df90f2f42..ed4d33dc7a3 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -111,12 +111,18 @@ module QA element.select value end - def has_element?(name, text: nil, wait: Capybara.default_max_wait_time) - has_css?(element_selector_css(name), wait: wait, text: text) + def has_element?(name, **kwargs) + wait = kwargs[:wait] ? kwargs[:wait] && kwargs.delete(:wait) : Capybara.default_max_wait_time + text = kwargs[:text] ? kwargs[:text] && kwargs.delete(:text) : nil + + has_css?(element_selector_css(name, kwargs), text: text, wait: wait) end - def has_no_element?(name, text: nil, wait: Capybara.default_max_wait_time) - has_no_css?(element_selector_css(name), wait: wait, text: text) + def has_no_element?(name, **kwargs) + wait = kwargs[:wait] ? kwargs[:wait] && kwargs.delete(:wait) : Capybara.default_max_wait_time + text = kwargs[:text] ? kwargs[:text] && kwargs.delete(:text) : nil + + has_no_css?(element_selector_css(name, kwargs), wait: wait, text: text) end def has_text?(text) @@ -135,6 +141,40 @@ module QA has_no_css?('.fa-spinner.block-loading', wait: Capybara.default_max_wait_time) end + def has_loaded_all_images? + # I don't know of a foolproof way to wait for all images to load + # This loop gives time for the img tags to be rendered and for + # images to start loading. + previous_total_images = 0 + wait(interval: 1) do + current_total_images = all("img").size + result = previous_total_images == current_total_images + previous_total_images = current_total_images + result + end + + # Retry until all images found can be fetched via HTTP, and + # check that the image has a non-zero natural width (a broken + # img tag could have a width, but wouldn't have a natural width) + + # Unfortunately, this doesn't account for SVGs. They're rendered + # as HTML, so there doesn't seem to be a way to check that they + # display properly via Selenium. However, if the SVG couldn't be + # rendered (e.g., because the file doesn't exist), the whole page + # won't display properly, so we should catch that with the test + # this method is called from. + + # The user's avatar is an img, which could be a gravatar image, + # so we skip that by only checking for images hosted internally + retry_until(sleep_interval: 1) do + all("img").all? do |image| + next true unless URI(image['src']).host == URI(page.current_url).host + + asset_exists?(image['src']) && image['naturalWidth'].to_i > 0 + end + end + end + def wait_for_animated_element(name) # It would be ideal if we could detect when the animation is complete # but in some cases there's nothing we can easily access via capybara @@ -165,8 +205,8 @@ module QA scroll_to(element_selector_css(name), *args) end - def element_selector_css(name) - Page::Element.new(name).selector_css + def element_selector_css(name, *attributes) + Page::Element.new(name, *attributes).selector_css end def click_link_with_text(text) diff --git a/qa/qa/page/component/select2.rb b/qa/qa/page/component/select2.rb index d05c44d22b2..8fe6a4a75b3 100644 --- a/qa/qa/page/component/select2.rb +++ b/qa/qa/page/component/select2.rb @@ -20,12 +20,20 @@ module QA def search_and_select(item_text) find('.select2-input').set(item_text) + + wait_for_search_to_complete + select_item(item_text) end def expand_select_list find('span.select2-arrow').click end + + def wait_for_search_to_complete + has_css?('.select2-active') + has_no_css?('.select2-active', wait: 30) + end end end end diff --git a/qa/qa/page/dashboard/projects.rb b/qa/qa/page/dashboard/projects.rb index 378ac793f7b..c103bc26a36 100644 --- a/qa/qa/page/dashboard/projects.rb +++ b/qa/qa/page/dashboard/projects.rb @@ -18,6 +18,10 @@ module QA '/' end + def clear_project_filter + fill_element(:project_filter_form, "") + end + private def filter_by_name(name) diff --git a/qa/qa/page/dashboard/welcome.rb b/qa/qa/page/dashboard/welcome.rb new file mode 100644 index 00000000000..b54205780d9 --- /dev/null +++ b/qa/qa/page/dashboard/welcome.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module QA + module Page + module Dashboard + class Welcome < Page::Base + view 'app/views/dashboard/projects/_zero_authorized_projects.html.haml' do + element :welcome_title_content + end + + def has_welcome_title?(text) + has_element?(:welcome_title_content, text: text) + end + end + end + end +end diff --git a/qa/qa/page/element.rb b/qa/qa/page/element.rb index 9e6fd2fdd4f..6bfdf98587b 100644 --- a/qa/qa/page/element.rb +++ b/qa/qa/page/element.rb @@ -28,7 +28,7 @@ module QA end def selector_css - %Q([data-qa-selector="#{@name}"],.#{selector}) + %Q([data-qa-selector="#{@name}"]#{additional_selectors},.#{selector}) end def expression @@ -42,6 +42,14 @@ module QA def matches?(line) !!(line =~ /["']#{name}['"]|#{expression}/) end + + private + + def additional_selectors + @attributes.dup.delete_if { |attr| attr == :pattern || attr == :required }.map do |key, value| + %Q([data-qa-#{key.to_s.tr('_', '-')}="#{value}"]) + end.join + end end end end diff --git a/qa/qa/page/file/shared/commit_button.rb b/qa/qa/page/file/shared/commit_button.rb index d8e751dd7b6..559b4c6ceea 100644 --- a/qa/qa/page/file/shared/commit_button.rb +++ b/qa/qa/page/file/shared/commit_button.rb @@ -13,6 +13,10 @@ module QA def commit_changes click_element(:commit_button) + + wait(reload: false, max: 60) do + finished_loading? + end end end end diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb index d4c4be0d6ca..e1f319da134 100644 --- a/qa/qa/page/group/show.rb +++ b/qa/qa/page/group/show.rb @@ -18,6 +18,10 @@ module QA element :no_result_text, 'No groups or projects matched your search' # rubocop:disable QA/ElementWithPattern end + view 'app/views/shared/members/_access_request_links.html.haml' do + element :leave_group_link + end + def click_subgroup(name) click_link name end @@ -42,6 +46,12 @@ module QA click_element :new_in_group_button end + def leave_group + accept_alert do + click_element :leave_group_link + end + end + private def select_kind(kind) diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 024f56db8e2..49c48568e68 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -20,7 +20,7 @@ module QA element :admin_area_link element :projects_dropdown, required: true element :groups_dropdown, required: true - element :more_dropdown, required: true + element :more_dropdown element :snippets_link end diff --git a/qa/qa/page/project/issue/index.rb b/qa/qa/page/project/issue/index.rb index befee25b37a..a6ccee4353b 100644 --- a/qa/qa/page/project/issue/index.rb +++ b/qa/qa/page/project/issue/index.rb @@ -36,6 +36,10 @@ module QA def click_closed_issues_link click_element :closed_issues_link end + + def has_issue?(issue) + has_element? :issue, issue_title: issue.to_s + end end end end diff --git a/qa/qa/page/project/issue/show.rb b/qa/qa/page/project/issue/show.rb index d2732eb7dd2..6ec80b7c9cc 100644 --- a/qa/qa/page/project/issue/show.rb +++ b/qa/qa/page/project/issue/show.rb @@ -108,6 +108,10 @@ module QA find_element(:more_assignees_link) end + def noteable_note_item + find_element(:noteable_note_item) + end + def select_all_activities_filter select_filter_with_text('Show all activity') end @@ -161,7 +165,15 @@ module QA def select_user(username) find("#{element_selector_css(:assignee_block)} input").set(username) - find('.dropdown-menu-user-link', text: "@#{username}").click + + dropdown_menu_user_link_selector = '.dropdown-menu-user-link' + at_username = "@#{username}" + ten_seconds = 10 + + wait(reload: false, max: ten_seconds, interval: 1) do + has_css?(dropdown_menu_user_link_selector, wait: ten_seconds, text: at_username) + end + find(dropdown_menu_user_link_selector, text: at_username).click end def wait_assignees_block_finish_loading diff --git a/qa/qa/page/project/pipeline/index.rb b/qa/qa/page/project/pipeline/index.rb index fae7818f871..b52f3e99a36 100644 --- a/qa/qa/page/project/pipeline/index.rb +++ b/qa/qa/page/project/pipeline/index.rb @@ -7,6 +7,10 @@ module QA::Page element :pipeline_link, 'class="js-pipeline-url-link' # rubocop:disable QA/ElementWithPattern end + view 'app/assets/javascripts/pipelines/components/pipelines_table_row.vue' do + element :pipeline_commit_status + end + def click_on_latest_pipeline css = '.js-pipeline-url-link' @@ -16,6 +20,14 @@ module QA::Page link.click end + + def wait_for_latest_pipeline_success + wait(reload: false, max: 300) do + within_element_by_index(:pipeline_commit_status, 0) do + has_text?('passed') + end + end + end end end end diff --git a/qa/qa/page/project/settings/ci_cd.rb b/qa/qa/page/project/settings/ci_cd.rb index 45040cf4660..46f93fad61e 100644 --- a/qa/qa/page/project/settings/ci_cd.rb +++ b/qa/qa/page/project/settings/ci_cd.rb @@ -35,3 +35,5 @@ module QA end end end + +QA::Page::Project::Settings::CICD.prepend_if_ee('QA::EE::Page::Project::Settings::CICD') diff --git a/qa/qa/page/project/sub_menus/settings.rb b/qa/qa/page/project/sub_menus/settings.rb index 1cd39fcff58..8be442ba35d 100644 --- a/qa/qa/page/project/sub_menus/settings.rb +++ b/qa/qa/page/project/sub_menus/settings.rb @@ -13,6 +13,7 @@ module QA element :settings_item element :link_members_settings element :general_settings_link + element :integrations_settings_link end end end @@ -55,6 +56,14 @@ module QA end end + def go_to_integrations_settings + hover_settings do + within_submenu do + click_element :integrations_settings_link + end + end + end + private def hover_settings |