diff options
Diffstat (limited to 'spec/frontend/notes/components')
6 files changed, 67 insertions, 23 deletions
diff --git a/spec/frontend/notes/components/discussion_actions_spec.js b/spec/frontend/notes/components/discussion_actions_spec.js index 3e1e43d0c6a..b26eb00bfdc 100644 --- a/spec/frontend/notes/components/discussion_actions_spec.js +++ b/spec/frontend/notes/components/discussion_actions_spec.js @@ -13,11 +13,11 @@ const createDiscussionMock = (props = {}) => const createNoteMock = (props = {}) => Object.assign(JSON.parse(JSON.stringify(discussionMock.notes[0])), props); const createResolvableNote = () => - createNoteMock({ resolvable: true, current_user: { can_resolve: true } }); + createNoteMock({ resolvable: true, current_user: { can_resolve_discussion: true } }); const createUnresolvableNote = () => - createNoteMock({ resolvable: false, current_user: { can_resolve: false } }); + createNoteMock({ resolvable: false, current_user: { can_resolve_discussion: false } }); const createUnallowedNote = () => - createNoteMock({ resolvable: true, current_user: { can_resolve: false } }); + createNoteMock({ resolvable: true, current_user: { can_resolve_discussion: false } }); describe('DiscussionActions', () => { let wrapper; diff --git a/spec/frontend/notes/components/discussion_filter_note_spec.js b/spec/frontend/notes/components/discussion_filter_note_spec.js index 4701108d315..d35f8f7c28d 100644 --- a/spec/frontend/notes/components/discussion_filter_note_spec.js +++ b/spec/frontend/notes/components/discussion_filter_note_spec.js @@ -1,4 +1,5 @@ import { shallowMount } from '@vue/test-utils'; +import { GlButton, GlSprintf } from '@gitlab/ui'; import DiscussionFilterNote from '~/notes/components/discussion_filter_note.vue'; import eventHub from '~/notes/event_hub'; @@ -6,7 +7,11 @@ describe('DiscussionFilterNote component', () => { let wrapper; const createComponent = () => { - wrapper = shallowMount(DiscussionFilterNote); + wrapper = shallowMount(DiscussionFilterNote, { + stubs: { + GlSprintf, + }, + }); }; beforeEach(() => { @@ -19,21 +24,27 @@ describe('DiscussionFilterNote component', () => { }); it('timelineContent renders a string containing instruction for switching feed type', () => { - expect(wrapper.find({ ref: 'timelineContent' }).html()).toBe( - "<div>You're only seeing <b>other activity</b> in the feed. To add a comment, switch to one of the following options.</div>", + expect(wrapper.find('[data-testid="discussion-filter-timeline-content"]').html()).toBe( + '<div data-testid="discussion-filter-timeline-content">You\'re only seeing <b>other activity</b> in the feed. To add a comment, switch to one of the following options.</div>', ); }); it('emits `dropdownSelect` event with 0 parameter on clicking Show all activity button', () => { jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); - wrapper.find({ ref: 'showAllActivity' }).vm.$emit('click'); + wrapper + .findAll(GlButton) + .at(0) + .vm.$emit('click'); expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 0); }); it('emits `dropdownSelect` event with 1 parameter on clicking Show comments only button', () => { jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); - wrapper.find({ ref: 'showComments' }).vm.$emit('click'); + wrapper + .findAll(GlButton) + .at(1) + .vm.$emit('click'); expect(eventHub.$emit).toHaveBeenCalledWith('dropdownSelect', 1); }); diff --git a/spec/frontend/notes/components/note_actions_spec.js b/spec/frontend/notes/components/note_actions_spec.js index a79c3bbacb7..f01c6c6b84e 100644 --- a/spec/frontend/notes/components/note_actions_spec.js +++ b/spec/frontend/notes/components/note_actions_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import { shallowMount, createLocalVue, createWrapper } from '@vue/test-utils'; +import { mount, createLocalVue, createWrapper } from '@vue/test-utils'; import { TEST_HOST } from 'spec/test_constants'; import AxiosMockAdapter from 'axios-mock-adapter'; import createStore from '~/notes/stores'; @@ -14,9 +14,9 @@ describe('noteActions', () => { let actions; let axiosMock; - const shallowMountNoteActions = (propsData, computed) => { + const mountNoteActions = (propsData, computed) => { const localVue = createLocalVue(); - return shallowMount(localVue.extend(noteActions), { + return mount(localVue.extend(noteActions), { store, propsData, localVue, @@ -61,7 +61,7 @@ describe('noteActions', () => { beforeEach(() => { store.dispatch('setUserData', userDataMock); - wrapper = shallowMountNoteActions(props); + wrapper = mountNoteActions(props); }); it('should render noteable author badge', () => { @@ -178,7 +178,7 @@ describe('noteActions', () => { }; beforeEach(() => { - wrapper = shallowMountNoteActions(props, { + wrapper = mountNoteActions(props, { targetType: () => 'issue', }); store.state.noteableData = { @@ -205,7 +205,7 @@ describe('noteActions', () => { }; beforeEach(() => { - wrapper = shallowMountNoteActions(props, { + wrapper = mountNoteActions(props, { targetType: () => 'issue', }); }); @@ -221,7 +221,7 @@ describe('noteActions', () => { describe('user is not logged in', () => { beforeEach(() => { store.dispatch('setUserData', {}); - wrapper = shallowMountNoteActions({ + wrapper = mountNoteActions({ ...props, canDelete: false, canEdit: false, @@ -241,7 +241,7 @@ describe('noteActions', () => { describe('for showReply = true', () => { beforeEach(() => { - wrapper = shallowMountNoteActions({ + wrapper = mountNoteActions({ ...props, showReply: true, }); @@ -256,7 +256,7 @@ describe('noteActions', () => { describe('for showReply = false', () => { beforeEach(() => { - wrapper = shallowMountNoteActions({ + wrapper = mountNoteActions({ ...props, showReply: false, }); @@ -273,7 +273,7 @@ describe('noteActions', () => { beforeEach(() => { store.dispatch('setUserData', userDataMock); - wrapper = shallowMountNoteActions({ ...props, canResolve: true, isDraft: true }); + wrapper = mountNoteActions({ ...props, canResolve: true, isDraft: true }); }); it('should render the right resolve button title', () => { diff --git a/spec/frontend/notes/components/note_awards_list_spec.js b/spec/frontend/notes/components/note_awards_list_spec.js index dce5424f154..5ab183e5452 100644 --- a/spec/frontend/notes/components/note_awards_list_spec.js +++ b/spec/frontend/notes/components/note_awards_list_spec.js @@ -92,15 +92,14 @@ describe('note_awards_list component', () => { }).$mount(); }; - const findTooltip = () => - vm.$el.querySelector('[data-original-title]').getAttribute('data-original-title'); + const findTooltip = () => vm.$el.querySelector('[title]').getAttribute('title'); it('should only escape & and " characters', () => { awardsMock = [...new Array(1)].map(createAwardEmoji); mountComponent(); const escapedName = awardsMock[0].user.name.replace(/&/g, '&').replace(/"/g, '"'); - expect(vm.$el.querySelector('[data-original-title]').outerHTML).toContain(escapedName); + expect(vm.$el.querySelector('[title]').outerHTML).toContain(escapedName); }); it('should not escape special HTML characters twice when only 1 person awarded', () => { diff --git a/spec/frontend/notes/components/note_form_spec.js b/spec/frontend/notes/components/note_form_spec.js index a5b5204509e..cc434d6c952 100644 --- a/spec/frontend/notes/components/note_form_spec.js +++ b/spec/frontend/notes/components/note_form_spec.js @@ -272,6 +272,7 @@ describe('issue_note_form component', () => { wrapper = createComponentWrapper(); wrapper.setProps({ ...props, + isDraft: true, noteId: '', discussion: { ...discussionMock, for_commit: false }, }); @@ -292,6 +293,27 @@ describe('issue_note_form component', () => { expect(wrapper.find('.js-resolve-checkbox').exists()).toBe(true); }); + it('hides resolve checkbox', async () => { + wrapper.setProps({ + isDraft: false, + discussion: { + ...discussionMock, + notes: [ + ...discussionMock.notes.map(n => ({ + ...n, + resolvable: true, + current_user: { ...n.current_user, can_resolve_discussion: false }, + })), + ], + for_commit: false, + }, + }); + + await wrapper.vm.$nextTick(); + + expect(wrapper.find('.js-resolve-checkbox').exists()).toBe(false); + }); + it('hides actions for commits', () => { wrapper.setProps({ discussion: { for_commit: true } }); diff --git a/spec/frontend/notes/components/note_header_spec.js b/spec/frontend/notes/components/note_header_spec.js index 2bb08b60569..69aab0d051e 100644 --- a/spec/frontend/notes/components/note_header_spec.js +++ b/spec/frontend/notes/components/note_header_spec.js @@ -1,7 +1,9 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import { nextTick } from 'vue'; import Vuex from 'vuex'; +import { GlSprintf } from '@gitlab/ui'; import NoteHeader from '~/notes/components/note_header.vue'; +import { AVAILABILITY_STATUS } from '~/set_status_modal/utils'; const localVue = createLocalVue(); localVue.use(Vuex); @@ -28,6 +30,9 @@ describe('NoteHeader component', () => { path: '/root', state: 'active', username: 'root', + status: { + availability: '', + }, }; const createComponent = props => { @@ -37,6 +42,7 @@ describe('NoteHeader component', () => { actions, }), propsData: { ...props }, + stubs: { GlSprintf }, }); }; @@ -78,7 +84,7 @@ describe('NoteHeader component', () => { expanded: true, }); - expect(findChevronIcon().classes()).toContain('fa-chevron-up'); + expect(findChevronIcon().props('name')).toBe('chevron-up'); }); it('has chevron-down icon if expanded prop is false', () => { @@ -87,7 +93,7 @@ describe('NoteHeader component', () => { expanded: false, }); - expect(findChevronIcon().classes()).toContain('fa-chevron-down'); + expect(findChevronIcon().props('name')).toBe('chevron-down'); }); }); @@ -97,6 +103,12 @@ describe('NoteHeader component', () => { expect(wrapper.find('.js-user-link').exists()).toBe(true); }); + it('renders busy status if author availability is set', () => { + createComponent({ author: { ...author, status: { availability: AVAILABILITY_STATUS.BUSY } } }); + + expect(wrapper.find('.js-user-link').text()).toContain('(Busy)'); + }); + it('renders deleted user text if author is not passed as a prop', () => { createComponent(); |