Commit aaa9dc01 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-testcases-195-audit-logs' into 'master'

Add e2e tests for project audit logs

See merge request gitlab-org/gitlab-ee!16012
parents db1fcb06 e7300f92
......@@ -215,6 +215,7 @@ export default {
:disabled="!canChangeVisibilityLevel"
name="project[visibility_level]"
class="form-control select-control"
data-qa-selector="project_visibility_dropdown"
>
<option
:value="visibilityOptions.PRIVATE"
......
......@@ -26,9 +26,9 @@
%p= _('Once the exported file is ready, you will receive a notification email with a download link, or you can download it from this page.')
- if project.export_status == :finished
= link_to _('Download export'), download_export_project_path(project),
rel: 'nofollow', download: '', method: :get, class: "btn btn-default"
rel: 'nofollow', download: '', method: :get, class: "btn btn-default", data: { qa_selector: 'download_export_link' }
= link_to _('Generate new export'), generate_new_export_project_path(project),
method: :post, class: "btn btn-default"
- else
= link_to _('Export project'), export_project_path(project),
method: :post, class: "btn btn-default"
method: :post, class: "btn btn-default", data: { qa_selector: 'export_project_link' }
......@@ -3,7 +3,7 @@
- if !project.empty_repo? && can?(current_user, :download_code, project)
- archive_prefix = "#{project.path}-#{ref.tr('/', '-')}"
.project-action-button.dropdown.inline>
%button.btn.has-tooltip{ title: s_('DownloadSource|Download'), 'data-toggle' => 'dropdown', 'aria-label' => s_('DownloadSource|Download'), 'data-display' => 'static' }
%button.btn.has-tooltip{ title: s_('DownloadSource|Download'), 'data-toggle' => 'dropdown', 'aria-label' => s_('DownloadSource|Download'), 'data-display' => 'static', data: { qa_selector: 'download_source_code_button' } }
= sprite_icon('download')
%span.sr-only= _('Select Archive Format')
= sprite_icon("arrow-down")
......
......@@ -10,7 +10,7 @@
%p= _('Update your project name, topics, description and avatar.')
.settings-content= render 'projects/settings/general'
%section.settings.sharing-permissions.no-animate#js-shared-permissions{ class: ('expanded' if expanded) }
%section.settings.sharing-permissions.no-animate#js-shared-permissions{ class: ('expanded' if expanded), data: { qa_selector: 'visibility_features_permissions_content' } }
.settings-header
%h4.settings-title.js-settings-toggle.js-settings-toggle-trigger-only= _('Visibility, project features, permissions')
%button.btn.btn-default.js-settings-toggle{ type: 'button' }= expanded ? _('Collapse') : _('Expand')
......@@ -21,7 +21,7 @@
%input{ name: 'update_section', type: 'hidden', value: 'js-shared-permissions' }
%template.js-project-permissions-form-data{ type: "application/json" }= project_permissions_panel_data_json(@project)
.js-project-permissions-form
= f.submit _('Save changes'), class: "btn btn-success"
= f.submit _('Save changes'), class: "btn btn-success", data: { qa_selector: 'visibility_features_permissions_save_button' }
%section.qa-merge-request-settings.rspec-merge-request-settings.settings.merge-requests-feature.no-animate#js-merge-request-settings{ class: [('expanded' if expanded), ('hidden' if @project.project_feature.send(:merge_requests_access_level) == 0)] }
.settings-header
......@@ -81,12 +81,12 @@
- if @project.archived?
%p= _("Unarchiving the project will restore people's ability to make changes to it. The repository can be committed to, and issues, comments and other entities can be created. <strong>Once active this project shows up in the search and on the dashboard.</strong>").html_safe
= link_to _('Unarchive project'), unarchive_project_path(@project),
data: { confirm: _("Are you sure that you want to unarchive this project?") },
data: { confirm: _("Are you sure that you want to unarchive this project?"), qa_selector: 'unarchive_project_link' },
method: :post, class: "btn btn-success"
- else
%p= _("Archiving the project will make it entirely read-only. It is hidden from the dashboard and doesn't show up in searches. <strong>The repository cannot be committed to, and no issues, comments or other entities can be created.</strong>").html_safe
= link_to _('Archive project'), archive_project_path(@project),
data: { confirm: _("Are you sure that you want to archive this project?") },
data: { confirm: _("Are you sure that you want to archive this project?"), qa_selector: 'archive_project_link' },
method: :post, class: "btn btn-warning"
.sub-section.rename-repository
%h4.warning-title= _('Change path')
......
- return unless @project.feature_available?(:audit_events) || show_promotions?
= nav_link(controller: :audit_events) do
= link_to project_audit_events_path(@project), title: "Audit Events" do
= link_to project_audit_events_path(@project), title: "Audit Events", data: { qa_selector: 'audit_events_settings_link' } do
= _('Audit Events')
......@@ -222,6 +222,7 @@ module QA
autoload :MergeRequest, 'qa/page/project/settings/merge_request'
autoload :Members, 'qa/page/project/settings/members'
autoload :MirroringRepositories, 'qa/page/project/settings/mirroring_repositories'
autoload :VisibilityFeaturesPermissions, 'qa/page/project/settings/visibility_features_permissions'
end
module SubMenus
......
......@@ -83,6 +83,8 @@ module QA
module SubMenus
autoload :SecurityCompliance, 'qa/ee/page/project/sub_menus/security_compliance'
autoload :Repository, 'qa/ee/page/project/sub_menus/repository'
autoload :Settings, 'qa/ee/page/project/sub_menus/settings'
autoload :Project, 'qa/ee/page/project/sub_menus/project'
end
module Issue
......
......@@ -4,17 +4,11 @@ module QA
module EE
module Page
module Project
class Menu < ::QA::Page::Base
include QA::Page::Project::SubMenus::Common
view 'ee/app/views/layouts/nav/_project_insights_link.html.haml' do
element :project_insights_link
end
def click_project_insights_link
within_sidebar do
click_element(:project_insights_link)
end
end
module Menu
prepend QA::Page::Project::SubMenus::Common
prepend SubMenus::SecurityCompliance
prepend SubMenus::Project
prepend SubMenus::Settings
end
end
end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module SubMenus
module Project
def self.included(base)
base.class_eval do
view 'ee/app/views/layouts/nav/_project_insights_link.html.haml' do
element :project_insights_link
end
end
end
def click_project_insights_link
within_sidebar do
click_element(:project_insights_link)
end
end
end
end
end
end
end
end
......@@ -6,8 +6,6 @@ module QA
module Project
module SubMenus
module SecurityCompliance
include QA::Page::Project::SubMenus::Common
def self.included(page)
page.class_eval do
view 'ee/app/views/layouts/nav/sidebar/_project_security_link.html.haml' do
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module SubMenus
module Settings
include QA::Page::Project::SubMenus::Common
def self.included(base)
base.class_eval do
view 'ee/app/views/projects/sidebar/_settings_audit_events.html.haml' do
element :audit_events_settings_link
end
end
end
def go_to_audit_events_settings
hover_settings do
within_submenu do
click_element :audit_events_settings_link
end
end
end
private
def hover_settings
within_sidebar do
scroll_to_element(:settings_item)
find_element(:settings_item).hover
yield
end
end
end
end
end
end
end
end
......@@ -40,4 +40,4 @@ module QA
end
end
QA::Page::Project::Menu.prepend_if_ee('QA::EE::Page::Project::SubMenus::SecurityCompliance')
QA::Page::Project::Menu.prepend_if_ee('QA::EE::Page::Project::Menu')
......@@ -12,6 +12,13 @@ module QA
element :project_path_field
element :change_path_button
element :transfer_button
element :archive_project_link
element :unarchive_project_link
end
view 'app/views/projects/_export.html.haml' do
element :export_project_link
element :download_export_link
end
def update_project_path_to(path)
......@@ -38,6 +45,26 @@ module QA
fill_confirmation_text(project_name)
click_confirm_button
end
def click_export_project_link
click_element :export_project_link
end
def click_download_export_link
click_element :download_export_link
end
def archive_project
page.accept_alert("Are you sure that you want to archive this project?") do
click_element :archive_project_link
end
end
def unarchive_project
page.accept_alert("Are you sure that you want to unarchive this project?") do
click_element :unarchive_project_link
end
end
end
end
end
......
......@@ -18,6 +18,10 @@ module QA
element :save_naming_topics_avatar_button
end
view 'app/views/projects/edit.html.haml' do
element :visibility_features_permissions_content
end
def rename_project_to(name)
fill_project_name(name)
click_save_changes
......@@ -36,6 +40,12 @@ module QA
Advanced.perform(&block)
end
end
def expand_visibility_project_features_permissions(&block)
expand_section(:visibility_features_permissions_content) do
VisibilityFeaturesPermissions.perform(&block)
end
end
end
end
end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Settings
class VisibilityFeaturesPermissions < Page::Base
include QA::Page::Component::Select2
view 'app/views/projects/edit.html.haml' do
element :visibility_features_permissions_save_button
end
view 'app/assets/javascripts/pages/projects/shared/permissions/components/settings_panel.vue' do
element :project_visibility_dropdown
end
def set_project_visibility(visibility)
select_element(:project_visibility_dropdown, visibility)
click_element :visibility_features_permissions_save_button
end
end
end
end
end
end
......@@ -56,6 +56,10 @@ module QA
element :spinner
end
view 'app/views/projects/buttons/_download.html.haml' do
element :download_source_code_button
end
def wait_for_viewers_to_load
wait(reload: false) do
has_no_element?(:spinner)
......
......@@ -41,7 +41,7 @@ module QA
project.visit!
EE::Page::Project::Menu.perform(&:click_project_insights_link)
Page::Project::Menu.perform(&:click_project_insights_link)
end
it_behaves_like 'default insights page'
......
# frozen_string_literal: true
module QA
context 'Manage' do
shared_examples 'project audit event logs' do |expected_events|
it 'logs audit events for UI operations' do
Page::Project::Menu.perform(&:go_to_audit_events_settings)
expected_events.each do |expected_event|
expect(page).to have_text(expected_event)
end
end
end
describe 'Project audit logs' do
before(:all) do
sign_in
@project = Resource::Project.fabricate_via_browser_ui! do |project|
project.name = 'awesome-project'
project.initialize_with_readme = true
end
end
before do
sign_in
end
let(:user) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
context "Add project" do
before do
@project.visit!
end
it_behaves_like 'project audit event logs', ["Add project"]
end
context "Add user access as guest" do
before do
@project.visit!
Page::Project::Menu.perform(&:go_to_members_settings)
Page::Project::Settings::Members.perform do |page|
page.add_member(user.username)
end
end
it_behaves_like 'project audit event logs', ["Add user access as guest"]
end
context "Add deploy key" do
before do
key = Runtime::Key::RSA.new
deploy_key_title = 'deploy key title'
deploy_key_value = key.public_key
Resource::DeployKey.fabricate_via_browser_ui! do |resource|
resource.project = @project
resource.title = deploy_key_title
resource.key = deploy_key_value
end
end
it_behaves_like 'project audit event logs', ["Add deploy key"]
end
context "Change visibility" do
before do
@project.visit!
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |settings|
# Change visibility from public to internal
settings.expand_visibility_project_features_permissions do |page|
page.set_project_visibility "internal"
end
end
end
it_behaves_like 'project audit event logs', ["Change visibility from public to internal"]
end
context "Export file download" do
before do
@project.visit!
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |settings|
settings.expand_advanced_settings(&:click_export_project_link)
expect(page).to have_text("Project export started")
Page::Project::Menu.perform(&:go_to_general_settings)
settings.expand_advanced_settings(&:click_download_export_link)
end
end
it_behaves_like 'project audit event logs', ["Export file download started"]
end
context "Project archive and unarchive" do
before do
@project.visit!
# Project archive
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |settings|
settings.expand_advanced_settings(&:archive_project)
end
# Project unarchived
Page::Project::Menu.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform do |settings|
settings.expand_advanced_settings(&:unarchive_project)
end
end
it_behaves_like 'project audit event logs', ["Project archived", "Project unarchived"]
end
def sign_in
unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
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