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 ...@@ -178,7 +178,6 @@ module QA
def has_vulnerability_report?(timeout: 60) def has_vulnerability_report?(timeout: 60)
wait_until(reload: true, max_duration: timeout, sleep_interval: 1) do wait_until(reload: true, max_duration: timeout, sleep_interval: 1) do
finished_loading?
has_element?(:vulnerability_report_grouped, wait: 10) has_element?(:vulnerability_report_grouped, wait: 10)
end end
find_element(:vulnerability_report_grouped).has_no_content?("is loading") find_element(:vulnerability_report_grouped).has_no_content?("is loading")
......
...@@ -169,7 +169,7 @@ module QA ...@@ -169,7 +169,7 @@ module QA
end end
def has_element?(name, **kwargs) 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) disabled = kwargs.delete(:disabled)
...@@ -209,15 +209,6 @@ module QA ...@@ -209,15 +209,6 @@ module QA
has_text?(text.gsub(/\s+/, " "), wait: wait) has_text?(text.gsub(/\s+/, " "), wait: wait)
end 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? def finished_loading_block?
wait_for_requests wait_for_requests
......
...@@ -55,12 +55,10 @@ module QA ...@@ -55,12 +55,10 @@ module QA
end end
def fill_file_name(name) def fill_file_name(name)
finished_loading?
fill_element :file_name_field, name fill_element :file_name_field, name
end end
def fill_file_content(content) def fill_file_content(content)
finished_loading?
text_area.set content text_area.set content
end end
......
...@@ -100,19 +100,16 @@ module QA ...@@ -100,19 +100,16 @@ module QA
end end
def has_file_content?(file_content) def has_file_content?(file_content)
finished_loading?
within_element(:file_content) do within_element(:file_content) do
has_text?(file_content) has_text?(file_content)
end end
end end
def click_edit_button def click_edit_button
finished_loading?
click_element(:snippet_action_button, action: 'Edit') click_element(:snippet_action_button, action: 'Edit')
end end
def click_delete_button def click_delete_button
finished_loading?
click_element(:snippet_action_button, action: 'Delete') click_element(:snippet_action_button, action: 'Delete')
click_element(:delete_snippet_button) click_element(:delete_snippet_button)
# wait for the page to reload after deletion # wait for the page to reload after deletion
...@@ -123,32 +120,27 @@ module QA ...@@ -123,32 +120,27 @@ module QA
end end
def get_repository_uri_http def get_repository_uri_http
finished_loading?
click_element(:clone_button) click_element(:clone_button)
Git::Location.new(find_element(:copy_http_url_button)['data-clipboard-text']).uri.to_s Git::Location.new(find_element(:copy_http_url_button)['data-clipboard-text']).uri.to_s
end end
def get_repository_uri_ssh def get_repository_uri_ssh
finished_loading?
click_element(:clone_button) click_element(:clone_button)
Git::Location.new(find_element(:copy_ssh_url_button)['data-clipboard-text']).uri.to_s Git::Location.new(find_element(:copy_ssh_url_button)['data-clipboard-text']).uri.to_s
end end
def add_comment(comment) def add_comment(comment)
finished_loading?
fill_element(:note_field, comment) fill_element(:note_field, comment)
click_element(:comment_button) click_element(:comment_button)
end end
def has_comment_author?(author_username) def has_comment_author?(author_username)
finished_loading?
within_element(:note_author_content) do within_element(:note_author_content) do
has_text?('@' + author_username) has_text?('@' + author_username)
end end
end end
def has_comment_content?(comment_content) def has_comment_content?(comment_content)
finished_loading?
within_element(:note_content) do within_element(:note_content) do
has_text?(comment_content) has_text?(comment_content)
end end
...@@ -161,14 +153,12 @@ module QA ...@@ -161,14 +153,12 @@ module QA
end end
def edit_comment(comment) def edit_comment(comment)
finished_loading?
click_element(:edit_comment_button) click_element(:edit_comment_button)
fill_element(:edit_note_field, comment) fill_element(:edit_note_field, comment)
click_element(:save_comment_button) click_element(:save_comment_button)
end end
def delete_comment(comment) def delete_comment(comment)
finished_loading?
click_element(:more_actions_dropdown) click_element(:more_actions_dropdown)
accept_alert do accept_alert do
click_element(:delete_comment_button) click_element(:delete_comment_button)
......
...@@ -275,7 +275,7 @@ module QA ...@@ -275,7 +275,7 @@ module QA
end end
def wait_for_loading def wait_for_loading
finished_loading? && has_no_element?(:skeleton_note) has_no_element?(:skeleton_note)
end end
def click_open_in_web_ide def click_open_in_web_ide
......
...@@ -56,7 +56,7 @@ module QA ...@@ -56,7 +56,7 @@ module QA
def await_installed(application_name) def await_installed(application_name)
within_element(application_name) do 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
end end
......
...@@ -14,6 +14,7 @@ module QA ...@@ -14,6 +14,7 @@ module QA
def click_create_first_snippet def click_create_first_snippet
finished_loading? finished_loading?
# The svg takes a fraction of a second to load after which the # The svg takes a fraction of a second to load after which the
# "New snippet" button shifts up a bit. This can cause # "New snippet" button shifts up a bit. This can cause
# webdriver to miss the hit so we wait for the svg to load before # webdriver to miss the hit so we wait for the svg to load before
......
...@@ -136,7 +136,6 @@ module QA ...@@ -136,7 +136,6 @@ module QA
end end
def create_first_file(file_name) def create_first_file(file_name)
finished_loading?
click_element(:first_file_button, Page::Component::WebIDE::Modal::CreateNewFile) click_element(:first_file_button, Page::Component::WebIDE::Modal::CreateNewFile)
fill_element(:file_name_field, file_name) fill_element(:file_name_field, file_name)
click_button('Create file') click_button('Create file')
......
...@@ -14,7 +14,6 @@ module QA ...@@ -14,7 +14,6 @@ module QA
click_button 'Expand' unless has_css?('button', text: 'Collapse', wait: 1) click_button 'Expand' unless has_css?('button', text: 'Collapse', wait: 1)
has_content?('Collapse') has_content?('Collapse')
finished_loading?
end end
yield if block_given? yield if block_given?
......
...@@ -19,7 +19,7 @@ module QA ...@@ -19,7 +19,7 @@ module QA
end end
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! closed_issue.visit!
Page::Project::Issue::Show.perform do |issue_page| Page::Project::Issue::Show.perform do |issue_page|
......
...@@ -41,7 +41,7 @@ module QA ...@@ -41,7 +41,7 @@ module QA
Page::Group::Menu.perform(&:click_contribution_analytics_item) Page::Group::Menu.perform(&:click_contribution_analytics_item)
end 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| 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_push_element('3 pushes, more than 4.0 commits by 1 person contributors.')
expect(contribution_analytics).to have_mr_element('1 created, 1 merged.') expect(contribution_analytics).to have_mr_element('1 created, 1 merged.')
......
...@@ -120,7 +120,7 @@ module QA ...@@ -120,7 +120,7 @@ module QA
found found
end end
def finished_loading? def finished_loading?(wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME)
log('waiting for loading to complete...') log('waiting for loading to complete...')
now = Time.now now = Time.now
......
...@@ -5,9 +5,11 @@ module QA ...@@ -5,9 +5,11 @@ module QA
module WaitForRequests module WaitForRequests
module_function 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 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
end end
...@@ -20,6 +22,13 @@ module QA ...@@ -20,6 +22,13 @@ module QA
Capybara.page.evaluate_script('jQuery.active').zero? Capybara.page.evaluate_script('jQuery.active').zero?
end 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 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