Commit f348d617 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '224528-un-assign-issue-to-from-comment-author-action-visibility' into 'master'

Resolve "(Un)Assign Issue to/from Comment Author Action Visibility"

Closes #224528

See merge request gitlab-org/gitlab!35459
parents f87bbb46 77ee604f
......@@ -128,6 +128,9 @@ export default {
isIssue() {
return this.targetType === 'issue';
},
canAssign() {
return this.getNoteableData.current_user?.can_update && this.isIssue;
},
},
methods: {
onEdit() {
......@@ -257,7 +260,7 @@ export default {
{{ __('Copy link') }}
</button>
</li>
<li v-if="isIssue">
<li v-if="canAssign">
<button
class="btn-default btn-transparent"
data-testid="assign-user"
......
---
title: Resolve [Un]Assign Issue to/from Comment Author Action Visibility
merge_request: 35459
author:
type: fixed
......@@ -127,25 +127,63 @@ describe('noteActions', () => {
.catch(done.fail);
});
it('should be possible to assign or unassign the comment author', () => {
wrapper = shallowMountNoteActions(props, {
targetType: () => 'issue',
});
it('should not be possible to assign or unassign the comment author in a merge request', () => {
const assignUserButton = wrapper.find('[data-testid="assign-user"]');
expect(assignUserButton.exists()).toBe(true);
expect(assignUserButton.exists()).toBe(false);
});
});
});
assignUserButton.trigger('click');
axiosMock.onPut(`${TEST_HOST}/api/v4/projects/group/project/issues/1`).reply(() => {
expect(actions.updateAssignees).toHaveBeenCalled();
});
describe('when a user has access to edit an issue', () => {
const testButtonClickTriggersAction = () => {
axiosMock.onPut(`${TEST_HOST}/api/v4/projects/group/project/issues/1`).reply(() => {
expect(actions.updateAssignees).toHaveBeenCalled();
});
it('should not be possible to assign or unassign the comment author in a merge request', () => {
const assignUserButton = wrapper.find('[data-testid="assign-user"]');
expect(assignUserButton.exists()).toBe(false);
const assignUserButton = wrapper.find('[data-testid="assign-user"]');
expect(assignUserButton.exists()).toBe(true);
assignUserButton.trigger('click');
};
beforeEach(() => {
wrapper = shallowMountNoteActions(props, {
targetType: () => 'issue',
});
store.state.noteableData = {
current_user: {
can_update: true,
},
};
store.state.userData = userDataMock;
});
afterEach(() => {
wrapper.destroy();
axiosMock.restore();
});
it('should be possible to assign the comment author', testButtonClickTriggersAction);
it('should be possible to unassign the comment author', testButtonClickTriggersAction);
});
describe('when a user does not have access to edit an issue', () => {
const testButtonDoesNotRender = () => {
const assignUserButton = wrapper.find('[data-testid="assign-user"]');
expect(assignUserButton.exists()).toBe(false);
};
beforeEach(() => {
wrapper = shallowMountNoteActions(props, {
targetType: () => 'issue',
});
});
afterEach(() => {
wrapper.destroy();
});
it('should not be possible to assign the comment author', testButtonDoesNotRender);
it('should not be possible to unassign the comment author', testButtonDoesNotRender);
});
describe('user is not logged in', () => {
......
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