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 { ...@@ -128,6 +128,9 @@ export default {
isIssue() { isIssue() {
return this.targetType === 'issue'; return this.targetType === 'issue';
}, },
canAssign() {
return this.getNoteableData.current_user?.can_update && this.isIssue;
},
}, },
methods: { methods: {
onEdit() { onEdit() {
...@@ -257,7 +260,7 @@ export default { ...@@ -257,7 +260,7 @@ export default {
{{ __('Copy link') }} {{ __('Copy link') }}
</button> </button>
</li> </li>
<li v-if="isIssue"> <li v-if="canAssign">
<button <button
class="btn-default btn-transparent" class="btn-default btn-transparent"
data-testid="assign-user" 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', () => { ...@@ -127,25 +127,63 @@ describe('noteActions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('should be possible to assign or unassign the comment author', () => { it('should not be possible to assign or unassign the comment author in a merge request', () => {
wrapper = shallowMountNoteActions(props, {
targetType: () => 'issue',
});
const assignUserButton = wrapper.find('[data-testid="assign-user"]'); const assignUserButton = wrapper.find('[data-testid="assign-user"]');
expect(assignUserButton.exists()).toBe(true); expect(assignUserButton.exists()).toBe(false);
});
});
});
assignUserButton.trigger('click'); describe('when a user has access to edit an issue', () => {
axiosMock.onPut(`${TEST_HOST}/api/v4/projects/group/project/issues/1`).reply(() => { const testButtonClickTriggersAction = () => {
expect(actions.updateAssignees).toHaveBeenCalled(); 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"]');
const assignUserButton = wrapper.find('[data-testid="assign-user"]'); expect(assignUserButton.exists()).toBe(true);
expect(assignUserButton.exists()).toBe(false); 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', () => { 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