2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
2018-11-08 19:23:39 +05:30
|
|
|
import createStore from '~/notes/stores';
|
2018-03-17 18:26:18 +05:30
|
|
|
import noteActions from '~/notes/components/note_actions.vue';
|
|
|
|
import { userDataMock } from '../mock_data';
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
describe('issue_note_actions component', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
let vm;
|
2018-11-08 19:23:39 +05:30
|
|
|
let store;
|
2018-03-17 18:26:18 +05:30
|
|
|
let Component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Component = Vue.extend(noteActions);
|
2018-11-08 19:23:39 +05:30
|
|
|
store = createStore();
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('user is logged in', () => {
|
|
|
|
let props;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
props = {
|
2018-11-08 19:23:39 +05:30
|
|
|
accessLevel: 'Maintainer',
|
2018-03-17 18:26:18 +05:30
|
|
|
authorId: 26,
|
|
|
|
canDelete: true,
|
|
|
|
canEdit: true,
|
2018-05-09 12:01:36 +05:30
|
|
|
canAwardEmoji: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
canReportAsAbuse: true,
|
2018-11-20 20:47:30 +05:30
|
|
|
noteId: '539',
|
2018-11-08 19:23:39 +05:30
|
|
|
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',
|
2018-03-17 18:26:18 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('actions dropdown', () => {
|
|
|
|
it('should be possible to edit the comment', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-note-edit')).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
it('should be possible to report abuse to GitLab', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector(`a[href="${props.reportAbusePath}"]`)).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should be possible to delete comment', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-note-delete')).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('user is not logged in', () => {
|
|
|
|
let props;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
store.dispatch('setUserData', {});
|
|
|
|
props = {
|
2018-11-08 19:23:39 +05:30
|
|
|
accessLevel: 'Maintainer',
|
2018-03-17 18:26:18 +05:30
|
|
|
authorId: 26,
|
|
|
|
canDelete: false,
|
|
|
|
canEdit: false,
|
2018-05-09 12:01:36 +05:30
|
|
|
canAwardEmoji: false,
|
2018-03-17 18:26:18 +05:30
|
|
|
canReportAsAbuse: false,
|
2018-11-20 20:47:30 +05:30
|
|
|
noteId: '539',
|
2018-11-08 19:23:39 +05:30
|
|
|
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',
|
2018-03-17 18:26:18 +05:30
|
|
|
};
|
|
|
|
vm = new Component({
|
|
|
|
store,
|
|
|
|
propsData: props,
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render emoji link', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-add-award')).toEqual(null);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render actions dropdown', () => {
|
|
|
|
expect(vm.$el.querySelector('.more-actions')).toEqual(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|