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_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
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _("Merge request approvals")
%button.btn.js-settings-toggle{ type: 'button' }= expanded ? _("Collapse") : _("Expand")
......@@ -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|
%input{ name: 'update_section', type: 'hidden', value: 'js-merge-request-approval-settings' }
= 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 @@
- if project.code_owner_approval_required_available?
.form-group.require-code-owner-approval
.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
%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'
......
......@@ -14,9 +14,9 @@
%tr.d-none.d-sm-table-row
%th.w-25= s_('CodeOwner|Pattern')
%th= _('Members')
%tbody
%tbody.qa-approver-list
- code_owner_rules.each do |code_owner_approval_rule|
%tr
%tr.qa-approver
%td.monospace= code_owner_approval_rule.name
%td.d-none.d-sm-table-cell
- code_owner_approval_rule.approvers.each do |approver|
......
......@@ -68,6 +68,8 @@ module QA
module Settings
autoload :ProtectedBranches, 'qa/ee/page/project/settings/protected_branches'
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
module Pipeline
......
......@@ -32,6 +32,11 @@ module QA
element :review_preview_toggle
end
view 'ee/app/views/projects/merge_requests/_code_owner_approval_rules.html.haml' do
element :approver
element :approver_list
end
def start_review
click_element :start_review
end
......@@ -62,6 +67,12 @@ module QA
def unresolve_review_discussion
check_element :unresolve_review_discussion
end
def approvers
within_element :approver_list do
all_elements(:approver).map { |item| item.find('img')['title'] }
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
click_element :edit_button
end
def approvers
within_element :approver_list do
all_elements(:approver).map(&:text)
end
end
def view_email_patches
click_element :dropdown_toggle
visit_link_in_element(:download_email_patches)
......
......@@ -5,6 +5,8 @@ module QA
module Project
module Settings
class Main < Page::Base
prepend QA::EE::Page::Project::Settings::Main
include Common
include Component::Select2
include SubMenus::Project
......
......@@ -12,7 +12,11 @@ module QA
end
def within_submenu
within('.fly-out-list') do
if has_css?('.fly-out-list')
within('.fly-out-list') do
yield
end
else
yield
end
end
......
......@@ -10,6 +10,7 @@ module QA
:description,
:source_branch,
:target_branch,
:target_new_branch,
:assignee,
:milestone,
:labels,
......@@ -28,6 +29,7 @@ module QA
Repository::ProjectPush.fabricate! do |resource|
resource.project = project
resource.branch_name = 'master'
resource.new_branch = @target_new_branch
resource.remote_branch = target_branch
end
end
......@@ -53,6 +55,7 @@ module QA
@labels = []
@file_name = "added_file.txt"
@file_content = "File Added"
@target_new_branch = true
end
def fabricate!
......
# frozen_string_literal: true
module QA
# https://gitlab.com/gitlab-org/quality/staging/issues/39
context 'Create', :quarantine do
context 'Create' do
describe 'Codeowners' do
it 'merge request assigns code owners as approvers' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
......@@ -25,6 +24,15 @@ module QA
members_page.add_member(non_approver.username)
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
project_push = Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
......@@ -36,16 +44,18 @@ module QA
end
# 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.description = 'Change code owners'
merge_request.project = project_push.project
merge_request.file_name = 'CODEOWNERS'
merge_request.target_new_branch = false
merge_request.file_content = <<~CONTENT
CODEOWNERS @#{non_approver.username}
CONTENT
end
merge_request.visit!
# Check that the merge request assigns the original code owner as an
# approver (because the current CODEOWNERS file in the master branch
# 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