Commit 79d42b37 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'sl-qa-staging-39-fix-assign-code-owners-spec' into 'master'

Fix assign code owners spec

Closes gitlab-org/quality/staging#39

See merge request gitlab-org/gitlab-ee!14685
parents 663714ca 186c79c3
- return unless @project.feature_available?(:merge_requests, current_user) - return unless @project.feature_available?(:merge_requests, current_user)
- return unless @project.feature_available?(:merge_request_approvers, current_user) - return unless @project.feature_available?(:merge_request_approvers, current_user)
%section.settings.merge-requests-feature.no-animate#js-merge-request-approval-settings{ class: [('expanded' if expanded)] } %section.qa-merge-request-approval-settings.settings.merge-requests-feature.no-animate#js-merge-request-approval-settings{ class: [('expanded' if expanded)] }
.settings-header .settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _("Merge request approvals") %h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _("Merge request approvals")
%button.btn.js-settings-toggle{ type: 'button' }= expanded ? _("Collapse") : _("Expand") %button.btn.js-settings-toggle{ type: 'button' }= expanded ? _("Collapse") : _("Expand")
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
= form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { class: "merge-request-approval-settings-form js-mr-approvals-form" }, authenticity_token: true do |f| = form_for [@project.namespace.becomes(Namespace), @project], remote: true, html: { class: "merge-request-approval-settings-form js-mr-approvals-form" }, authenticity_token: true do |f|
%input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-approval-settings' } %input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-approval-settings' }
= render 'projects/merge_request_approvals_settings_form', form: f, project: @project = render 'projects/merge_request_approvals_settings_form', form: f, project: @project
= f.submit _("Save changes"), class: "btn btn-success" = f.submit _("Save changes"), class: "btn btn-success qa-save-merge-request-approval-settings-button"
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
- if project.code_owner_approval_required_available? - if project.code_owner_approval_required_available?
.form-group.require-code-owner-approval .form-group.require-code-owner-approval
.form-check .form-check
= form.check_box(:merge_requests_require_code_owner_approval, class: 'form-check-input') = form.check_box(:merge_requests_require_code_owner_approval, class: 'form-check-input qa-require-code-owners-approval-checkbox')
= form.label :merge_requests_require_code_owner_approval, class: 'form-check-label' do = form.label :merge_requests_require_code_owner_approval, class: 'form-check-label' do
%span= _('Require approval from code owners') %span= _('Require approval from code owners')
= link_to icon('question-circle'), help_page_path('user/project/merge_requests/merge_request_approvals', anchor: 'editing-approvals-premium'), target: '_blank' = link_to icon('question-circle'), help_page_path('user/project/merge_requests/merge_request_approvals', anchor: 'editing-approvals-premium'), target: '_blank'
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
%tr.d-none.d-sm-table-row %tr.d-none.d-sm-table-row
%th.w-25= s_('CodeOwner|Pattern') %th.w-25= s_('CodeOwner|Pattern')
%th= _('Members') %th= _('Members')
%tbody %tbody.qa-approver-list
- code_owner_rules.each do |code_owner_approval_rule| - code_owner_rules.each do |code_owner_approval_rule|
%tr %tr.qa-approver
%td.monospace= code_owner_approval_rule.name %td.monospace= code_owner_approval_rule.name
%td.d-none.d-sm-table-cell %td.d-none.d-sm-table-cell
- code_owner_approval_rule.approvers.each do |approver| - code_owner_approval_rule.approvers.each do |approver|
......
...@@ -68,6 +68,8 @@ module QA ...@@ -68,6 +68,8 @@ module QA
module Settings module Settings
autoload :ProtectedBranches, 'qa/ee/page/project/settings/protected_branches' autoload :ProtectedBranches, 'qa/ee/page/project/settings/protected_branches'
autoload :MirroringRepositories, 'qa/ee/page/project/settings/mirroring_repositories' autoload :MirroringRepositories, 'qa/ee/page/project/settings/mirroring_repositories'
autoload :Main, 'qa/ee/page/project/settings/main'
autoload :MergeRequestApproval, 'qa/ee/page/project/settings/merge_request_approval'
end end
module Pipeline module Pipeline
......
...@@ -32,6 +32,11 @@ module QA ...@@ -32,6 +32,11 @@ module QA
element :review_preview_toggle element :review_preview_toggle
end end
view 'ee/app/views/projects/merge_requests/_code_owner_approval_rules.html.haml' do
element :approver
element :approver_list
end
def start_review def start_review
click_element :start_review click_element :start_review
end end
...@@ -62,6 +67,12 @@ module QA ...@@ -62,6 +67,12 @@ module QA
def unresolve_review_discussion def unresolve_review_discussion
check_element :unresolve_review_discussion check_element :unresolve_review_discussion
end end
def approvers
within_element :approver_list do
all_elements(:approver).map { |item| item.find('img')['title'] }
end
end
end end
end end
end end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Settings
module Main
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/_merge_request_approvals_settings.html.haml' do
element :merge_request_approval_settings
end
end
end
def expand_request_approval_settings(&block)
expand_section(:merge_request_approval_settings) do
MergeRequestApproval.perform(&block)
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Settings
class MergeRequestApproval < QA::Page::Base
view 'ee/app/views/projects/_merge_request_approvals_settings_form.html.haml' do
element :require_code_owners_approval_checkbox
end
view 'ee/app/views/projects/_merge_request_approvals_settings.html.haml' do
element :save_merge_request_approval_settings_button
end
def click_require_code_owners_approval_checkbox
check_element :require_code_owners_approval_checkbox
end
def click_save_merge_request_approval_button
click_element :save_merge_request_approval_settings_button
end
end
end
end
end
end
end
...@@ -175,12 +175,6 @@ module QA ...@@ -175,12 +175,6 @@ module QA
click_element :edit_button click_element :edit_button
end end
def approvers
within_element :approver_list do
all_elements(:approver).map(&:text)
end
end
def view_email_patches def view_email_patches
click_element :dropdown_toggle click_element :dropdown_toggle
visit_link_in_element(:download_email_patches) visit_link_in_element(:download_email_patches)
......
...@@ -5,6 +5,8 @@ module QA ...@@ -5,6 +5,8 @@ module QA
module Project module Project
module Settings module Settings
class Main < Page::Base class Main < Page::Base
prepend QA::EE::Page::Project::Settings::Main
include Common include Common
include Component::Select2 include Component::Select2
include SubMenus::Project include SubMenus::Project
......
...@@ -12,7 +12,11 @@ module QA ...@@ -12,7 +12,11 @@ module QA
end end
def within_submenu def within_submenu
within('.fly-out-list') do if has_css?('.fly-out-list')
within('.fly-out-list') do
yield
end
else
yield yield
end end
end end
......
...@@ -10,6 +10,7 @@ module QA ...@@ -10,6 +10,7 @@ module QA
:description, :description,
:source_branch, :source_branch,
:target_branch, :target_branch,
:target_new_branch,
:assignee, :assignee,
:milestone, :milestone,
:labels, :labels,
...@@ -28,6 +29,7 @@ module QA ...@@ -28,6 +29,7 @@ module QA
Repository::ProjectPush.fabricate! do |resource| Repository::ProjectPush.fabricate! do |resource|
resource.project = project resource.project = project
resource.branch_name = 'master' resource.branch_name = 'master'
resource.new_branch = @target_new_branch
resource.remote_branch = target_branch resource.remote_branch = target_branch
end end
end end
...@@ -53,6 +55,7 @@ module QA ...@@ -53,6 +55,7 @@ module QA
@labels = [] @labels = []
@file_name = "added_file.txt" @file_name = "added_file.txt"
@file_content = "File Added" @file_content = "File Added"
@target_new_branch = true
end end
def fabricate! def fabricate!
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
# https://gitlab.com/gitlab-org/quality/staging/issues/39 context 'Create' do
context 'Create', :quarantine do
describe 'Codeowners' do describe 'Codeowners' do
it 'merge request assigns code owners as approvers' do it 'merge request assigns code owners as approvers' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
...@@ -25,6 +24,15 @@ module QA ...@@ -25,6 +24,15 @@ module QA
members_page.add_member(non_approver.username) members_page.add_member(non_approver.username)
end end
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |settings|
settings.expand_request_approval_settings do |page|
page.click_require_code_owners_approval_checkbox
page.click_save_merge_request_approval_button
end
end
# Push CODEOWNERS to master # Push CODEOWNERS to master
project_push = Resource::Repository::ProjectPush.fabricate! do |push| project_push = Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = project
...@@ -36,16 +44,18 @@ module QA ...@@ -36,16 +44,18 @@ module QA
end end
# Push a new CODEOWNERS file and create a merge request # Push a new CODEOWNERS file and create a merge request
Resource::MergeRequest.fabricate! do |merge_request| merge_request = Resource::MergeRequest.fabricate! do |merge_request|
merge_request.title = 'This is a merge request' merge_request.title = 'This is a merge request'
merge_request.description = 'Change code owners' merge_request.description = 'Change code owners'
merge_request.project = project_push.project merge_request.project = project_push.project
merge_request.file_name = 'CODEOWNERS' merge_request.file_name = 'CODEOWNERS'
merge_request.target_new_branch = false
merge_request.file_content = <<~CONTENT merge_request.file_content = <<~CONTENT
CODEOWNERS @#{non_approver.username} CODEOWNERS @#{non_approver.username}
CONTENT CONTENT
end end
merge_request.visit!
# Check that the merge request assigns the original code owner as an # Check that the merge request assigns the original code owner as an
# approver (because the current CODEOWNERS file in the master branch # approver (because the current CODEOWNERS file in the master branch
# doesn't have the new owner yet) # doesn't have the new owner yet)
......
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