Commit 043aacf1 authored by Walmyr Lima e Silva Filho's avatar Walmyr Lima e Silva Filho

Merge branch 'qa-gitlab-insights-spec' into 'master'

Add GitLab Insights e2e tests

See merge request gitlab-org/gitlab-ee!15295
parents 803e5d02 af47c716
......@@ -64,6 +64,7 @@ export default {
<div v-else-if="configPresent" class="insights-wrapper">
<gl-dropdown
class="js-insights-dropdown col-8 col-md-9 gl-pr-0"
data-qa-selector="insights_dashboard_dropdown"
menu-class="w-100 mw-100"
toggle-class="dropdown-menu-toggle w-100 gl-field-error-outline"
:text="__('Select Page')"
......
......@@ -90,10 +90,10 @@ export default {
};
</script>
<template>
<div class="insights-page">
<div class="insights-page" data-qa-selector="insights_page">
<div v-if="hasChartsConfigured" class="js-insights-page-container">
<h4 class="text-center">{{ pageConfig.title }}</h4>
<div v-if="!pageLoading" class="insights-charts">
<div v-if="!pageLoading" class="insights-charts" data-qa-selector="insights_charts">
<div v-for="(insights, key, index) in chartData" :key="index" class="insights-chart">
<component
:is="chartType(insights.type)"
......
- return unless group_sidebar_link?(:group_insights)
= nav_link(path: 'groups/insights#show') do
= link_to group_insights_path(@group), title: _('Insights'), class: 'shortcuts-group-insights' do
= link_to group_insights_path(@group), title: _('Insights'), class: 'shortcuts-group-insights', data: { qa_selector: 'group_insights_link' } do
%span= _('Insights')
- return unless project_nav_tab?(:project_insights)
= nav_link(path: 'projects/insights#show') do
= link_to project_insights_path(@project), title: _('Insights'), class: 'shortcuts-project-insights' do
= link_to project_insights_path(@project), title: _('Insights'), class: 'shortcuts-project-insights', data: { qa_selector: 'project_insights_link' } do
%span= _('Insights')
......@@ -64,6 +64,7 @@ module QA
module Project
autoload :New, 'qa/ee/page/project/new'
autoload :Show, 'qa/ee/page/project/show'
autoload :Menu, 'qa/ee/page/project/menu'
module SubMenus
autoload :SecurityCompliance, 'qa/ee/page/project/sub_menus/security_compliance'
......@@ -119,6 +120,10 @@ module QA
autoload :Show, 'qa/ee/page/group/secure/show'
end
end
module Insights
autoload :Show, 'qa/ee/page/insights/show'
end
end
module Resource
......
......@@ -25,6 +25,10 @@ module QA
element :security_dashboard_link
end
view 'ee/app/views/layouts/nav/_group_insights_link.html.haml' do
element :group_insights_link
end
def go_to_saml_sso_group_settings
hover_settings do
within_submenu do
......@@ -41,6 +45,12 @@ module QA
end
end
def click_group_insights_link
within_sidebar do
click_element(:group_insights_link)
end
end
def click_group_members_item
within_sidebar do
click_element(:group_members_item)
......
# frozen_string_literal: true
module QA
module EE
module Page
module Insights
class Show < QA::Page::Base
view 'ee/app/assets/javascripts/insights/components/insights.vue' do
element :insights_dashboard_dropdown
end
view 'ee/app/assets/javascripts/insights/components/insights_page.vue' do
element :insights_charts
element :insights_page
end
def wait_for_insight_charts_to_load
wait(reload: false) do
has_element?(:insights_charts)
end
end
def select_insights_dashboard(title)
click_element :insights_dashboard_dropdown
within_insights_dropdown do
has_text?(title)
click_on title
end
wait_for_insight_charts_to_load
end
def has_insights_dashboard_title?(title)
within_insights_page do
has_text?(title)
end
end
def within_insights_dropdown
within_element :insights_dashboard_dropdown do
yield
end
end
def within_insights_page
within_element :insights_page do
yield
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
class Menu < ::QA::Page::Base
include QA::Page::Project::SubMenus::Common
view 'ee/app/views/layouts/nav/_project_insights_link.html.haml' do
element :project_insights_link
end
def click_project_insights_link
within_sidebar do
click_element(:project_insights_link)
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
context 'Manage' do
shared_examples 'default insights page' do
it 'displays issues and merge requests dashboards' do
EE::Page::Insights::Show.perform do |show|
show.wait_for_insight_charts_to_load
expect(show).to have_insights_dashboard_title('Issues Dashboard')
show.select_insights_dashboard('Merge Requests Dashboard')
expect(show).to have_insights_dashboard_title('Merge Requests Dashboard')
end
end
end
before(:all) do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
end
context 'group insights page' do
before do
group = Resource::Group.fabricate_via_api!
group.visit!
EE::Page::Group::Menu.perform(&:click_group_insights_link)
end
it_behaves_like 'default insights page'
end
context 'project insights page' do
before do
project = Resource::Project.fabricate_via_api! do |project|
project.name = 'project-insights'
project.description = 'Project Insights'
end
project.visit!
EE::Page::Project::Menu.perform(&:click_project_insights_link)
end
it_behaves_like 'default insights page'
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