Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-07 12:09:15 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-07 12:09:15 +0300
commit708815aefead73a61473c1a611aea169ab16a358 (patch)
treeab884f50fcbcab73d1c2ba4a5ade563f9a6456d5 /spec/frontend/work_items
parent02b949f3b64f88e97abec62c355ca1b1da2bd460 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/work_items')
-rw-r--r--spec/frontend/work_items/components/notes/work_item_note_actions_spec.js27
-rw-r--r--spec/frontend/work_items/components/notes/work_item_note_spec.js41
2 files changed, 67 insertions, 1 deletions
diff --git a/spec/frontend/work_items/components/notes/work_item_note_actions_spec.js b/spec/frontend/work_items/components/notes/work_item_note_actions_spec.js
index 9f796c8663f..dcce89bdf09 100644
--- a/spec/frontend/work_items/components/notes/work_item_note_actions_spec.js
+++ b/spec/frontend/work_items/components/notes/work_item_note_actions_spec.js
@@ -3,6 +3,7 @@ import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
+import { createMockDirective } from 'helpers/vue_mock_directive';
import EmojiPicker from '~/emoji/components/picker.vue';
import waitForPromises from 'helpers/wait_for_promises';
import ReplyButton from '~/notes/components/note_actions/reply_button.vue';
@@ -23,6 +24,7 @@ describe('Work Item Note Actions', () => {
const findCopyLinkButton = () => wrapper.find('[data-testid="copy-link-action"]');
const findAssignUnassignButton = () => wrapper.find('[data-testid="assign-note-action"]');
const findReportAbuseToAdminButton = () => wrapper.find('[data-testid="abuse-note-action"]');
+ const findAuthorBadge = () => wrapper.find('[data-testid="author-badge"]');
const addEmojiMutationResolver = jest.fn().mockResolvedValue({
data: {
@@ -41,6 +43,8 @@ describe('Work Item Note Actions', () => {
showAwardEmoji = true,
showAssignUnassign = false,
canReportAbuse = false,
+ workItemType = 'Task',
+ isWorkItemAuthor = false,
} = {}) => {
wrapper = shallowMount(WorkItemNoteActions, {
propsData: {
@@ -50,6 +54,8 @@ describe('Work Item Note Actions', () => {
showAwardEmoji,
showAssignUnassign,
canReportAbuse,
+ workItemType,
+ isWorkItemAuthor,
},
provide: {
glFeatures: {
@@ -60,6 +66,9 @@ describe('Work Item Note Actions', () => {
EmojiPicker: EmojiPickerStub,
},
apolloProvider: createMockApollo([[addAwardEmojiMutation, addEmojiMutationResolver]]),
+ directives: {
+ GlTooltip: createMockDirective('gl-tooltip'),
+ },
});
wrapper.vm.$refs.dropdown.close = jest.fn();
};
@@ -225,4 +234,22 @@ describe('Work Item Note Actions', () => {
expect(wrapper.emitted('reportAbuse')).toEqual([[]]);
});
});
+
+ describe('user role badges', () => {
+ describe('author badge', () => {
+ it('does not show the author badge by default', () => {
+ createComponent();
+
+ expect(findAuthorBadge().exists()).toBe(false);
+ });
+
+ it('shows the author badge when the work item is author by the current User', () => {
+ createComponent({ isWorkItemAuthor: true });
+
+ expect(findAuthorBadge().exists()).toBe(true);
+ expect(findAuthorBadge().text()).toBe('Author');
+ expect(findAuthorBadge().attributes('title')).toBe('This user is the author of this task.');
+ });
+ });
+ });
});
diff --git a/spec/frontend/work_items/components/notes/work_item_note_spec.js b/spec/frontend/work_items/components/notes/work_item_note_spec.js
index 645d0e98c0b..39ce3193ee6 100644
--- a/spec/frontend/work_items/components/notes/work_item_note_spec.js
+++ b/spec/frontend/work_items/components/notes/work_item_note_spec.js
@@ -33,6 +33,23 @@ describe('Work Item Note', () => {
const updatedNoteBody = '<h1 data-sourcepos="1:1-1:12" dir="auto">Some title</h1>';
const mockWorkItemId = workItemQueryResponse.data.workItem.id;
+ const mockWorkItemByDifferentUser = {
+ data: {
+ workItem: {
+ ...workItemQueryResponse.data.workItem,
+ author: {
+ avatarUrl:
+ 'http://127.0.0.1:3000/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
+ id: 'gid://gitlab/User/2',
+ name: 'User 1',
+ username: 'user1',
+ webUrl: 'http://127.0.0.1:3000/user1',
+ __typename: 'UserCore',
+ },
+ },
+ },
+ };
+
const successHandler = jest.fn().mockResolvedValue({
data: {
updateNote: {
@@ -47,6 +64,9 @@ describe('Work Item Note', () => {
});
const workItemResponseHandler = jest.fn().mockResolvedValue(workItemByIidResponseFactory());
+ const workItemByAuthoredByDifferentUser = jest
+ .fn()
+ .mockResolvedValue(mockWorkItemByDifferentUser);
const updateWorkItemMutationSuccessHandler = jest
.fn()
@@ -69,6 +89,7 @@ describe('Work Item Note', () => {
workItemId = mockWorkItemId,
updateWorkItemMutationHandler = updateWorkItemMutationSuccessHandler,
assignees = mockAssignees,
+ workItemByIidResponseHandler = workItemResponseHandler,
} = {}) => {
wrapper = shallowMount(WorkItemNote, {
provide: {
@@ -85,7 +106,7 @@ describe('Work Item Note', () => {
assignees,
},
apolloProvider: mockApollo([
- [workItemByIidQuery, workItemResponseHandler],
+ [workItemByIidQuery, workItemByIidResponseHandler],
[updateWorkItemNoteMutation, updateNoteMutationHandler],
[updateWorkItemMutation, updateWorkItemMutationHandler],
]),
@@ -336,5 +357,23 @@ describe('Work Item Note', () => {
expect(findNoteHeader().props('isInternalNote')).toBe(true);
});
});
+
+ describe('author and user role badges', () => {
+ describe('author badge props', () => {
+ it.each`
+ isWorkItemAuthor | sameAsCurrentUser | workItemByIidResponseHandler
+ ${true} | ${'same as'} | ${workItemResponseHandler}
+ ${false} | ${'not same as'} | ${workItemByAuthoredByDifferentUser}
+ `(
+ 'should pass correct isWorkItemAuthor `$isWorkItemAuthor` to note actions when author is $sameAsCurrentUser as current note',
+ async ({ isWorkItemAuthor, workItemByIidResponseHandler }) => {
+ createComponent({ workItemByIidResponseHandler });
+ await waitForPromises();
+
+ expect(findNoteActions().props('isWorkItemAuthor')).toBe(isWorkItemAuthor);
+ },
+ );
+ });
+ });
});
});