Commit bb4bda2d authored by Sanad Liaquat's avatar Sanad Liaquat

Add e2e tests for group audit logs

Also adds the required qa-selectors
parent 59022e4f
...@@ -7,7 +7,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -7,7 +7,7 @@ document.addEventListener('DOMContentLoaded', () => {
const skippable = parseBoolean(twoFactorNode.dataset.twoFactorSkippable); const skippable = parseBoolean(twoFactorNode.dataset.twoFactorSkippable);
if (skippable) { if (skippable) {
const button = `<a class="btn btn-sm btn-warning float-right" data-method="patch" href="${twoFactorNode.dataset.two_factor_skip_url}">Configure it later</a>`; const button = `<a class="btn btn-sm btn-warning float-right" data-qa-selector="configure_it_later_button" data-method="patch" href="${twoFactorNode.dataset.two_factor_skip_url}">Configure it later</a>`;
const flashAlert = document.querySelector('.flash-alert'); const flashAlert = document.querySelector('.flash-alert');
if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button); if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Groups::GroupMembersHelper module Groups::GroupMembersHelper
def group_member_select_options def group_member_select_options
{ multiple: true, class: 'input-clamp', scope: :all, email_user: true } { multiple: true, class: 'input-clamp qa-member-select-field ', scope: :all, email_user: true }
end end
end end
......
...@@ -19,4 +19,4 @@ ...@@ -19,4 +19,4 @@
On this date, the member(s) will automatically lose access to this group and all of its projects. On this date, the member(s) will automatically lose access to this group and all of its projects.
.col-md-2 .col-md-2
= f.submit 'Add to group', class: "btn btn-success btn-block" = f.submit 'Add to group', class: "btn btn-success btn-block", data: { qa_selector: 'add_to_group_button' }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.row .row
.form-group.col-md-5 .form-group.col-md-5
= f.label :name, _('Group name'), class: 'label-bold' = f.label :name, _('Group name'), class: 'label-bold'
= f.text_field :name, class: 'form-control' = f.text_field :name, class: 'form-control', data: { qa_selector: 'group_name_field' }
.form-group.col-md-7 .form-group.col-md-7
= f.label :id, _('Group ID'), class: 'label-bold' = f.label :id, _('Group ID'), class: 'label-bold'
...@@ -30,4 +30,4 @@ ...@@ -30,4 +30,4 @@
= render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group = render 'shared/visibility_level', f: f, visibility_level: @group.visibility_level, can_change_visibility_level: can_change_group_visibility_level?(@group), form_model: @group
= f.submit _('Save changes'), class: 'btn btn-success mt-4 js-dirty-submit' = f.submit _('Save changes'), class: 'btn btn-success mt-4 js-dirty-submit', data: { qa_selector: 'save_name_visibility_settings_button' }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
.form-group.append-bottom-default .form-group.append-bottom-default
.form-check .form-check
= f.check_box :lfs_enabled, checked: @group.lfs_enabled?, class: 'form-check-input' = f.check_box :lfs_enabled, checked: @group.lfs_enabled?, class: 'form-check-input', data: { qa_selector: 'lfs_checkbox' }
= f.label :lfs_enabled, class: 'form-check-label' do = f.label :lfs_enabled, class: 'form-check-label' do
%span %span
= _('Allow projects within this group to use Git LFS') = _('Allow projects within this group to use Git LFS')
......
.form-group .form-group
= f.label s_('ProjectCreationLevel|Allowed to create projects'), class: 'label-bold' = f.label s_('ProjectCreationLevel|Allowed to create projects'), class: 'label-bold'
= f.select :project_creation_level, options_for_select(::Gitlab::Access.project_creation_options, group.project_creation_level), {}, class: 'form-control' = f.select :project_creation_level, options_for_select(::Gitlab::Access.project_creation_options, group.project_creation_level), {}, class: 'form-control', data: { qa_selector: 'project_creation_level_dropdown' }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
.form-group .form-group
.form-check .form-check
= f.check_box :require_two_factor_authentication, class: 'form-check-input' = f.check_box :require_two_factor_authentication, class: 'form-check-input', data: { qa_selector: 'require_2fa_checkbox' }
= f.label :require_two_factor_authentication, class: 'form-check-label' do = f.label :require_two_factor_authentication, class: 'form-check-label' do
%span= _('Require all users in this group to setup Two-factor authentication') %span= _('Require all users in this group to setup Two-factor authentication')
.form-group .form-group
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
= form_tag project_group_links_path(@project), class: 'js-requires-input', method: :post do = form_tag project_group_links_path(@project), class: 'js-requires-input', method: :post do
.form-group .form-group
= label_tag :link_group_id, _("Select a group to invite"), class: "label-bold" = label_tag :link_group_id, _("Select a group to invite"), class: "label-bold"
= groups_select_tag(:link_group_id, data: { skip_groups: @skip_groups }, class: "input-clamp", required: true) = groups_select_tag(:link_group_id, data: { skip_groups: @skip_groups }, class: "input-clamp qa-group-select-field", required: true)
.form-group .form-group
= label_tag :link_group_access, _("Max access level"), class: "label-bold" = label_tag :link_group_access, _("Max access level"), class: "label-bold"
.select-wrapper .select-wrapper
...@@ -18,4 +18,4 @@ ...@@ -18,4 +18,4 @@
.clearable-input .clearable-input
= text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date-groups', placeholder: _('Expiration date'), id: 'expires_at_groups' = text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date-groups', placeholder: _('Expiration date'), id: 'expires_at_groups'
%i.clear-icon.js-clear-input %i.clear-icon.js-clear-input
= submit_tag _("Invite"), class: "btn btn-success" = submit_tag _("Invite"), class: "btn btn-success", data: { qa_selector: 'invite_group_button' }
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
%li.nav-tab{ role: 'presentation' } %li.nav-tab{ role: 'presentation' }
%a.nav-link.active{ href: '#invite-member-pane', id: 'invite-member-tab', data: { toggle: 'tab' }, role: 'tab' }= _("Invite member") %a.nav-link.active{ href: '#invite-member-pane', id: 'invite-member-tab', data: { toggle: 'tab' }, role: 'tab' }= _("Invite member")
%li.nav-tab{ role: 'presentation', class: ('active' if membership_locked?) } %li.nav-tab{ role: 'presentation', class: ('active' if membership_locked?) }
%a.nav-link{ href: '#invite-group-pane', id: 'invite-group-tab', data: { toggle: 'tab' }, role: 'tab' }= _("Invite group") %a.nav-link{ href: '#invite-group-pane', id: 'invite-group-tab', data: { toggle: 'tab', qa_selector: 'invite_group_tab' }, role: 'tab' }= _("Invite group")
.tab-content.gitlab-tab-content .tab-content.gitlab-tab-content
.tab-pane.active{ id: 'invite-member-pane', role: 'tabpanel' } .tab-pane.active{ id: 'invite-member-pane', role: 'tabpanel' }
......
- label_class = local_assigns.fetch(:bold_label, false) ? 'font-weight-bold' : '' - label_class = local_assigns.fetch(:bold_label, false) ? 'font-weight-bold' : ''
.form-check .form-check
= form.check_box :request_access_enabled, class: 'form-check-input' = form.check_box :request_access_enabled, class: 'form-check-input', data: { qa_selector: 'request_access_checkbox' }
= form.label :request_access_enabled, class: 'form-check-label' do = form.label :request_access_enabled, class: 'form-check-label' do
%span{ class: label_class }= _('Allow users to request access') %span{ class: label_class }= _('Allow users to request access')
%br %br
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- next if disallowed || restricted - next if disallowed || restricted
.form-check .form-check
= form.radio_button model_method, level, checked: (selected_level == level), class: 'form-check-input', data: { track_label: "blank_project", track_event: "activate_form_input", track_property: "#{model_method}_#{level}", track_value: "" } = form.radio_button model_method, level, checked: (selected_level == level), class: 'form-check-input', data: { track_label: "blank_project", track_event: "activate_form_input", track_property: "#{model_method}_#{level}", track_value: "", qa_selector: "#{visibility_level_label(level).downcase}_radio" }
= form.label "#{model_method}_#{level}", class: 'form-check-label' do = form.label "#{model_method}_#{level}", class: 'form-check-label' do
= visibility_level_icon(level) = visibility_level_icon(level)
.option-title .option-title
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
-# Note this is just for groups. For individual members please see shared/members/_member -# Note this is just for groups. For individual members please see shared/members/_member
%li.member.group_member.py-2.px-3.d-flex.flex-column.flex-md-row{ id: dom_id } %li.member.group_member.py-2.px-3.d-flex.flex-column.flex-md-row{ id: dom_id, data: { qa_selector: 'group_row' } }
%span.list-item-name.mb-2.m-md-0 %span.list-item-name.mb-2.m-md-0
= group_icon(group, class: "avatar s40 flex-shrink-0 flex-grow-0", alt: '') = group_icon(group, class: "avatar s40 flex-shrink-0 flex-grow-0", alt: '')
.user-info .user-info
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
- if can_admin_member - if can_admin_member
= link_to project_group_link_path(@project, group_link), = link_to project_group_link_path(@project, group_link),
method: :delete, method: :delete,
data: { confirm: _("Are you sure you want to remove %{group_name}?") % { group_name: group.name } }, data: { confirm: _("Are you sure you want to remove %{group_name}?") % { group_name: group.name }, qa_selector: 'delete_group_access_link' },
class: 'btn btn-remove m-0 ml-sm-2 align-self-center' do class: 'btn btn-remove m-0 ml-sm-2 align-self-center' do
%span.d-block.d-sm-none %span.d-block.d-sm-none
= _("Delete") = _("Delete")
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
-# Note this is just for individual members. For groups please see shared/members/_group -# Note this is just for individual members. For groups please see shared/members/_group
%li.member.py-2.px-3.d-flex.flex-column{ class: [dom_class(member), ("is-overridden" if override), ("flex-md-row" unless force_mobile_view)], id: dom_id(member) } %li.member.py-2.px-3.d-flex.flex-column{ class: [dom_class(member), ("is-overridden" if override), ("flex-md-row" unless force_mobile_view)], id: dom_id(member), data: { qa_selector: 'member_row' } }
%span.list-item-name.mb-2.m-md-0 %span.list-item-name.mb-2.m-md-0
- if user - if user
= image_tag avatar_icon_for_user(user, 40), class: "avatar s40 flex-shrink-0 flex-grow-0", alt: '' = image_tag avatar_icon_for_user(user, 40), class: "avatar s40 flex-shrink-0 flex-grow-0", alt: ''
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
.member-form-control.dropdown{ class: [("mr-sm-2 d-sm-inline-block" unless force_mobile_view)] } .member-form-control.dropdown{ class: [("mr-sm-2 d-sm-inline-block" unless force_mobile_view)] }
%button.dropdown-menu-toggle.js-member-permissions-dropdown{ type: "button", %button.dropdown-menu-toggle.js-member-permissions-dropdown{ type: "button",
disabled: member.can_override? && !override, disabled: member.can_override? && !override,
data: { toggle: "dropdown", field_name: "#{f.object_name}[access_level]" } } data: { toggle: "dropdown", field_name: "#{f.object_name}[access_level]", qa_selector: "access_level_dropdown" } }
%span.dropdown-toggle-text %span.dropdown-toggle-text
= member.human_access = member.human_access
= icon("chevron-down") = icon("chevron-down")
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
%li %li
= link_to role, '#', = link_to role, '#',
class: ("is-active" if member.access_level == role_id), class: ("is-active" if member.access_level == role_id),
data: { id: role_id, el_id: dom_id(member) } data: { id: role_id, el_id: dom_id(member), qa_selector: "#{role.downcase}_access_level_link" }
= render_if_exists 'shared/members/ee/revert_ldap_group_sync_option', = render_if_exists 'shared/members/ee/revert_ldap_group_sync_option',
group: @group, group: @group,
member: member, member: member,
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
- else - else
= link_to member, = link_to member,
method: :delete, method: :delete,
data: { confirm: remove_member_message(member) }, data: { confirm: remove_member_message(member), qa_selector: 'delete_member_button' },
class: "btn btn-remove align-self-center m-0 #{'ml-sm-2' unless force_mobile_view}", class: "btn btn-remove align-self-center m-0 #{'ml-sm-2' unless force_mobile_view}",
title: remove_member_title(member) do title: remove_member_title(member) do
%span{ class: ('d-block d-sm-none' unless force_mobile_view) } %span{ class: ('d-block d-sm-none' unless force_mobile_view) }
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
%h5= _('Member lock') %h5= _('Member lock')
.form-group .form-group
.form-check .form-check
= f.check_box :membership_lock, class: 'form-check-input' = f.check_box :membership_lock, class: 'form-check-input', data: { qa_selector: 'membership_lock_checkbox' }
= f.label :membership_lock, class: 'form-check-label' do = f.label :membership_lock, class: 'form-check-label' do
%span= _('Prevent adding new members to project membership within this group') %span= _('Prevent adding new members to project membership within this group')
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- if @group.feature_available?(:audit_events) - if @group.feature_available?(:audit_events)
= nav_link(path: 'audit_events#index') do = nav_link(path: 'audit_events#index') do
= link_to group_audit_events_path(@group), title: 'Audit Events' do = link_to group_audit_events_path(@group), title: 'Audit Events', data: { qa_selector: 'audit_events_settings_link' } do
%span %span
Audit Events Audit Events
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
.form-group.col-md-9 .form-group.col-md-9
= form.label :repository_size_limit, class: 'label-bold' do = form.label :repository_size_limit, class: 'label-bold' do
Repository size limit (MB) Repository size limit (MB)
= form.number_field :repository_size_limit, value: form.object.repository_size_limit.try(:to_mb), class: 'form-control', min: 0 = form.number_field :repository_size_limit, value: form.object.repository_size_limit.try(:to_mb), class: 'form-control', min: 0, data: { qa_selector: 'repository_size_limit_field' }
%span.form-text.text-muted#repository_size_limit_help_block %span.form-text.text-muted#repository_size_limit_help_block
= is_project ? size_limit_message(@project) : size_limit_message_for_group(@group) = is_project ? size_limit_message(@project) : size_limit_message_for_group(@group)
...@@ -162,6 +162,12 @@ module QA ...@@ -162,6 +162,12 @@ module QA
module Group module Group
autoload :New, 'qa/page/group/new' autoload :New, 'qa/page/group/new'
autoload :Show, 'qa/page/group/show' autoload :Show, 'qa/page/group/show'
autoload :Menu, 'qa/page/group/menu'
module SubMenus
autoload :Common, 'qa/page/group/sub_menus/common'
autoload :Members, 'qa/page/group/sub_menus/members'
end
module Settings module Settings
autoload :General, 'qa/page/group/settings/general' autoload :General, 'qa/page/group/settings/general'
...@@ -279,6 +285,7 @@ module QA ...@@ -279,6 +285,7 @@ module QA
autoload :Menu, 'qa/page/profile/menu' autoload :Menu, 'qa/page/profile/menu'
autoload :PersonalAccessTokens, 'qa/page/profile/personal_access_tokens' autoload :PersonalAccessTokens, 'qa/page/profile/personal_access_tokens'
autoload :SSHKeys, 'qa/page/profile/ssh_keys' autoload :SSHKeys, 'qa/page/profile/ssh_keys'
autoload :TwoFactorAuth, 'qa/page/profile/two_factor_auth'
end end
module Issuable module Issuable
......
...@@ -4,35 +4,44 @@ module QA ...@@ -4,35 +4,44 @@ module QA
module EE module EE
module Page module Page
module Group module Group
class Menu < ::QA::Page::Base module Menu
view 'ee/app/views/groups/ee/_settings_nav.html.haml' do prepend QA::Page::Group::SubMenus::Common
element :group_saml_sso_link
element :ldap_synchronization_link def self.included(base)
end base.class_eval do
view 'ee/app/views/groups/ee/_settings_nav.html.haml' do
view 'app/views/layouts/nav/sidebar/_group.html.haml' do element :group_saml_sso_link
element :group_sidebar element :ldap_synchronization_link
element :group_sidebar_submenu element :audit_events_settings_link
element :group_settings_item end
element :group_members_item view 'ee/app/views/layouts/nav/ee/_epic_link.html.haml' do
element :general_settings_link element :group_epics_link
end end
view 'ee/app/views/layouts/nav/ee/_epic_link.html.haml' do view 'ee/app/views/layouts/nav/ee/_security_link.html.haml' do
element :group_epics_link element :security_dashboard_link
end end
view 'ee/app/views/layouts/nav/ee/_security_link.html.haml' do view 'ee/app/views/layouts/nav/_group_insights_link.html.haml' do
element :security_dashboard_link element :group_insights_link
end end
view 'ee/app/views/layouts/nav/_group_insights_link.html.haml' do view 'app/views/layouts/nav/sidebar/_group.html.haml' do
element :group_insights_link element :group_issue_boards_link
element :group_issues_item
element :group_sidebar
element :group_sidebar_submenu
element :group_settings_item
end
end
end end
view 'app/views/layouts/nav/sidebar/_group.html.haml' do def go_to_audit_events_settings
element :group_issue_boards_link hover_element(:group_settings_item) do
element :group_issues_item within_submenu(:group_sidebar_submenu) do
click_element(:audit_events_settings_link)
end
end
end end
def go_to_issue_boards def go_to_issue_boards
...@@ -90,27 +99,6 @@ module QA ...@@ -90,27 +99,6 @@ module QA
click_element(:security_dashboard_link) click_element(:security_dashboard_link)
end end
end end
private
def hover_element(element)
within_sidebar do
find_element(element).hover
yield
end
end
def within_sidebar
within_element(:group_sidebar) do
yield
end
end
def within_submenu(element)
within_element(element) do
yield
end
end
end end
end end
end end
......
...@@ -5,18 +5,30 @@ module QA ...@@ -5,18 +5,30 @@ module QA
module Page module Page
module Group module Group
module Settings module Settings
class General < QA::Page::Base module General
include ::QA::Page::Component::Select2 prepend ::QA::Page::Component::Select2
include ::QA::Page::Settings::Common prepend ::QA::Page::Settings::Common
view 'ee/app/views/groups/_custom_project_templates_setting.html.haml' do def self.included(base)
element :custom_project_template_select base.class_eval do
element :custom_project_templates view 'ee/app/views/groups/_custom_project_templates_setting.html.haml' do
element :save_changes_button element :custom_project_template_select
end element :custom_project_templates
element :save_changes_button
end
view 'ee/app/views/groups/settings/_ip_restriction.html.haml' do
element :ip_restriction_field
end
view 'ee/app/views/groups/_member_lock_setting.html.haml' do
element :membership_lock_checkbox
end
view 'ee/app/views/groups/settings/_ip_restriction.html.haml' do view 'ee/app/views/shared/_repository_size_limit_setting.html.haml' do
element :ip_restriction_field element :repository_size_limit_field
end
end
end end
def current_custom_project_template def current_custom_project_template
...@@ -44,6 +56,22 @@ module QA ...@@ -44,6 +56,22 @@ module QA
find_element(:ip_restriction_field).set ip_address find_element(:ip_restriction_field).set ip_address
click_element :save_permissions_changes_button click_element :save_permissions_changes_button
end end
def set_membership_lock_enabled
expand_section :permission_lfs_2fa_section
check_element :membership_lock_checkbox
click_element :save_permissions_changes_button
end
def set_membership_lock_disabled
expand_section :permission_lfs_2fa_section
uncheck_element :membership_lock_checkbox
click_element :save_permissions_changes_button
end
def set_repository_size_limit(limit)
find_element(:repository_size_limit_field).set limit
end
end end
end end
end end
......
...@@ -27,7 +27,7 @@ module QA ...@@ -27,7 +27,7 @@ module QA
def fabricate! def fabricate!
group.visit! group.visit!
QA::EE::Page::Group::Menu.perform(&:click_group_epics_link) QA::Page::Group::Menu.perform(&:click_group_epics_link)
QA::EE::Page::Group::Epic::Index.perform do |page| QA::EE::Page::Group::Epic::Index.perform do |page|
page.click_new_epic page.click_new_epic
......
# frozen_string_literal: true
module QA
module Page
module Group
class Menu < Page::Base
include SubMenus::Common
view 'app/views/layouts/nav/sidebar/_group.html.haml' do
element :group_settings_item
element :group_members_item
element :general_settings_link
end
def click_group_members_item
within_sidebar do
click_element(:group_members_item)
end
end
def click_group_general_settings_item
hover_element(:group_settings_item) do
within_submenu(:group_sidebar_submenu) do
click_element(:general_settings_link)
end
end
end
end
end
end
end
QA::Page::Group::Menu.prepend_if_ee('QA::EE::Page::Group::Menu')
...@@ -5,14 +5,99 @@ module QA ...@@ -5,14 +5,99 @@ module QA
module Group module Group
module Settings module Settings
class General < QA::Page::Base class General < QA::Page::Base
include ::QA::Page::Settings::Common
view 'app/views/groups/edit.html.haml' do view 'app/views/groups/edit.html.haml' do
element :permission_lfs_2fa_section element :permission_lfs_2fa_section
end end
view 'app/views/groups/settings/_permissions.html.haml' do view 'app/views/groups/settings/_permissions.html.haml' do
element :save_permissions_changes_button element :save_permissions_changes_button
end end
view 'app/views/groups/settings/_general.html.haml' do
element :group_name_field
element :save_name_visibility_settings_button
end
view 'app/views/shared/_visibility_radios.html.haml' do
element :internal_radio, 'qa_selector: "#{visibility_level_label(level).downcase}_radio"' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck
end
view 'app/views/groups/settings/_lfs.html.haml' do
element :lfs_checkbox
end
view 'app/views/shared/_allow_request_access.html.haml' do
element :request_access_checkbox
end
view 'app/views/groups/settings/_two_factor_auth.html.haml' do
element :require_2fa_checkbox
end
view 'app/views/groups/settings/_project_creation_level.html.haml' do
element :project_creation_level_dropdown
end
def set_group_name(name)
find_element(:group_name_field).send_keys([:command, 'a'], :backspace)
find_element(:group_name_field).set name
end
def set_group_visibility(visibility)
find_element("#{visibility.downcase}_radio").click
end
def click_save_name_visibility_settings_button
click_element(:save_name_visibility_settings_button)
end
def set_lfs_enabled
expand_section :permission_lfs_2fa_section
check_element :lfs_checkbox
click_element :save_permissions_changes_button
end
def set_lfs_disabled
expand_section :permission_lfs_2fa_section
uncheck_element :lfs_checkbox
click_element :save_permissions_changes_button
end
def set_request_access_enabled
expand_section :permission_lfs_2fa_section
check_element :request_access_checkbox
click_element :save_permissions_changes_button
end
def set_request_access_disabled
expand_section :permission_lfs_2fa_section
uncheck_element :request_access_checkbox
click_element :save_permissions_changes_button
end
def set_require_2fa_enabled
expand_section :permission_lfs_2fa_section
check_element :require_2fa_checkbox
click_element :save_permissions_changes_button
end
def set_require_2fa_disabled
expand_section :permission_lfs_2fa_section
uncheck_element :require_2fa_checkbox
click_element :save_permissions_changes_button
end
def set_project_creation_level(value)
expand_section :permission_lfs_2fa_section
select_element(:project_creation_level_dropdown, value)
click_element :save_permissions_changes_button
end
end end
end end
end end
end end
end end
QA::Page::Group::Settings::General.prepend_if_ee('QA::EE::Page::Group::Settings::General')
# frozen_string_literal: true
module QA
module Page
module Group
module SubMenus
module Common
def self.included(base)
base.class_eval do
view 'app/views/layouts/nav/sidebar/_group.html.haml' do
element :group_sidebar
end
end
end
def hover_element(element)
within_sidebar do
find_element(element).hover
yield
end
end
def within_sidebar
within_element(:group_sidebar) do
yield
end
end
def within_submenu(element)
within_element(element) do
yield
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Group
module SubMenus
class Members < Page::Base
include Page::Component::UsersSelect
view 'app/views/groups/group_members/_new_group_member.html.haml' do
element :add_to_group_button
end
view 'app/helpers/groups/group_members_helper.rb' do
element :member_select_field
end
view 'app/views/shared/members/_member.html.haml' do
element :member_row
element :access_level_dropdown
element :delete_member_button
element :developer_access_level_link, 'qa_selector: "#{role.downcase}_access_level_link"' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck
end
def add_member(username)
select_user :member_select_field, username
click_element :add_to_group_button
end
def update_access_level(username, access_level)
within_element(:member_row, text: username) do
click_element :access_level_dropdown
click_element "#{access_level.downcase}_access_level_link"
end
end
def remove_member(username)
page.accept_confirm do
within_element(:member_row, text: username) do
click_element :delete_member_button
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Profile
class TwoFactorAuth < Page::Base
view 'app/assets/javascripts/pages/profiles/two_factor_auths/index.js' do
element :configure_it_later_button
end
def click_configure_it_later_button
click_element :configure_it_later_button
end
end
end
end
end
...@@ -6,6 +6,7 @@ module QA ...@@ -6,6 +6,7 @@ module QA
module Settings module Settings
class Members < Page::Base class Members < Page::Base
include Page::Component::UsersSelect include Page::Component::UsersSelect
include QA::Page::Component::Select2
view 'app/views/projects/project_members/_new_project_member.html.haml' do view 'app/views/projects/project_members/_new_project_member.html.haml' do
element :member_select_input element :member_select_input
...@@ -16,10 +17,44 @@ module QA ...@@ -16,10 +17,44 @@ module QA
element :members_list element :members_list
end end
view 'app/views/projects/project_members/index.html.haml' do
element :invite_group_tab
end
view 'app/views/projects/project_members/_new_project_group.html.haml' do
element :group_select_field
element :invite_group_button
end
view 'app/views/shared/members/_group.html.haml' do
element :group_row
element :delete_group_access_link
end
def select_group(group_name)
click_element :group_select_field
search_and_select(group_name)
end
def invite_group(group_name)
click_element :invite_group_tab
select_group(group_name)
click_element :invite_group_button
end
def add_member(username) def add_member(username)
select_user :member_select_input, username select_user :member_select_input, username
click_element :add_member_button click_element :add_member_button
end end
def remove_group(group_name)
click_element :invite_group_tab
page.accept_alert do
within_element(:group_row, text: group_name) do
click_element :delete_group_access_link
end
end
end
end end
end end
end end
......
# frozen_string_literal: true
require 'securerandom'
module QA
context 'Manage' do
shared_examples 'group audit event logs' do |expected_events|
it 'logs audit events' do
Page::Group::Menu.perform(&:go_to_audit_events_settings)
expected_events.each do |expected_event|
expect(page).to have_text(expected_event)
end
end
end
describe 'Group audit logs' do
before(:all) do
sign_in
@group = Resource::Group.fabricate_via_browser_ui! do |resource|
resource.path = "test-group-#{SecureRandom.hex(8)}"
end
end
let(:project) do
Resource::Project.fabricate_via_api! do |resource|
resource.name = 'project-shared-with-group'
end
end
let(:user) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
context 'Add group' do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
end
it_behaves_like 'group audit event logs', ["Add group"]
end
context 'Change repository size limit' do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform do |settings|
settings.set_repository_size_limit(100)
settings.click_save_name_visibility_settings_button
end
end
it_behaves_like 'group audit event logs', ["Change repository size limit"]
end
context 'Update group name' do
before do
sign_in
@group.visit!
updated_group_name = "#{@group.path}-updated"
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform do |settings|
settings.set_group_name(updated_group_name)
settings.click_save_name_visibility_settings_button
end
end
it_behaves_like 'group audit event logs', ["Change name"]
end
context 'Add user, change access level, remove user' do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_members_item)
Page::Group::SubMenus::Members.perform do |members_page|
members_page.add_member(user.username)
end
Page::Group::SubMenus::Members.perform do |members_page|
members_page.update_access_level(user.username, "Developer")
end
Page::Group::SubMenus::Members.perform do |members_page|
members_page.remove_member(user.username)
end
end
it_behaves_like 'group audit event logs', ["Add user access as guest", "Change access level", "Remove user access"]
end
context 'Add and remove project access' do
before do
sign_in
project.visit!
Page::Project::Menu.perform(&:go_to_members_settings)
Page::Project::Settings::Members.perform do |page|
page.invite_group(@group.path)
end
Page::Project::Menu.perform(&:go_to_members_settings)
Page::Project::Settings::Members.perform do |page|
page.remove_group(@group.path)
end
@group.visit!
end
it_behaves_like 'group audit event logs', ["Add project access", "Remove project access"]
end
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
# frozen_string_literal: true
require 'securerandom'
module QA
context 'Manage' do
shared_examples 'group audit event logs' do |expected_events|
it 'logs audit events' do
Page::Group::Menu.perform(&:go_to_audit_events_settings)
expected_events.each do |expected_event|
expect(page).to have_text(expected_event)
end
end
end
describe 'Group audit logs' do
before(:all) do
sign_in
@group = Resource::Group.fabricate_via_api! do |resource|
resource.path = "test-group-#{SecureRandom.hex(8)}"
end
end
# Bug issue: https://gitlab.com/gitlab-org/gitlab-ee/issues/14756
context 'Disable and Enable LFS', :quarantine do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_lfs_disabled)
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_lfs_enabled)
end
it_behaves_like 'group audit event logs', ["Change lfs enabled from false to true", "Change lfs enabled from true to false"]
end
context 'Enable and disable LFS' do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_membership_lock_enabled)
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_membership_lock_disabled)
end
it_behaves_like 'group audit event logs', ["Change membership lock from true to false", "Change membership lock from false to true"]
end
context 'Enable and disable allow user request access' do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_request_access_enabled)
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_request_access_disabled)
end
it_behaves_like 'group audit event logs', ["Change request access enabled from true to false", "Change request access enabled from false to true"]
end
# Bug issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/67283
context 'Enable and disable 2FA requirement', :quarantine do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_require_2fa_enabled)
Page::Profile::TwoFactorAuth.perform(&:click_configure_it_later_button)
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform(&:set_require_2fa_disabled)
end
it_behaves_like 'group audit event logs', ["Change require two factor authentication from true to false", "Change require two factor authentication from false to true"]
end
context 'Change project creation level' do
before do
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_general_settings_item)
Page::Group::Settings::General.perform do |settings|
settings.set_project_creation_level("Maintainers")
end
end
it_behaves_like 'group audit event logs', ["Change project creation level"]
end
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
...@@ -66,7 +66,7 @@ module QA ...@@ -66,7 +66,7 @@ module QA
group = create_group_and_add_user_via_api(owner_user, 'Synched-engineering-group') group = create_group_and_add_user_via_api(owner_user, 'Synched-engineering-group')
signin_and_visit_group_as_user(owner_user, group) signin_and_visit_group_as_user(owner_user, group)
EE::Page::Group::Menu.perform(&:go_to_ldap_sync_settings) Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
EE::Page::Group::Settings::LDAPSync.perform do |page| EE::Page::Group::Settings::LDAPSync.perform do |page|
page.set_sync_method('LDAP Group cn') page.set_sync_method('LDAP Group cn')
...@@ -74,7 +74,7 @@ module QA ...@@ -74,7 +74,7 @@ module QA
page.click_add_sync_button page.click_add_sync_button
end end
EE::Page::Group::Menu.perform(&:click_group_members_item) Page::Group::Menu.perform(&:click_group_members_item)
end end
it 'has LDAP users synced' do it 'has LDAP users synced' do
...@@ -116,14 +116,14 @@ module QA ...@@ -116,14 +116,14 @@ module QA
group = create_group_and_add_user_via_api(owner_user, 'Synched-human-resources-group') group = create_group_and_add_user_via_api(owner_user, 'Synched-human-resources-group')
signin_and_visit_group_as_user(owner_user, group) signin_and_visit_group_as_user(owner_user, group)
EE::Page::Group::Menu.perform(&:go_to_ldap_sync_settings) Page::Group::Menu.perform(&:go_to_ldap_sync_settings)
EE::Page::Group::Settings::LDAPSync.perform do |page| EE::Page::Group::Settings::LDAPSync.perform do |page|
page.set_user_filter('(&(objectClass=person)(cn=HR*))') page.set_user_filter('(&(objectClass=person)(cn=HR*))')
page.click_add_sync_button page.click_add_sync_button
end end
EE::Page::Group::Menu.perform(&:click_group_members_item) Page::Group::Menu.perform(&:click_group_members_item)
end end
it 'has LDAP users synced' do it 'has LDAP users synced' do
......
...@@ -21,7 +21,7 @@ module QA ...@@ -21,7 +21,7 @@ module QA
end end
it 'User logs in to group with SAML SSO' do it 'User logs in to group with SAML SSO' do
EE::Page::Group::Menu.perform(&:go_to_saml_sso_group_settings) Page::Group::Menu.perform(&:go_to_saml_sso_group_settings)
EE::Page::Group::Settings::SamlSSO.perform do |page| EE::Page::Group::Settings::SamlSSO.perform do |page|
page.set_id_provider_sso_url(QA::EE::Runtime::Saml.idp_sso_url) page.set_id_provider_sso_url(QA::EE::Runtime::Saml.idp_sso_url)
...@@ -35,7 +35,7 @@ module QA ...@@ -35,7 +35,7 @@ module QA
login_to_idp_if_required_and_expect_success login_to_idp_if_required_and_expect_success
EE::Page::Group::Menu.perform(&:go_to_saml_sso_group_settings) Page::Group::Menu.perform(&:go_to_saml_sso_group_settings)
EE::Page::Group::Settings::SamlSSO.perform(&:click_user_login_url_link) EE::Page::Group::Settings::SamlSSO.perform(&:click_user_login_url_link)
...@@ -45,7 +45,7 @@ module QA ...@@ -45,7 +45,7 @@ module QA
end end
it 'Lets group admin test settings' do it 'Lets group admin test settings' do
EE::Page::Group::Menu.perform(&:go_to_saml_sso_group_settings) Page::Group::Menu.perform(&:go_to_saml_sso_group_settings)
EE::Page::Group::Settings::SamlSSO.perform do |page| EE::Page::Group::Settings::SamlSSO.perform do |page|
page.set_id_provider_sso_url(QA::EE::Runtime::Saml.idp_sso_url) page.set_id_provider_sso_url(QA::EE::Runtime::Saml.idp_sso_url)
...@@ -84,7 +84,7 @@ module QA ...@@ -84,7 +84,7 @@ module QA
@group.visit! @group.visit!
EE::Page::Group::Menu.perform(&:go_to_saml_sso_group_settings) Page::Group::Menu.perform(&:go_to_saml_sso_group_settings)
EE::Page::Group::Settings::SamlSSO.perform do |page| EE::Page::Group::Settings::SamlSSO.perform do |page|
page.enforce_sso page.enforce_sso
......
...@@ -33,9 +33,9 @@ module QA ...@@ -33,9 +33,9 @@ module QA
it 'denies access' do it 'denies access' do
@group.sandbox.visit! @group.sandbox.visit!
EE::Page::Group::Menu.perform(&:click_group_general_settings_item) Page::Group::Menu.perform(&:click_group_general_settings_item)
EE::Page::Group::Settings::General.perform do |settings| Page::Group::Settings::General.perform do |settings|
settings.set_ip_address_restriction(get_next_ip_address) settings.set_ip_address_restriction(get_next_ip_address)
end end
...@@ -61,9 +61,9 @@ module QA ...@@ -61,9 +61,9 @@ module QA
it 'allows access' do it 'allows access' do
@group.sandbox.visit! @group.sandbox.visit!
EE::Page::Group::Menu.perform(&:click_group_general_settings_item) Page::Group::Menu.perform(&:click_group_general_settings_item)
EE::Page::Group::Settings::General.perform do |settings| Page::Group::Settings::General.perform do |settings|
settings.set_ip_address_restriction(get_current_ip_address) settings.set_ip_address_restriction(get_current_ip_address)
end end
......
...@@ -26,7 +26,7 @@ module QA ...@@ -26,7 +26,7 @@ module QA
group = Resource::Group.fabricate_via_api! group = Resource::Group.fabricate_via_api!
group.visit! group.visit!
EE::Page::Group::Menu.perform(&:click_group_insights_link) Page::Group::Menu.perform(&:click_group_insights_link)
end end
it_behaves_like 'default insights page' it_behaves_like 'default insights page'
......
...@@ -86,13 +86,13 @@ module QA ...@@ -86,13 +86,13 @@ module QA
Page::Main::Menu.perform(&:click_admin_area) Page::Main::Menu.perform(&:click_admin_area)
Page::Admin::Menu.perform(&:go_to_template_settings) Page::Admin::Menu.perform(&:go_to_template_settings)
EE::Page::Admin::Settings::Templates.perform do |page| Page::Admin::Settings::Templates.perform do |page|
page.choose_custom_project_template("#{@template_container_group_name}") page.choose_custom_project_template("#{@template_container_group_name}")
end end
Page::Admin::Menu.perform(&:go_to_template_settings) Page::Admin::Menu.perform(&:go_to_template_settings)
EE::Page::Admin::Settings::Templates.perform do |page| Page::Admin::Settings::Templates.perform do |page|
expect(page.current_custom_project_template).to include @template_container_group_name expect(page.current_custom_project_template).to include @template_container_group_name
end end
...@@ -136,13 +136,13 @@ module QA ...@@ -136,13 +136,13 @@ module QA
Page::Dashboard::Groups.perform { |page| page.click_group(Runtime::Namespace.sandbox_name) } Page::Dashboard::Groups.perform { |page| page.click_group(Runtime::Namespace.sandbox_name) }
Page::Project::Menu.perform(&:click_settings) Page::Project::Menu.perform(&:click_settings)
EE::Page::Group::Settings::General.perform do |settings| Page::Group::Settings::General.perform do |settings|
settings.choose_custom_project_template("#{@template_container_group_name}") settings.choose_custom_project_template("#{@template_container_group_name}")
end end
Page::Project::Menu.perform(&:click_settings) Page::Project::Menu.perform(&:click_settings)
EE::Page::Group::Settings::General.perform do |settings| Page::Group::Settings::General.perform do |settings|
expect(settings.current_custom_project_template).to include @template_container_group_name expect(settings.current_custom_project_template).to include @template_container_group_name
end end
......
...@@ -37,7 +37,7 @@ module QA ...@@ -37,7 +37,7 @@ module QA
end end
group.visit! group.visit!
QA::EE::Page::Group::Menu.perform(&:click_group_epics_link) Page::Group::Menu.perform(&:click_group_epics_link)
QA::EE::Page::Group::Epic::Index.perform do |index| QA::EE::Page::Group::Epic::Index.perform do |index|
index.click_first_epic(QA::EE::Page::Group::Epic::Show) index.click_first_epic(QA::EE::Page::Group::Epic::Show)
end end
......
...@@ -25,7 +25,7 @@ module QA ...@@ -25,7 +25,7 @@ module QA
Page::Dashboard::Groups.perform do |groups| Page::Dashboard::Groups.perform do |groups|
groups.click_group(group.path) groups.click_group(group.path)
end end
EE::Page::Group::Menu.perform(&:go_to_issue_boards) Page::Group::Menu.perform(&:go_to_issue_boards)
end end
it 'shows multiple group boards in the boards dropdown menu' do it 'shows multiple group boards in the boards dropdown menu' do
......
...@@ -98,7 +98,7 @@ module QA ...@@ -98,7 +98,7 @@ module QA
Page::Dashboard::Groups.perform do |page| Page::Dashboard::Groups.perform do |page|
page.click_group @project.group.path page.click_group @project.group.path
end end
EE::Page::Group::Menu.perform(&:click_group_security_link) Page::Group::Menu.perform(&:click_group_security_link)
EE::Page::Group::Secure::Show.perform do |dashboard| EE::Page::Group::Secure::Show.perform do |dashboard|
dashboard.filter_project(@project.name) dashboard.filter_project(@project.name)
......
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