2022-04-04 11:22:00 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Vue, { nextTick } from 'vue';
|
2020-03-13 15:44:24 +05:30
|
|
|
import Vuex from 'vuex';
|
|
|
|
import CollapsibleSidebar from '~/ide/components/panes/collapsible_sidebar.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import RightPane from '~/ide/components/panes/right.vue';
|
2018-11-08 19:23:39 +05:30
|
|
|
import { rightSidebarViews } from '~/ide/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { createStore } from '~/ide/stores';
|
2020-06-23 00:09:42 +05:30
|
|
|
import extendStore from '~/ide/stores/extend';
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
Vue.use(Vuex);
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('ide/components/panes/right.vue', () => {
|
|
|
|
let wrapper;
|
|
|
|
let store;
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const createComponent = (props) => {
|
2020-06-23 00:09:42 +05:30
|
|
|
extendStore(store, document.createElement('div'));
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
wrapper = shallowMount(RightPane, {
|
|
|
|
store,
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
store = createStore();
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2020-03-13 15:44:24 +05:30
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
describe('default', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders collapsible-sidebar', () => {
|
|
|
|
expect(wrapper.findComponent(CollapsibleSidebar).props()).toMatchObject({
|
|
|
|
side: 'right',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('pipelines tab', () => {
|
|
|
|
it('is always shown', () => {
|
|
|
|
createComponent();
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(wrapper.findComponent(CollapsibleSidebar).props('extensionTabs')).toEqual(
|
2020-03-13 15:44:24 +05:30
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
show: true,
|
|
|
|
title: 'Pipelines',
|
|
|
|
views: expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
name: rightSidebarViews.pipelines.name,
|
|
|
|
}),
|
|
|
|
expect.objectContaining({
|
|
|
|
name: rightSidebarViews.jobsDetail.name,
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
);
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('clientside live preview tab', () => {
|
|
|
|
it('is shown if there is a packageJson and clientsidePreviewEnabled', () => {
|
|
|
|
Vue.set(store.state.entries, 'package.json', {
|
2020-01-01 13:55:28 +05:30
|
|
|
name: 'package.json',
|
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
store.state.clientsidePreviewEnabled = true;
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
createComponent();
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(wrapper.findComponent(CollapsibleSidebar).props('extensionTabs')).toEqual(
|
2020-03-13 15:44:24 +05:30
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
show: true,
|
|
|
|
title: 'Live preview',
|
|
|
|
views: expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
name: rightSidebarViews.clientSidePreview.name,
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
describe('terminal tab', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('adds terminal tab', async () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
store.state.terminal.isVisible = true;
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
await nextTick();
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(wrapper.findComponent(CollapsibleSidebar).props('extensionTabs')).toEqual(
|
2022-04-04 11:22:00 +05:30
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
show: true,
|
|
|
|
title: 'Terminal',
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('hides terminal tab when not visible', () => {
|
|
|
|
store.state.terminal.isVisible = false;
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(wrapper.findComponent(CollapsibleSidebar).props('extensionTabs')).toEqual(
|
2020-06-23 00:09:42 +05:30
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
show: false,
|
|
|
|
title: 'Terminal',
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|