debian-mirror-gitlab/spec/frontend_integration/ide/helpers/start.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-08-27 11:52:29 +05:30
import { editor as monacoEditor } from 'monaco-editor';
2021-10-27 15:23:28 +05:30
import setWindowLocation from 'helpers/set_window_location_helper';
2021-02-22 17:27:13 +05:30
import { TEST_HOST } from 'helpers/test_constants';
2022-10-11 01:57:18 +05:30
import { initLegacyWebIDE } from '~/ide';
2021-03-11 19:13:27 +05:30
import extendStore from '~/ide/stores/extend';
2022-01-26 12:08:38 +05:30
import { getProject, getEmptyProject } from 'jest/../frontend_integration/test_helpers/fixtures';
2021-03-11 19:13:27 +05:30
import { IDE_DATASET } from './mock_data';
export default (container, { isRepoEmpty = false, path = '', mrId = '' } = {}) => {
const projectName = isRepoEmpty ? 'lorem-ipsum-empty' : 'lorem-ipsum';
const pathSuffix = mrId ? `merge_requests/${mrId}` : `tree/master/-/${path}`;
2022-01-26 12:08:38 +05:30
const project = isRepoEmpty ? getEmptyProject() : getProject();
2021-02-22 17:27:13 +05:30
2021-10-27 15:23:28 +05:30
setWindowLocation(`${TEST_HOST}/-/ide/project/gitlab-test/${projectName}/${pathSuffix}`);
2021-02-22 17:27:13 +05:30
const el = document.createElement('div');
2022-01-26 12:08:38 +05:30
Object.assign(el.dataset, IDE_DATASET, { project: JSON.stringify(project) });
2021-02-22 17:27:13 +05:30
container.appendChild(el);
2022-10-11 01:57:18 +05:30
const vm = initLegacyWebIDE(el, { extendStore });
2021-03-08 18:12:59 +05:30
// We need to dispose of editor Singleton things or tests will bump into eachother
2022-08-27 11:52:29 +05:30
vm.$on('destroy', () => monacoEditor.getModels().forEach((model) => model.dispose()));
2021-03-08 18:12:59 +05:30
return vm;
2021-02-22 17:27:13 +05:30
};