Commit 2aec0058 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-shl-wait-for-load-in-wait-for-spinner' into 'master'

Move `finished_loading?` to `wait_for_requests`

See merge request gitlab-org/gitlab!35505
parents c4079d30 6a2a9b1c
......@@ -178,7 +178,6 @@ module QA
def has_vulnerability_report?(timeout: 60)
wait_until(reload: true, max_duration: timeout, sleep_interval: 1) do
finished_loading?
has_element?(:vulnerability_report_grouped, wait: 10)
end
find_element(:vulnerability_report_grouped).has_no_content?("is loading")
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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')
......
......@@ -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?
......
......@@ -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|
......
......@@ -41,7 +41,7 @@ module QA
Page::Group::Menu.perform(&:click_contribution_analytics_item)
end
it 'tests contributions' do
it 'tests contributions', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/225303', type: :bug } do
EE::Page::Group::ContributionAnalytics.perform do |contribution_analytics|
expect(contribution_analytics).to have_push_element('3 pushes, more than 4.0 commits by 1 person contributors.')
expect(contribution_analytics).to have_mr_element('1 created, 1 merged.')
......
......@@ -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
......
......@@ -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
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment