debian-mirror-gitlab/spec/frontend_integration/ide/user_opens_mr_spec.js

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

66 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { basename } from 'path';
2022-07-16 23:28:13 +05:30
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
2021-03-11 19:13:27 +05:30
import { getMergeRequests, getMergeRequestWithChanges } from 'test_helpers/fixtures';
import { useOverclockTimers } from 'test_helpers/utils/overclock_timers';
2022-08-13 15:12:31 +05:30
import { stubPerformanceWebAPI } from 'helpers/performance';
2021-03-11 19:13:27 +05:30
import * as ideHelper from './helpers/ide_helper';
import startWebIDE from './helpers/start';
const getRelevantChanges = () =>
getMergeRequestWithChanges().changes.filter((x) => !x.deleted_file);
describe('IDE: User opens Merge Request', () => {
useOverclockTimers();
let vm;
let container;
let changes;
beforeEach(async () => {
2022-08-13 15:12:31 +05:30
stubPerformanceWebAPI();
2021-03-11 19:13:27 +05:30
const [{ iid: mrId }] = getMergeRequests();
changes = getRelevantChanges();
2022-07-16 23:28:13 +05:30
setHTMLFixture('<div class="webide-container"></div>');
2021-03-11 19:13:27 +05:30
container = document.querySelector('.webide-container');
vm = startWebIDE(container, { mrId });
2021-04-17 20:07:23 +05:30
const editor = await ideHelper.waitForMonacoEditor();
await ideHelper.waitForEditorModelChange(editor);
2021-03-11 19:13:27 +05:30
});
2021-04-17 20:07:23 +05:30
afterEach(() => {
2021-03-11 19:13:27 +05:30
vm.$destroy();
vm = null;
2022-07-16 23:28:13 +05:30
resetHTMLFixture();
2021-03-11 19:13:27 +05:30
});
const findAllTabs = () => Array.from(document.querySelectorAll('.multi-file-tab'));
const findAllTabsData = () =>
findAllTabs().map((el) => ({
title: el.getAttribute('title'),
text: el.textContent.trim(),
}));
it('shows first change as active in file tree', async () => {
const firstPath = changes[0].new_path;
const row = await ideHelper.findAndTraverseToPath(firstPath);
expect(row).toHaveClass('is-open');
expect(row).toHaveClass('is-active');
});
it('opens other changes', () => {
// We only show first 10 changes
const expectedTabs = changes.slice(0, 10).map((x) => ({
title: `${ideHelper.getBaseRoute()}/-/${x.new_path}/`,
text: basename(x.new_path),
}));
expect(findAllTabsData()).toEqual(expectedTabs);
});
});