Commit 72e7489c authored by Robert Speicher's avatar Robert Speicher

Merge branch 'ml-qa-code-owners' into 'master'

QA: Add basic e2e test for codeowners display in file blob

See merge request gitlab-org/gitlab-ee!7368
parents 4a84ae4e 91df8e26
- return if blob.owners.empty?
.well-segment.blob-auxiliary-viewer.file-owner-content
.well-segment.blob-auxiliary-viewer.file-owner-content.qa-file-owner-content
= sprite_icon('users', size: 18, css_class: 'icon')
%strong
= _("Code owners")
= link_to icon('question-circle'), help_page_path('user/project/code_owners'), title: 'About this feature', target: '_blank'
:
= users_sentence(blob.owners, link_class: 'file-owner-link')
= users_sentence(blob.owners, link_class: 'file-owner-link qa-link-file-owner')
......@@ -23,6 +23,10 @@ module QA
end
end
module File
autoload :Show, 'qa/ee/page/file/show'
end
module Main
autoload :Banner, 'qa/ee/page/main/banner'
end
......
# frozen_string_literal: true
module QA
module EE
module Page
module File
module Show
def self.prepended(page)
page.module_eval do
view 'ee/app/views/projects/blob/_owners.html.haml' do
element :file_owner_content
element :link_file_owner
end
end
end
end
end
end
end
end
......@@ -31,7 +31,9 @@ module QA
end
def files=(files)
if !files.is_a?(Array) || files.empty?
if !files.is_a?(Array) ||
files.empty? ||
files.any? { |file| !file.has_key?(:name) || !file.has_key?(:content) }
raise ArgumentError, "Please provide an array of hashes e.g.: [{name: 'file1', content: 'foo'}]"
end
......
......@@ -2,6 +2,8 @@ module QA
module Page
module File
class Show < Page::Base
prepend QA::EE::Page::File::Show
include Shared::CommitMessage
view 'app/helpers/blob_helper.rb' do
......
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Codeowners' do
let(:files) do
[
{
name: 'file.txt',
content: 'foo'
},
{
name: 'README.md',
content: 'bar'
}
]
end
before do
# Add two new users to a project as members
Runtime::Browser.visit(:gitlab, Page::Main::Login)
@user = Factory::Resource::User.fabricate!
@user2 = Factory::Resource::User.fabricate!
Page::Main::Menu.perform { |menu| menu.sign_out }
Page::Main::Login.perform { |login_page| login_page.sign_in_using_credentials }
@project = Factory::Resource::Project.fabricate! do |project|
project.name = "codeowners"
end
@project.visit!
Page::Project::Menu.perform { |menu| menu.click_members_settings }
Page::Project::Settings::Members.perform do |members_page|
members_page.add_member(@user.username)
members_page.add_member(@user2.username)
end
end
it 'displays owners specified in CODEOWNERS file' do
codeowners_file_content =
<<-CONTENT
* @#{@user2.username}
*.txt @#{@user.username}
CONTENT
files << {
name: 'CODEOWNERS',
content: codeowners_file_content
}
# Push CODEOWNERS and test files to the project
Factory::Repository::ProjectPush.fabricate! do |push|
push.project = @project
push.files = files
push.commit_message = 'Add CODEOWNERS and test files'
end
Page::Project::Show.perform do |project_page|
project_page.wait_for_push
end
# Check the files and code owners
Page::Project::Show.perform do |project_page|
project_page.go_to_file 'file.txt'
end
expect(page).to have_content(@user.name)
expect(page).not_to have_content(@user2.name)
@project.visit!
Page::Project::Show.perform do |project_page|
project_page.go_to_file 'README.md'
end
expect(page).to have_content(@user2.name)
expect(page).not_to have_content(@user.name)
end
end
end
end
......@@ -19,7 +19,11 @@ describe QA::Factory::Repository::Push do
expect { subject.files = [] }.to raise_error(ArgumentError)
end
it 'does not raise if files is an array' do
it 'raises an error if files is not an array of hashes with :name and :content keys' do
expect { subject.files = [{ foo: 'foo' }] }.to raise_error(ArgumentError)
end
it 'does not raise if files is an array of hashes with :name and :content keys' do
expect { subject.files = files }.not_to raise_error
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