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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 06:08:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-06 06:08:47 +0300
commitcfbaef3f1c28cdb9b15615215b87167181cb210f (patch)
tree8713f67e889a9b6d89fd35584ec7405f5a379565 /spec/javascripts
parenta97acfe57aac7d8206e99e5ffdfe9c5fb5b69544 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/diffs/components/diff_line_gutter_content_spec.js105
-rw-r--r--spec/javascripts/diffs/mock_data/diff_file.js249
2 files changed, 4 insertions, 350 deletions
diff --git a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js b/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
deleted file mode 100644
index 8d20be9971d..00000000000
--- a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js
+++ /dev/null
@@ -1,105 +0,0 @@
-import Vue from 'vue';
-import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
-import DiffLineGutterContent from '~/diffs/components/diff_line_gutter_content.vue';
-import { createStore } from '~/mr_notes/stores';
-import discussionsMockData from '../mock_data/diff_discussions';
-import diffFileMockData from '../mock_data/diff_file';
-
-describe('DiffLineGutterContent', () => {
- const getDiffFileMock = () => Object.assign({}, diffFileMockData);
- const createComponent = (options = {}) => {
- const cmp = Vue.extend(DiffLineGutterContent);
- const props = Object.assign({}, options);
- props.line = {
- line_code: 'LC_42',
- type: 'new',
- old_line: null,
- new_line: 1,
- discussions: [{ ...discussionsMockData }],
- text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- rich_text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- meta_data: null,
- };
- props.fileHash = getDiffFileMock().file_hash;
- props.contextLinesPath = '/context/lines/path';
-
- return createComponentWithStore(cmp, createStore(), props).$mount();
- };
-
- describe('computed', () => {
- describe('lineHref', () => {
- it('should prepend # to lineCode', () => {
- const lineCode = 'LC_42';
- const component = createComponent();
-
- expect(component.lineHref).toEqual(`#${lineCode}`);
- });
-
- it('should return # if there is no lineCode', () => {
- const component = createComponent();
- component.line.line_code = '';
-
- expect(component.lineHref).toEqual('#');
- });
- });
-
- describe('discussions, hasDiscussions, shouldShowAvatarsOnGutter', () => {
- it('should return empty array when there is no discussion', () => {
- const component = createComponent();
- component.line.discussions = [];
-
- expect(component.hasDiscussions).toEqual(false);
- expect(component.shouldShowAvatarsOnGutter).toEqual(false);
- });
-
- it('should return discussions for the given lineCode', () => {
- const cmp = Vue.extend(DiffLineGutterContent);
- const props = {
- line: getDiffFileMock().highlighted_diff_lines[1],
- fileHash: getDiffFileMock().file_hash,
- showCommentButton: true,
- contextLinesPath: '/context/lines/path',
- };
- props.line.discussions = [Object.assign({}, discussionsMockData)];
- const component = createComponentWithStore(cmp, createStore(), props).$mount();
-
- expect(component.hasDiscussions).toEqual(true);
- expect(component.shouldShowAvatarsOnGutter).toEqual(true);
- });
- });
- });
-
- describe('template', () => {
- it('should render comment button', () => {
- const component = createComponent({
- showCommentButton: true,
- });
- Object.defineProperty(component, 'isLoggedIn', {
- get() {
- return true;
- },
- });
-
- expect(component.$el.querySelector('.js-add-diff-note-button')).toBeDefined();
- });
-
- it('should render line link', () => {
- const lineNumber = 42;
- const lineCode = `LC_${lineNumber}`;
- const component = createComponent({ lineNumber, lineCode });
- const link = component.$el.querySelector('a');
-
- expect(link.href.indexOf(`#${lineCode}`)).toBeGreaterThan(-1);
- expect(link.dataset.linenumber).toEqual(lineNumber.toString());
- });
-
- it('should render user avatars', () => {
- const component = createComponent({
- showCommentButton: true,
- lineCode: getDiffFileMock().highlighted_diff_lines[1].line_code,
- });
-
- expect(component.$el.querySelector('.diff-comment-avatar-holders')).not.toBe(null);
- });
- });
-});
diff --git a/spec/javascripts/diffs/mock_data/diff_file.js b/spec/javascripts/diffs/mock_data/diff_file.js
index 531686efff1..9dc365b7403 100644
--- a/spec/javascripts/diffs/mock_data/diff_file.js
+++ b/spec/javascripts/diffs/mock_data/diff_file.js
@@ -1,246 +1,5 @@
-// Copied to ee/spec/frontend/diffs/mock_data/diff_file.js
+// No new code should be added to this file. Instead, modify the
+// file this one re-exports from. For more detail about why, see:
+// https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/31349
-export default {
- submodule: false,
- submodule_link: null,
- blob: {
- id: '9e10516ca50788acf18c518a231914a21e5f16f7',
- path: 'CHANGELOG',
- name: 'CHANGELOG',
- mode: '100644',
- readable_text: true,
- icon: 'file-text-o',
- },
- blob_path: 'CHANGELOG',
- blob_name: 'CHANGELOG',
- blob_icon: '<i aria-hidden="true" data-hidden="true" class="fa fa-file-text-o fa-fw"></i>',
- file_hash: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a',
- file_path: 'CHANGELOG',
- new_file: false,
- deleted_file: false,
- renamed_file: false,
- old_path: 'CHANGELOG',
- new_path: 'CHANGELOG',
- mode_changed: false,
- a_mode: '100644',
- b_mode: '100644',
- text: true,
- viewer: {
- name: 'text',
- error: null,
- collapsed: false,
- },
- added_lines: 2,
- removed_lines: 0,
- diff_refs: {
- base_sha: 'e63f41fe459e62e1228fcef60d7189127aeba95a',
- start_sha: 'd9eaefe5a676b820c57ff18cf5b68316025f7962',
- head_sha: 'c48ee0d1bf3b30453f5b32250ce03134beaa6d13',
- },
- content_sha: 'c48ee0d1bf3b30453f5b32250ce03134beaa6d13',
- stored_externally: null,
- external_storage: null,
- old_path_html: 'CHANGELOG',
- new_path_html: 'CHANGELOG',
- edit_path: '/gitlab-org/gitlab-test/edit/spooky-stuff/CHANGELOG',
- view_path: '/gitlab-org/gitlab-test/blob/spooky-stuff/CHANGELOG',
- replaced_view_path: null,
- collapsed: false,
- renderIt: false,
- too_large: false,
- context_lines_path:
- '/gitlab-org/gitlab-test/blob/c48ee0d1bf3b30453f5b32250ce03134beaa6d13/CHANGELOG/diff',
- highlighted_diff_lines: [
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1',
- type: 'new',
- old_line: null,
- new_line: 1,
- discussions: [],
- text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- rich_text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2',
- type: 'new',
- old_line: null,
- new_line: 2,
- discussions: [],
- text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
- rich_text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
- type: null,
- old_line: 1,
- new_line: 3,
- discussions: [],
- text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- rich_text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
- type: null,
- old_line: 2,
- new_line: 4,
- discussions: [],
- text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- rich_text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
- type: null,
- old_line: 3,
- new_line: 5,
- discussions: [],
- text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- rich_text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- meta_data: null,
- },
- {
- line_code: null,
- type: 'match',
- old_line: null,
- new_line: null,
- discussions: [],
- text: '',
- rich_text: '',
- meta_data: {
- old_pos: 3,
- new_pos: 5,
- },
- },
- ],
- parallel_diff_lines: [
- {
- left: {
- type: 'empty-cell',
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1',
- type: 'new',
- old_line: null,
- new_line: 1,
- discussions: [],
- text: '+<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- rich_text: '<span id="LC1" class="line" lang="plaintext"> - Bad dates</span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- type: 'empty-cell',
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_2',
- type: 'new',
- old_line: null,
- new_line: 2,
- discussions: [],
- text: '+<span id="LC2" class="line" lang="plaintext"></span>\n',
- rich_text: '<span id="LC2" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_Code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
- type: null,
- old_line: 1,
- new_line: 3,
- discussions: [],
- text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- rich_text: '<span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- meta_data: null,
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3',
- type: null,
- old_line: 1,
- new_line: 3,
- discussions: [],
- text: ' <span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- rich_text: '<span id="LC3" class="line" lang="plaintext">v6.8.0</span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
- type: null,
- old_line: 2,
- new_line: 4,
- discussions: [],
- text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- rich_text: '<span id="LC4" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_2_4',
- type: null,
- old_line: 2,
- new_line: 4,
- discussions: [],
- text: ' <span id="LC4" class="line" lang="plaintext"></span>\n',
- rich_text: '<span id="LC4" class="line" lang="plaintext"></span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
- type: null,
- old_line: 3,
- new_line: 5,
- discussions: [],
- text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- rich_text: '<span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- meta_data: null,
- },
- right: {
- line_code: '1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_3_5',
- type: null,
- old_line: 3,
- new_line: 5,
- discussions: [],
- text: ' <span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- rich_text: '<span id="LC5" class="line" lang="plaintext">v6.7.0</span>\n',
- meta_data: null,
- },
- },
- {
- left: {
- line_code: null,
- type: 'match',
- old_line: null,
- new_line: null,
- discussions: [],
- text: '',
- rich_text: '',
- meta_data: {
- old_pos: 3,
- new_pos: 5,
- },
- },
- right: {
- line_code: null,
- type: 'match',
- old_line: null,
- new_line: null,
- discussions: [],
- text: '',
- rich_text: '',
- meta_data: {
- old_pos: 3,
- new_pos: 5,
- },
- },
- },
- ],
- discussions: [],
- renderingLines: false,
-};
+export { default } from '../../../frontend/diffs/mock_data/diff_file';