2018-06-21 08:22:40 -04:00
|
|
|
import initMRPage from '~/mr_notes/index';
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
|
|
import { userDataMock, notesDataMock, noteableDataMock } from '../notes/mock_data';
|
|
|
|
import diffFileMockData from '../diffs/mock_data/diff_file';
|
|
|
|
|
|
|
|
export default function initVueMRPage() {
|
2018-06-30 09:17:46 -04:00
|
|
|
const mrTestEl = document.createElement('div');
|
|
|
|
mrTestEl.className = 'js-merge-request-test';
|
|
|
|
document.body.appendChild(mrTestEl);
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
const diffsAppEndpoint = '/diffs/app/endpoint';
|
2018-06-26 14:49:22 -04:00
|
|
|
const diffsAppProjectPath = 'testproject';
|
2018-06-21 08:22:40 -04:00
|
|
|
const mrEl = document.createElement('div');
|
|
|
|
mrEl.className = 'merge-request fixture-mr';
|
|
|
|
mrEl.setAttribute('data-mr-action', 'diffs');
|
2018-06-30 09:17:46 -04:00
|
|
|
mrTestEl.appendChild(mrEl);
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
const mrDiscussionsEl = document.createElement('div');
|
|
|
|
mrDiscussionsEl.id = 'js-vue-mr-discussions';
|
|
|
|
mrDiscussionsEl.setAttribute('data-current-user-data', JSON.stringify(userDataMock));
|
|
|
|
mrDiscussionsEl.setAttribute('data-noteable-data', JSON.stringify(noteableDataMock));
|
|
|
|
mrDiscussionsEl.setAttribute('data-notes-data', JSON.stringify(notesDataMock));
|
|
|
|
mrDiscussionsEl.setAttribute('data-noteable-type', 'merge-request');
|
2018-06-30 09:17:46 -04:00
|
|
|
mrTestEl.appendChild(mrDiscussionsEl);
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
const discussionCounterEl = document.createElement('div');
|
|
|
|
discussionCounterEl.id = 'js-vue-discussion-counter';
|
2018-06-30 09:17:46 -04:00
|
|
|
mrTestEl.appendChild(discussionCounterEl);
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
const diffsAppEl = document.createElement('div');
|
|
|
|
diffsAppEl.id = 'js-diffs-app';
|
|
|
|
diffsAppEl.setAttribute('data-endpoint', diffsAppEndpoint);
|
2018-06-26 14:49:22 -04:00
|
|
|
diffsAppEl.setAttribute('data-project-path', diffsAppProjectPath);
|
2018-06-21 08:22:40 -04:00
|
|
|
diffsAppEl.setAttribute('data-current-user-data', JSON.stringify(userDataMock));
|
2018-06-30 09:17:46 -04:00
|
|
|
mrTestEl.appendChild(diffsAppEl);
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
const mock = new MockAdapter(axios);
|
|
|
|
mock.onGet(diffsAppEndpoint).reply(200, {
|
|
|
|
branch_name: 'foo',
|
|
|
|
diff_files: [diffFileMockData],
|
|
|
|
});
|
|
|
|
|
|
|
|
initMRPage();
|
|
|
|
return mock;
|
|
|
|
}
|