Welcome to mirror list, hosted at ThFree Co, Russian Federation.

start.js « helpers « ide « frontend_integration « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 925db12f36e1538a8d53215e7d84b46e954fd07a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { editor as monacoEditor } from 'monaco-editor';
import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants';
import { initIde } from '~/ide';
import extendStore from '~/ide/stores/extend';
import { getProject, getEmptyProject } from 'jest/../frontend_integration/test_helpers/fixtures';
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}`;
  const project = isRepoEmpty ? getEmptyProject() : getProject();

  setWindowLocation(`${TEST_HOST}/-/ide/project/gitlab-test/${projectName}/${pathSuffix}`);

  const el = document.createElement('div');
  Object.assign(el.dataset, IDE_DATASET, { project: JSON.stringify(project) });
  container.appendChild(el);
  const vm = initIde(el, { extendStore });

  // We need to dispose of editor Singleton things or tests will bump into eachother
  vm.$on('destroy', () => monacoEditor.getModels().forEach((model) => model.dispose()));

  return vm;
};