2022-04-04 11:22:00 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
import Vuex from 'vuex';
|
2021-02-22 17:27:13 +05:30
|
|
|
import waitForPromises from 'helpers/wait_for_promises';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { TEST_HOST } from 'spec/test_constants';
|
2020-06-23 00:09:42 +05:30
|
|
|
import TerminalEmptyState from '~/ide/components/terminal/empty_state.vue';
|
|
|
|
import TerminalSession from '~/ide/components/terminal/session.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import TerminalView from '~/ide/components/terminal/view.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
const TEST_HELP_PATH = `${TEST_HOST}/help`;
|
|
|
|
const TEST_SVG_PATH = `${TEST_HOST}/illustration.svg`;
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
Vue.use(Vuex);
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
describe('IDE TerminalView', () => {
|
|
|
|
let state;
|
|
|
|
let actions;
|
|
|
|
let getters;
|
|
|
|
let wrapper;
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
const factory = async () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const store = new Vuex.Store({
|
|
|
|
modules: {
|
|
|
|
terminal: {
|
|
|
|
namespaced: true,
|
|
|
|
state,
|
|
|
|
actions,
|
|
|
|
getters,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
wrapper = shallowMount(TerminalView, { store });
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
// Uses deferred components, so wait for those to load...
|
|
|
|
await waitForPromises();
|
2020-06-23 00:09:42 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
state = {
|
|
|
|
isShowSplash: true,
|
|
|
|
paths: {
|
|
|
|
webTerminalHelpPath: TEST_HELP_PATH,
|
|
|
|
webTerminalSvgPath: TEST_SVG_PATH,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
actions = {
|
|
|
|
hideSplash: jest.fn().mockName('hideSplash'),
|
|
|
|
startSession: jest.fn().mockName('startSession'),
|
|
|
|
};
|
|
|
|
|
|
|
|
getters = {
|
|
|
|
allCheck: () => ({
|
|
|
|
isLoading: false,
|
|
|
|
isValid: false,
|
|
|
|
message: 'bad',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it('renders empty state', async () => {
|
|
|
|
await factory();
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
expect(wrapper.find(TerminalEmptyState).props()).toEqual({
|
|
|
|
helpPath: TEST_HELP_PATH,
|
|
|
|
illustrationPath: TEST_SVG_PATH,
|
|
|
|
...getters.allCheck(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it('hides splash and starts, when started', async () => {
|
|
|
|
await factory();
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
expect(actions.startSession).not.toHaveBeenCalled();
|
|
|
|
expect(actions.hideSplash).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
wrapper.find(TerminalEmptyState).vm.$emit('start');
|
|
|
|
|
|
|
|
expect(actions.startSession).toHaveBeenCalled();
|
|
|
|
expect(actions.hideSplash).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it('shows Web Terminal when started', async () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
state.isShowSplash = false;
|
2021-02-22 17:27:13 +05:30
|
|
|
await factory();
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
expect(wrapper.find(TerminalEmptyState).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(TerminalSession).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|