summaryrefslogtreecommitdiff
path: root/spec/frontend_integration/ide/ide_integration_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend_integration/ide/ide_integration_spec.js')
-rw-r--r--spec/frontend_integration/ide/ide_integration_spec.js88
1 files changed, 25 insertions, 63 deletions
diff --git a/spec/frontend_integration/ide/ide_integration_spec.js b/spec/frontend_integration/ide/ide_integration_spec.js
index 7e8fb3a32ee..91d89c26ec1 100644
--- a/spec/frontend_integration/ide/ide_integration_spec.js
+++ b/spec/frontend_integration/ide/ide_integration_spec.js
@@ -8,93 +8,55 @@
*
* See https://gitlab.com/gitlab-org/gitlab/-/issues/208800 for more information.
*/
-import MockAdapter from 'axios-mock-adapter';
-import axios from '~/lib/utils/axios_utils';
+import { TEST_HOST } from 'helpers/test_constants';
+import { useOverclockTimers } from 'test_helpers/utils/overclock_timers';
import { initIde } from '~/ide';
-
-jest.mock('~/api', () => {
- return {
- project: jest.fn().mockImplementation(() => new Promise(() => {})),
- };
-});
-
-jest.mock('~/ide/services/gql', () => {
- return {
- query: jest.fn().mockImplementation(() => new Promise(() => {})),
- };
-});
+import extendStore from '~/ide/stores/extend';
+
+const TEST_DATASET = {
+ emptyStateSvgPath: '/test/empty_state.svg',
+ noChangesStateSvgPath: '/test/no_changes_state.svg',
+ committedStateSvgPath: '/test/committed_state.svg',
+ pipelinesEmptyStateSvgPath: '/test/pipelines_empty_state.svg',
+ promotionSvgPath: '/test/promotion.svg',
+ ciHelpPagePath: '/test/ci_help_page',
+ webIDEHelpPagePath: '/test/web_ide_help_page',
+ clientsidePreviewEnabled: 'true',
+ renderWhitespaceInCode: 'false',
+ codesandboxBundlerUrl: 'test/codesandbox_bundler',
+};
describe('WebIDE', () => {
+ useOverclockTimers();
+
let vm;
let root;
- let mock;
- let initData;
- let location;
beforeEach(() => {
root = document.createElement('div');
- initData = {
- emptyStateSvgPath: '/test/empty_state.svg',
- noChangesStateSvgPath: '/test/no_changes_state.svg',
- committedStateSvgPath: '/test/committed_state.svg',
- pipelinesEmptyStateSvgPath: '/test/pipelines_empty_state.svg',
- promotionSvgPath: '/test/promotion.svg',
- ciHelpPagePath: '/test/ci_help_page',
- webIDEHelpPagePath: '/test/web_ide_help_page',
- clientsidePreviewEnabled: 'true',
- renderWhitespaceInCode: 'false',
- codesandboxBundlerUrl: 'test/codesandbox_bundler',
- };
+ document.body.appendChild(root);
- mock = new MockAdapter(axios);
- mock.onAny('*').reply(() => new Promise(() => {}));
-
- location = { pathname: '/-/ide/project/gitlab-test/test', search: '', hash: '' };
- Object.defineProperty(window, 'location', {
- get() {
- return location;
- },
+ global.jsdom.reconfigure({
+ url: `${TEST_HOST}/-/ide/project/gitlab-test/lorem-ipsum`,
});
});
afterEach(() => {
vm.$destroy();
vm = null;
-
- mock.restore();
+ root.remove();
});
const createComponent = () => {
const el = document.createElement('div');
- Object.assign(el.dataset, initData);
+ Object.assign(el.dataset, TEST_DATASET);
root.appendChild(el);
- vm = initIde(el);
+ vm = initIde(el, { extendStore });
};
- expect.addSnapshotSerializer({
- test(value) {
- return value instanceof HTMLElement && !value.$_hit;
- },
- print(element, serialize) {
- element.$_hit = true;
- element.querySelectorAll('[style]').forEach(el => {
- el.$_hit = true;
- if (el.style.display === 'none') {
- el.textContent = '(jest: contents hidden)';
- }
- });
-
- return serialize(element)
- .replace(/^\s*<!---->$/gm, '')
- .replace(/\n\s*\n/gm, '\n');
- },
- });
-
it('runs', () => {
createComponent();
- return vm.$nextTick().then(() => {
- expect(root).toMatchSnapshot();
- });
+ expect(root).toMatchSnapshot();
});
});