2018-07-05 05:10:28 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import '~/behaviors/markdown/render_gfm';
|
2019-12-11 10:07:38 -05:00
|
|
|
import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
|
2018-07-05 05:10:28 -04:00
|
|
|
import { createStore } from '~/ide/stores';
|
|
|
|
import RightPane from '~/ide/components/panes/right.vue';
|
|
|
|
import { rightSidebarViews } from '~/ide/constants';
|
|
|
|
|
|
|
|
describe('IDE right pane', () => {
|
|
|
|
let Component;
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
Component = Vue.extend(RightPane);
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const store = createStore();
|
|
|
|
|
|
|
|
vm = createComponentWithStore(Component, store).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('active', () => {
|
|
|
|
it('renders merge request button as active', done => {
|
2018-09-27 17:57:30 -04:00
|
|
|
vm.$store.state.rightPane.isOpen = true;
|
|
|
|
vm.$store.state.rightPane.currentView = rightSidebarViews.mergeRequestInfo.name;
|
2018-07-05 05:10:28 -04:00
|
|
|
vm.$store.state.currentMergeRequestId = '123';
|
|
|
|
vm.$store.state.currentProjectId = 'gitlab-ce';
|
|
|
|
vm.$store.state.currentMergeRequestId = 1;
|
|
|
|
vm.$store.state.projects['gitlab-ce'] = {
|
|
|
|
mergeRequests: {
|
|
|
|
1: {
|
|
|
|
iid: 1,
|
|
|
|
title: 'Testing',
|
|
|
|
title_html: '<span class="title-html">Testing</span>',
|
|
|
|
description: 'Description',
|
|
|
|
description_html: '<p class="description-html">Description HTML</p>',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-09-27 17:57:30 -04:00
|
|
|
vm.$nextTick()
|
|
|
|
.then(() => {
|
|
|
|
expect(vm.$el.querySelector('.ide-sidebar-link.active')).not.toBe(null);
|
|
|
|
expect(
|
|
|
|
vm.$el.querySelector('.ide-sidebar-link.active').getAttribute('data-original-title'),
|
|
|
|
).toBe('Merge Request');
|
|
|
|
})
|
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
2018-07-05 05:10:28 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('click', () => {
|
|
|
|
beforeEach(() => {
|
2019-12-06 19:07:51 -05:00
|
|
|
jest.spyOn(vm, 'open').mockReturnValue();
|
2018-07-05 05:10:28 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('sets view to merge request', done => {
|
|
|
|
vm.$store.state.currentMergeRequestId = '123';
|
|
|
|
|
|
|
|
vm.$nextTick(() => {
|
|
|
|
vm.$el.querySelector('.ide-sidebar-link').click();
|
|
|
|
|
2018-09-27 17:57:30 -04:00
|
|
|
expect(vm.open).toHaveBeenCalledWith(rightSidebarViews.mergeRequestInfo);
|
2018-07-05 05:10:28 -04:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-06-13 12:06:35 -04:00
|
|
|
|
|
|
|
describe('live preview', () => {
|
|
|
|
it('renders live preview button', done => {
|
2019-12-06 19:07:51 -05:00
|
|
|
Vue.set(vm.$store.state.entries, 'package.json', {
|
|
|
|
name: 'package.json',
|
|
|
|
});
|
2018-06-13 12:06:35 -04:00
|
|
|
vm.$store.state.clientsidePreviewEnabled = true;
|
|
|
|
|
|
|
|
vm.$nextTick(() => {
|
|
|
|
expect(vm.$el.querySelector('button[aria-label="Live preview"]')).not.toBeNull();
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-07-05 05:10:28 -04:00
|
|
|
});
|