Commit 973c75d7 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'tmslvnkc/qa/new_test/contribution_analytics' into 'master'

Creating a test for `Contribution Analytics`

Closes gitlab-org/quality/testcases#121

See merge request gitlab-org/gitlab!19960
parents 050a97e0 e7dd1958
......@@ -155,7 +155,7 @@ export default {
{{ cherryPickLabel }}
</a>
</div>
<section class="mr-info-list">
<section class="mr-info-list" data-qa-selector="merged_status_content">
<p>
{{ s__('mrWidget|The changes were merged into') }}
<span class="label-branch">
......
......@@ -249,9 +249,10 @@ export default {
type="button"
class="btn btn-sm btn-info dropdown-toggle js-merge-moment"
data-toggle="dropdown"
data-qa-selector="merge_moment_dropdown"
:aria-label="__('Select merge moment')"
>
<i class="fa fa-chevron-down qa-merge-moment-dropdown" aria-hidden="true"></i>
<i class="fa fa-chevron-down" aria-hidden="true"></i>
</button>
<ul
v-if="shouldShowMergeImmediatelyDropdown"
......@@ -272,7 +273,8 @@ export default {
</li>
<li>
<a
class="accept-merge-request qa-merge-immediately-option"
class="accept-merge-request"
data-qa-selector="merge_immediately_option"
href="#"
@click.prevent="handleMergeButtonClick(false, true)"
>
......
......@@ -44,7 +44,7 @@
- if group_sidebar_link?(:contribution_analytics)
= nav_link(path: 'analytics#show') do
= link_to group_analytics_path(@group), title: _('Contribution Analytics'), data: { placement: 'right' } do
= link_to group_analytics_path(@group), title: _('Contribution Analytics'), data: { placement: 'right', qa_selector: 'contribution_analytics_link' } do
%span
= _('Contribution Analytics')
......
......@@ -6,7 +6,7 @@
- if is_current_user
- if can_update
= link_to "Close #{display_issuable_type}", close_issuable_path(issuable), method: button_method,
class: "d-none d-sm-none d-md-block btn btn-grouped btn-close js-btn-issue-action #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}"
class: "d-none d-sm-none d-md-block btn btn-grouped btn-close js-btn-issue-action #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}", data: { qa_selector: 'close_issue_button' }
- if can_reopen
= link_to "Reopen #{display_issuable_type}", reopen_issuable_path(issuable), method: button_method,
class: "d-none d-sm-none d-md-block btn btn-grouped btn-reopen js-btn-issue-action #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}", data: { qa_selector: 'reopen_issue_button' }
......
......@@ -20,6 +20,7 @@
.oneline
Contribution analytics for issues, merge requests and push events since #{@start_date}
%div{ data: { qa_selector: 'push_content' } }
%h3 Push
- code_push_count = @data_collector.total_push_count
- commits_count = @data_collector.total_commit_count
......@@ -35,6 +36,7 @@
.col-md-12
#js_pushes_chart_vue
%div{ data: { qa_selector: 'merge_request_content' } }
%h3 Merge Requests
- mr_created_count = @data_collector.total_merge_requests_created_count
- mr_merged_count = @data_collector.total_merge_requests_merged_count
......@@ -47,6 +49,7 @@
.col-md-12
#js_merge_requests_chart_vue
%div{ data: { qa_selector: 'issue_content' } }
%h3 Issues
- issues_created_count = @data_collector.total_issues_created_count
- issues_closed_count = @data_collector.total_issues_closed_count
......
......@@ -34,6 +34,7 @@ module QA
autoload :SamlSSOSignIn, 'qa/ee/page/group/saml_sso_sign_in'
autoload :SamlSSOSignUp, 'qa/ee/page/group/saml_sso_sign_up'
autoload :Members, 'qa/ee/page/group/members'
autoload :ContributionAnalytics, 'qa/ee/page/group/contribution_analytics'
module Settings
autoload :SamlSSO, 'qa/ee/page/group/settings/saml_sso'
......
# frozen_string_literal: true
module QA
module EE
module Page
module Group
class ContributionAnalytics < QA::Page::Base
view 'ee/app/views/groups/analytics/show.html.haml' do
element :push_content
element :merge_request_content
element :issue_content
end
def has_push_element?(text)
has_element? :push_content, text: text
end
def has_mr_element?(text)
has_element? :merge_request_content, text: text
end
def has_issue_element?(text)
has_element? :issue_content, text: text
end
end
end
end
end
end
......@@ -10,6 +10,7 @@ module QA
element :group_settings_item
element :group_members_item
element :general_settings_link
element :contribution_analytics_link
end
def click_group_members_item
......@@ -18,6 +19,12 @@ module QA
end
end
def click_group_analytics_item
within_sidebar do
click_element(:contribution_analytics_link)
end
end
def click_group_general_settings_item
hover_element(:group_settings_item) do
within_submenu(:group_sidebar_submenu) do
......
......@@ -26,7 +26,7 @@ module QA
end
view 'app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.vue' do
element :merged_status, 'The changes were merged into' # rubocop:disable QA/ElementWithPattern
element :merged_status_content
end
view 'app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue' do
......@@ -86,13 +86,31 @@ module QA
has_element?(:merge_moment_dropdown)
end
def merged?
has_element? :merged_status_content, text: 'The changes were merged into'
end
def merge_immediately
wait(reload: false, max: 60) do
has_merge_options?
end
if has_merge_options?
if has_no_element? :merge_immediately_option
retry_until do
click_element :merge_moment_dropdown
has_element? :merge_immediately_option
end
end
click_element :merge_immediately_option
else
click_element :merge_button
end
wait(reload: false, max: 60) do
merged?
end
end
def rebase!
......
......@@ -44,6 +44,7 @@ module QA
end
view 'app/views/shared/issuable/_close_reopen_button.html.haml' do
element :close_issue_button
element :reopen_issue_button
end
......@@ -84,6 +85,10 @@ module QA
click_element(:remove_related_issue_button)
end
def click_close_issue_button
click_element :close_issue_button
end
# Adds a comment to an issue
# attachment option should be an absolute path
def comment(text, attachment: nil, filter: :all_activities)
......
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Contribution Analytics' do
let(:group) do
Resource::Group.fabricate_via_api! do |group|
group.path = "contribution_analytics-#{SecureRandom.hex(8)}"
end
end
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'contribution_analytics'
project.group = group
end
end
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.project = project
end
end
let(:mr) do
Resource::MergeRequest.fabricate_via_api! do |mr|
mr.project = project
end
end
before do
Flow::Login.sign_in
issue.visit!
Page::Project::Issue::Show.perform(&:click_close_issue_button)
mr.visit!
Page::MergeRequest::Show.perform(&:merge_immediately)
group.visit!
Page::Group::Menu.perform(&:click_group_analytics_item)
end
it 'tests contributions' 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 accepted.')
expect(contribution_analytics).to have_issue_element('1 created, 1 closed.')
end
end
end
end
end
......@@ -75,9 +75,7 @@ module QA
show.merge_immediately
end
merged = Support::Retrier.retry_until(reload_page: page) do
page.has_content?('The changes were merged')
end
merged = Page::MergeRequest::Show.perform(&:merged?)
expect(merged).to be_truthy, "Expected content 'The changes were merged' but it did not appear."
end
......@@ -116,7 +114,7 @@ module QA
# automatically refresh, so we reload if the merge status
# doesn't update quickly.
merged = Support::Retrier.retry_until(reload_page: page) do
page.has_content?('The changes were merged')
Page::MergeRequest::Show.perform(&:merged?)
end
expect(merged).to be_truthy, "Expected content 'The changes were merged' but it did not appear."
......
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