Commit d786cf32 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'qa-auto-assign-codeowner-spec' into 'master'

Add e2e test: auto-assign code owners

See merge request gitlab-org/gitlab-ee!8372
parents 038707a2 0213d17a
......@@ -35,7 +35,7 @@
.card.prepend-top-10
.card-header
Approvers
%ul.content-list.approver-list
%ul.content-list.approver-list.qa-approver-list
- if presenter.all_approvers_including_groups.empty?
%li.no-approvers There are no approvers
- else
......@@ -43,7 +43,7 @@
- item_classes = unsaved_approvers ? ['unsaved-approvers'] : []
- presenter.overall_approvers.each do |approver|
%li{ id: dom_id(approver), class: item_classes + ['approver'] }
= link_to approver.name, approver
= link_to approver.name, approver, class: 'qa-approver'
- if can_update_approvers
.float-right
- if unsaved_approvers
......
......@@ -32,6 +32,10 @@ module QA
element :review_preview_toggle
end
view 'ee/app/views/shared/issuable/_approvals.html.haml' do
element :approver_list
end
def start_review
click_element :start_review
end
......
......@@ -173,6 +173,12 @@ module QA
def edit!
click_element :edit_button
end
def approvers
within_element :approver_list do
all_elements(:approver).map(&:text)
end
end
end
end
end
......
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Codeowners' do
it 'merge request assigns code owners as approvers' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create one user to be the assigned approver and another user who will
# not be an approver
approver = Resource::User.fabricate!
non_approver = Resource::User.fabricate!
# Create a project and assign the users to it
project = Resource::Project.fabricate! do |project|
project.name = "assign-approvers"
end
project.visit!
Page::Project::Menu.perform(&:click_members_settings)
Page::Project::Settings::Members.perform do |members_page|
members_page.add_member(approver.username)
members_page.add_member(non_approver.username)
end
# Push CODEOWNERS to master
project_push = Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
push.file_name = 'CODEOWNERS'
push.file_content = <<~CONTENT
CODEOWNERS @#{approver.username}
CONTENT
push.commit_message = 'Add CODEOWNERS and test files'
end
Page::Project::Show.perform do |project_page|
project_page.wait_for_push
end
# Push a new CODEOWNERS file and create a 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.file_content = <<~CONTENT
CODEOWNERS @#{non_approver.username}
CONTENT
end
# 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)
Page::MergeRequest::Show.perform do |mr_page|
mr_page.edit!
expect(mr_page.approvers).to include(approver.name)
expect(mr_page.approvers).not_to include(non_approver.name)
end
end
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