Commit 05023a7c authored by Anastasia McDonald's avatar Anastasia McDonald

Merge branch 'e2e-project-permissions-spec' into 'master'

E2E: Personal Project Permissions Spec

See merge request gitlab-org/gitlab!81551
parents 1aad6b9b b632d605
......@@ -31,7 +31,10 @@ export default {
computed: {
actionPrimary() {
return {
attributes: { variant: 'danger' },
attributes: {
variant: 'danger',
'data-qa-selector': 'confirm_delete_issue_button',
},
text: this.title,
};
},
......
......@@ -290,6 +290,7 @@ export default {
class="gl-display-none gl-sm-display-inline-flex! gl-ml-3"
icon="ellipsis_v"
category="tertiary"
data-qa-selector="issue_actions_ellipsis_dropdown"
:text="dropdownText"
:text-sr-only="true"
data-testid="desktop-dropdown"
......@@ -323,6 +324,7 @@ export default {
<gl-dropdown-item
v-gl-modal="$options.deleteModalId"
variant="danger"
data-qa-selector="delete_issue_button"
@click="track('click_dropdown')"
>
{{ deleteButtonText }}
......
......@@ -23,6 +23,12 @@ module QA
end
end
def filter_by_name(name)
within_element(:project_filter_form) do
fill_in :name, with: name
end
end
def go_to_project(name)
filter_by_name(name)
......@@ -40,14 +46,6 @@ module QA
def clear_project_filter
fill_element(:project_filter_form, "")
end
private
def filter_by_name(name)
within_element(:project_filter_form) do
fill_in :name, with: name
end
end
end
end
end
......
# frozen_string_literal: true
module QA
module Page
module Modal
class DeleteIssue < Base
view 'app/assets/javascripts/issues/show/components/delete_issue_modal.vue' do
element :confirm_delete_issue_button, required: true
end
def confirm_delete_issue
click_element :confirm_delete_issue_button
end
end
end
end
end
......@@ -18,6 +18,8 @@ module QA
view 'app/assets/javascripts/issues/show/components/header_actions.vue' do
element :close_issue_button
element :reopen_issue_button
element :issue_actions_ellipsis_dropdown
element :delete_issue_button
end
view 'app/assets/javascripts/related_issues/components/add_issuable_form.vue' do
......@@ -69,6 +71,20 @@ module QA
def has_reopen_issue_button?
has_element?(:reopen_issue_button)
end
def has_delete_issue_button?
click_element(:issue_actions_ellipsis_dropdown)
has_element?(:delete_issue_button)
end
def delete_issue
click_element(:issue_actions_ellipsis_dropdown)
click_element(:delete_issue_button, Page::Modal::DeleteIssue)
Page::Modal::DeleteIssue.perform(&:confirm_delete_issue)
wait_for_requests
end
end
end
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Manage' do
describe 'Personal project permissions' do
let!(:owner) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
let!(:owner_api_client) { Runtime::API::Client.new(:gitlab, user: owner) }
let!(:project) do
Resource::Project.fabricate_via_api! do |project|
project.api_client = owner_api_client
project.name = 'qa-owner-personal-project'
project.personal_namespace = owner.username
end
end
after do
project&.remove_via_api!
end
context 'when user is added as Owner' do
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.api_client = owner_api_client
issue.project = project
issue.title = 'Test Owner deletes issue'
end
end
before do
Flow::Login.sign_in(as: owner)
end
it "has Owner role with Owner permissions", testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/352542' do
Page::Dashboard::Projects.perform do |projects|
projects.filter_by_name(project.name)
expect(projects).to have_project_with_access_role(project.name, 'Owner')
end
expect_owner_permissions_allow_delete_issue
end
end
context 'when user is added as Maintainer' do
let(:maintainer) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.api_client = owner_api_client
issue.project = project
issue.title = 'Test Maintainer deletes issue'
end
end
before do
project.add_member(maintainer, Resource::Members::AccessLevel::MAINTAINER)
Flow::Login.sign_in(as: maintainer)
end
it "has Maintainer role without Owner permissions", testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/352607' do
Page::Dashboard::Projects.perform do |projects|
projects.filter_by_name(project.name)
expect(projects).to have_project_with_access_role(project.name, 'Maintainer')
end
expect_maintainer_permissions_do_not_allow_delete_issue
end
end
private
def expect_owner_permissions_allow_delete_issue
expect do
issue.visit!
Page::Project::Issue::Show.perform(&:delete_issue)
Page::Project::Issue::Index.perform do |index|
expect(index).not_to have_issue(issue)
end
end.not_to raise_error
end
def expect_maintainer_permissions_do_not_allow_delete_issue
expect do
issue.visit!
Page::Project::Issue::Show.perform do |issue|
expect(issue).not_to have_delete_issue_button
end
end.not_to raise_error
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