summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-04-15 14:04:40 +0100
committerSean McGivern <sean@gitlab.com>2019-04-16 14:33:06 +0100
commitc6456830b5f9a147807b9de32c437eb6dda4c53b (patch)
tree7bb4f9f9c41f3055e9a0bcdb8732dc7fb327b146 /qa
parentca8c35285eedb0ae6e9a52fe377ec0b3ae9ada1a (diff)
downloadgitlab-ce-c6456830b5f9a147807b9de32c437eb6dda4c53b.tar.gz
Add QA tests for the performance bar60356-add-qa-tests-for-the-performance-bar
These are very high-level. Currently, they test: 1. That the performance bar appears. 2. That it has detailed metrics for Postgres and Gitaly. 3. That AJAX requests are included in the request selector.
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb3
-rw-r--r--qa/qa/page/admin/menu.rb9
-rw-r--r--qa/qa/page/admin/settings/component/performance_bar.rb27
-rw-r--r--qa/qa/page/admin/settings/metrics_and_profiling.rb23
-rw-r--r--qa/qa/page/layout/performance_bar.rb35
-rw-r--r--qa/qa/specs/features/browser_ui/non_devops/performance_bar_spec.rb34
6 files changed, 131 insertions, 0 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 672f4aa928a..f580691f952 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -275,6 +275,7 @@ module QA
module Layout
autoload :Banner, 'qa/page/layout/banner'
+ autoload :PerformanceBar, 'qa/page/layout/performance_bar'
end
module Label
@@ -293,10 +294,12 @@ module QA
module Settings
autoload :Repository, 'qa/page/admin/settings/repository'
autoload :General, 'qa/page/admin/settings/general'
+ autoload :MetricsAndProfiling, 'qa/page/admin/settings/metrics_and_profiling'
module Component
autoload :RepositoryStorage, 'qa/page/admin/settings/component/repository_storage'
autoload :AccountAndLimit, 'qa/page/admin/settings/component/account_and_limit'
+ autoload :PerformanceBar, 'qa/page/admin/settings/component/performance_bar'
end
end
end
diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/admin/menu.rb
index 25564f2dc6e..eea5717f5a7 100644
--- a/qa/qa/page/admin/menu.rb
+++ b/qa/qa/page/admin/menu.rb
@@ -10,6 +10,7 @@ module QA
element :admin_settings_item
element :admin_settings_repository_item
element :admin_settings_general_item
+ element :admin_settings_metrics_and_profiling_item
end
def go_to_repository_settings
@@ -28,6 +29,14 @@ module QA
end
end
+ def go_to_metrics_and_profiling_settings
+ hover_settings do
+ within_submenu do
+ click_element :admin_settings_metrics_and_profiling_item
+ end
+ end
+ end
+
private
def hover_settings
diff --git a/qa/qa/page/admin/settings/component/performance_bar.rb b/qa/qa/page/admin/settings/component/performance_bar.rb
new file mode 100644
index 00000000000..bc29efb64c0
--- /dev/null
+++ b/qa/qa/page/admin/settings/component/performance_bar.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module QA
+ module Page
+ module Admin
+ module Settings
+ module Component
+ class PerformanceBar < Page::Base
+ view 'app/views/admin/application_settings/_performance_bar.html.haml' do
+ element :enable_performance_bar_checkbox
+ element :save_changes_button
+ end
+
+ def enable_performance_bar
+ click_element :enable_performance_bar_checkbox
+ Capybara.current_session.driver.browser.manage.add_cookie(name: 'perf_bar_enabled', value: 'true')
+ end
+
+ def save_settings
+ click_element :save_changes_button
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/admin/settings/metrics_and_profiling.rb b/qa/qa/page/admin/settings/metrics_and_profiling.rb
new file mode 100644
index 00000000000..e10a92d7a54
--- /dev/null
+++ b/qa/qa/page/admin/settings/metrics_and_profiling.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module QA
+ module Page
+ module Admin
+ module Settings
+ class MetricsAndProfiling < Page::Base
+ include QA::Page::Settings::Common
+
+ view 'app/views/admin/application_settings/metrics_and_profiling.html.haml' do
+ element :performance_bar_settings
+ end
+
+ def expand_performance_bar(&block)
+ expand_section(:performance_bar_settings) do
+ Component::PerformanceBar.perform(&block)
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/layout/performance_bar.rb b/qa/qa/page/layout/performance_bar.rb
new file mode 100644
index 00000000000..0cfef6a5705
--- /dev/null
+++ b/qa/qa/page/layout/performance_bar.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+module QA
+ module Page
+ module Layout
+ class PerformanceBar < Page::Base
+ view 'app/assets/javascripts/performance_bar/components/performance_bar_app.vue' do
+ element :performance_bar
+ end
+
+ view 'app/assets/javascripts/performance_bar/components/detailed_metric.vue' do
+ element :performance_bar_detailed_metric
+ end
+
+ view 'app/assets/javascripts/performance_bar/components/request_selector.vue' do
+ element :performance_bar_request
+ end
+
+ def has_performance_bar?
+ has_element?(:performance_bar)
+ end
+
+ def has_detailed_metrics?
+ all_elements(:performance_bar_detailed_metric).all? do |metric|
+ metric.has_text?(%r{\d+ms / \d+})
+ end
+ end
+
+ def has_request_for?(path)
+ has_element?(:performance_bar_request, text: path)
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/specs/features/browser_ui/non_devops/performance_bar_spec.rb b/qa/qa/specs/features/browser_ui/non_devops/performance_bar_spec.rb
new file mode 100644
index 00000000000..fc4ff364fd4
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/non_devops/performance_bar_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module QA
+ context 'Performance bar' do
+ context 'when logged in as an admin user' do
+ before do
+ Runtime::Browser.visit(:gitlab, Page::Main::Login)
+ Page::Main::Login.perform(&:sign_in_using_admin_credentials)
+ Page::Main::Menu.perform(&:click_admin_area)
+ Page::Admin::Menu.perform(&:go_to_metrics_and_profiling_settings)
+
+ Page::Admin::Settings::MetricsAndProfiling.perform do |setting|
+ setting.expand_performance_bar do |page|
+ page.enable_performance_bar
+ page.save_settings
+ end
+ end
+ end
+
+ it 'shows results for the original request and AJAX requests' do
+ # Issue pages always make AJAX requests
+ Resource::Issue.fabricate! do |issue|
+ issue.title = 'Performance bar test'
+ end
+
+ Page::Layout::PerformanceBar.perform do |page|
+ expect(page).to have_performance_bar
+ expect(page).to have_detailed_metrics
+ expect(page).to have_request_for('realtime_changes') # Always requested on issue pages
+ end
+ end
+ end
+ end
+end