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

init_vue_mr_page_helper.js « __helpers__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b719a324802fd01d3a9087f52188c6998e70431 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import initMRPage from '~/mr_notes';
import diffFileMockData from '../diffs/mock_data/diff_file';
import { userDataMock, notesDataMock, noteableDataMock } from '../notes/mock_data';

export default function initVueMRPage() {
  const mrTestEl = document.createElement('div');
  mrTestEl.className = 'js-merge-request-test';
  document.body.appendChild(mrTestEl);

  const diffsAppEndpoint = '/diffs/app/endpoint';
  const diffsAppProjectPath = 'testproject';
  const mrEl = document.createElement('div');
  mrEl.className = 'merge-request fixture-mr';
  mrEl.dataset.mrAction = 'diffs';
  mrTestEl.appendChild(mrEl);

  const mrDiscussionsEl = document.createElement('div');
  mrDiscussionsEl.id = 'js-vue-mr-discussions';
  mrDiscussionsEl.dataset.currentUserData = JSON.stringify(userDataMock);
  mrDiscussionsEl.dataset.noteableData = JSON.stringify(noteableDataMock);
  mrDiscussionsEl.dataset.notesData = JSON.stringify(notesDataMock);
  mrDiscussionsEl.dataset.noteableType = 'merge-request';
  mrDiscussionsEl.dataset.isLocked = 'false';
  mrTestEl.appendChild(mrDiscussionsEl);

  const discussionCounterEl = document.createElement('div');
  discussionCounterEl.id = 'js-vue-discussion-counter';
  mrTestEl.appendChild(discussionCounterEl);

  const diffsAppEl = document.createElement('div');
  diffsAppEl.id = 'js-diffs-app';
  diffsAppEl.dataset.endpoint = diffsAppEndpoint;
  diffsAppEl.dataset.projectPath = diffsAppProjectPath;
  diffsAppEl.dataset.currentUserData = JSON.stringify(userDataMock);
  mrTestEl.appendChild(diffsAppEl);

  const mock = new MockAdapter(axios);
  mock.onGet(diffsAppEndpoint).reply(200, {
    branch_name: 'foo',
    diff_files: [diffFileMockData],
  });

  initMRPage();
  return mock;
}