diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/frontend/diffs/components/diff_file_spec.js | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/frontend/diffs/components/diff_file_spec.js')
-rw-r--r-- | spec/frontend/diffs/components/diff_file_spec.js | 78 |
1 files changed, 64 insertions, 14 deletions
diff --git a/spec/frontend/diffs/components/diff_file_spec.js b/spec/frontend/diffs/components/diff_file_spec.js index c715d779986..9c3c3e82ad5 100644 --- a/spec/frontend/diffs/components/diff_file_spec.js +++ b/spec/frontend/diffs/components/diff_file_spec.js @@ -1,26 +1,25 @@ -import Vuex from 'vuex'; import { shallowMount, createLocalVue } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; +import Vuex from 'vuex'; -import axios from '~/lib/utils/axios_utils'; -import httpStatus from '~/lib/utils/http_status'; -import createDiffsStore from '~/diffs/store/modules'; -import createNotesStore from '~/notes/stores/modules'; -import diffFileMockDataReadable from '../mock_data/diff_file'; -import diffFileMockDataUnreadable from '../mock_data/diff_file_unreadable'; - +import DiffContentComponent from '~/diffs/components/diff_content.vue'; import DiffFileComponent from '~/diffs/components/diff_file.vue'; import DiffFileHeaderComponent from '~/diffs/components/diff_file_header.vue'; -import DiffContentComponent from '~/diffs/components/diff_content.vue'; -import eventHub from '~/diffs/event_hub'; import { EVT_EXPAND_ALL_FILES, EVT_PERF_MARK_DIFF_FILES_END, EVT_PERF_MARK_FIRST_DIFF_FILE_SHOWN, } from '~/diffs/constants'; +import eventHub from '~/diffs/event_hub'; +import createDiffsStore from '~/diffs/store/modules'; import { diffViewerModes, diffViewerErrors } from '~/ide/constants'; +import axios from '~/lib/utils/axios_utils'; +import httpStatus from '~/lib/utils/http_status'; +import createNotesStore from '~/notes/stores/modules'; +import diffFileMockDataReadable from '../mock_data/diff_file'; +import diffFileMockDataUnreadable from '../mock_data/diff_file_unreadable'; function changeViewer(store, index, { automaticallyCollapsed, manuallyCollapsed, name }) { const file = store.state.diffs.diffFiles[index]; @@ -66,7 +65,7 @@ function markFileToBeRendered(store, index = 0) { }); } -function createComponent({ file, first = false, last = false }) { +function createComponent({ file, first = false, last = false, options = {}, props = {} }) { const localVue = createLocalVue(); localVue.use(Vuex); @@ -89,7 +88,9 @@ function createComponent({ file, first = false, last = false }) { viewDiffsFileByFile: false, isFirstFile: first, isLastFile: last, + ...props, }, + ...options, }); return { @@ -220,6 +221,53 @@ describe('DiffFile', () => { }); }); + describe('computed', () => { + describe('showLocalFileReviews', () => { + let gon; + + function setLoggedIn(bool) { + window.gon.current_user_id = bool; + } + + beforeAll(() => { + gon = window.gon; + window.gon = {}; + }); + + afterEach(() => { + window.gon = gon; + }); + + it.each` + loggedIn | featureOn | bool + ${true} | ${true} | ${true} + ${false} | ${true} | ${false} + ${true} | ${false} | ${false} + ${false} | ${false} | ${false} + `( + 'should be $bool when { userIsLoggedIn: $loggedIn, featureEnabled: $featureOn }', + ({ loggedIn, featureOn, bool }) => { + setLoggedIn(loggedIn); + + ({ wrapper } = createComponent({ + options: { + provide: { + glFeatures: { + localFileReviews: featureOn, + }, + }, + }, + props: { + file: store.state.diffs.diffFiles[0], + }, + })); + + expect(wrapper.vm.showLocalFileReviews).toBe(bool); + }, + ); + }); + }); + describe('collapsing', () => { describe(`\`${EVT_EXPAND_ALL_FILES}\` event`, () => { beforeEach(() => { @@ -422,9 +470,11 @@ describe('DiffFile', () => { await wrapper.vm.$nextTick(); - expect(wrapper.vm.$el.innerText).toContain( - 'This source diff could not be displayed because it is too large', - ); + const button = wrapper.find('[data-testid="blob-button"]'); + + expect(wrapper.text()).toContain('Changes are too large to be shown.'); + expect(button.html()).toContain('View file @'); + expect(button.attributes('href')).toBe('/file/view/path'); }); }); }); |