2017-08-11 11:39:16 -04:00
|
|
|
import Vue from 'vue';
|
2018-06-21 08:22:40 -04:00
|
|
|
import createStore from '~/notes/stores';
|
2017-12-04 11:19:07 -05:00
|
|
|
import noteActions from '~/notes/components/note_actions.vue';
|
2017-08-11 11:39:16 -04:00
|
|
|
import { userDataMock } from '../mock_data';
|
|
|
|
|
2018-04-06 14:19:37 -04:00
|
|
|
describe('issue_note_actions component', () => {
|
2017-08-11 11:39:16 -04:00
|
|
|
let vm;
|
2018-06-21 08:22:40 -04:00
|
|
|
let store;
|
2017-08-11 11:39:16 -04:00
|
|
|
let Component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-12-04 11:19:07 -05:00
|
|
|
Component = Vue.extend(noteActions);
|
2018-06-21 08:22:40 -04:00
|
|
|
store = createStore();
|
2017-08-11 11:39:16 -04:00
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:39:16 -04:00
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('user is logged in', () => {
|
2017-08-11 11:39:16 -04:00
|
|
|
let props;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
props = {
|
2018-05-22 07:55:07 -04:00
|
|
|
accessLevel: 'Maintainer',
|
2017-08-11 11:39:16 -04:00
|
|
|
authorId: 26,
|
|
|
|
canDelete: true,
|
|
|
|
canEdit: true,
|
2018-04-06 14:19:37 -04:00
|
|
|
canAwardEmoji: true,
|
2017-08-11 11:39:16 -04:00
|
|
|
canReportAsAbuse: true,
|
2018-09-07 09:39:20 -04:00
|
|
|
noteId: '539',
|
2018-06-21 08:22:40 -04:00
|
|
|
noteUrl: 'https://localhost:3000/group/project/merge_requests/1#note_1',
|
|
|
|
reportAbusePath:
|
|
|
|
'/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_539&user_id=26',
|
2017-08-11 11:39:16 -04:00
|
|
|
};
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:39:16 -04:00
|
|
|
store.dispatch('setUserData', userDataMock);
|
|
|
|
|
|
|
|
vm = new Component({
|
|
|
|
store,
|
|
|
|
propsData: props,
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render access level badge', () => {
|
|
|
|
expect(vm.$el.querySelector('.note-role').textContent.trim()).toEqual(props.accessLevel);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render emoji link', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-add-award')).toBeDefined();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('actions dropdown', () => {
|
|
|
|
it('should be possible to edit the comment', () => {
|
2017-08-11 11:39:16 -04:00
|
|
|
expect(vm.$el.querySelector('.js-note-edit')).toBeDefined();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should be possible to report as abuse', () => {
|
2017-08-11 11:39:16 -04:00
|
|
|
expect(vm.$el.querySelector(`a[href="${props.reportAbusePath}"]`)).toBeDefined();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
2018-09-07 09:39:20 -04:00
|
|
|
it('should be possible to copy link to a note', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-btn-copy-note-link')).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not show copy link action when `noteUrl` prop is empty', done => {
|
|
|
|
vm.noteUrl = '';
|
|
|
|
Vue.nextTick()
|
|
|
|
.then(() => {
|
|
|
|
expect(vm.$el.querySelector('.js-btn-copy-note-link')).toBeNull();
|
|
|
|
})
|
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
|
2017-08-04 11:51:35 -04:00
|
|
|
it('should be possible to delete comment', () => {
|
2017-08-11 11:39:16 -04:00
|
|
|
expect(vm.$el.querySelector('.js-note-delete')).toBeDefined();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('user is not logged in', () => {
|
2017-08-11 11:39:16 -04:00
|
|
|
let props;
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:39:16 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
store.dispatch('setUserData', {});
|
|
|
|
props = {
|
2018-05-22 07:55:07 -04:00
|
|
|
accessLevel: 'Maintainer',
|
2017-08-11 11:39:16 -04:00
|
|
|
authorId: 26,
|
|
|
|
canDelete: false,
|
|
|
|
canEdit: false,
|
2018-04-06 14:19:37 -04:00
|
|
|
canAwardEmoji: false,
|
2017-08-11 11:39:16 -04:00
|
|
|
canReportAsAbuse: false,
|
2018-09-07 09:39:20 -04:00
|
|
|
noteId: '539',
|
2018-06-21 08:22:40 -04:00
|
|
|
noteUrl: 'https://localhost:3000/group/project/merge_requests/1#note_1',
|
|
|
|
reportAbusePath:
|
|
|
|
'/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_539&user_id=26',
|
2017-08-11 11:39:16 -04:00
|
|
|
};
|
|
|
|
vm = new Component({
|
|
|
|
store,
|
|
|
|
propsData: props,
|
|
|
|
}).$mount();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
2017-08-11 11:39:16 -04:00
|
|
|
it('should not render emoji link', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-add-award')).toEqual(null);
|
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:39:16 -04:00
|
|
|
it('should not render actions dropdown', () => {
|
|
|
|
expect(vm.$el.querySelector('.more-actions')).toEqual(null);
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
});
|
2017-08-09 15:13:00 -04:00
|
|
|
});
|