diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 18:42:06 +0000 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/frontend/repository | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) | |
download | gitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend/repository')
8 files changed, 90 insertions, 24 deletions
diff --git a/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap b/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap index 1dca65dd862..cf2e6b00800 100644 --- a/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap +++ b/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap @@ -10,7 +10,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` imgcssclasses="" imgsize="40" imgsrc="https://test.com" - linkhref="https://test.com/test" + linkhref="/test" tooltipplacement="top" tooltiptext="" username="" @@ -24,7 +24,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` > <gl-link-stub class="commit-row-message item-title" - href="https://test.com/commit/123" + href="/commit/123" > Commit title </gl-link-stub> @@ -36,7 +36,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` > <gl-link-stub class="commit-author-link js-user-link" - href="https://test.com/test" + href="/test" > Test @@ -110,7 +110,7 @@ exports[`Repository last commit component renders the signature HTML as returned imgcssclasses="" imgsize="40" imgsrc="https://test.com" - linkhref="https://test.com/test" + linkhref="/test" tooltipplacement="top" tooltiptext="" username="" @@ -124,7 +124,7 @@ exports[`Repository last commit component renders the signature HTML as returned > <gl-link-stub class="commit-row-message item-title" - href="https://test.com/commit/123" + href="/commit/123" > Commit title </gl-link-stub> @@ -136,7 +136,7 @@ exports[`Repository last commit component renders the signature HTML as returned > <gl-link-stub class="commit-author-link js-user-link" - href="https://test.com/test" + href="/test" > Test diff --git a/spec/frontend/repository/components/breadcrumbs_spec.js b/spec/frontend/repository/components/breadcrumbs_spec.js index 38e5c9aaca5..ca4120576f5 100644 --- a/spec/frontend/repository/components/breadcrumbs_spec.js +++ b/spec/frontend/repository/components/breadcrumbs_spec.js @@ -1,5 +1,5 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; -import { GlDropdown } from '@gitlab/ui'; +import { GlDeprecatedDropdown } from '@gitlab/ui'; import Breadcrumbs from '~/repository/components/breadcrumbs.vue'; let vm; @@ -61,7 +61,7 @@ describe('Repository breadcrumbs component', () => { vm.setData({ userPermissions: { forkProject: false, createMergeRequestIn: false } }); return vm.vm.$nextTick(() => { - expect(vm.find(GlDropdown).exists()).toBe(false); + expect(vm.find(GlDeprecatedDropdown).exists()).toBe(false); }); }); @@ -71,7 +71,7 @@ describe('Repository breadcrumbs component', () => { vm.setData({ userPermissions: { forkProject: true, createMergeRequestIn: true } }); return vm.vm.$nextTick(() => { - expect(vm.find(GlDropdown).exists()).toBe(true); + expect(vm.find(GlDeprecatedDropdown).exists()).toBe(true); }); }); }); diff --git a/spec/frontend/repository/components/last_commit_spec.js b/spec/frontend/repository/components/last_commit_spec.js index a5bfeb08fe4..c14a7f0e061 100644 --- a/spec/frontend/repository/components/last_commit_spec.js +++ b/spec/frontend/repository/components/last_commit_spec.js @@ -11,12 +11,12 @@ function createCommitData(data = {}) { title: 'Commit title', titleHtml: 'Commit title', message: 'Commit message', - webUrl: 'https://test.com/commit/123', + webPath: '/commit/123', authoredDate: '2019-01-01', author: { name: 'Test', avatarUrl: 'https://test.com', - webUrl: 'https://test.com/test', + webPath: '/test', }, pipeline: { detailedStatus: { @@ -108,7 +108,7 @@ describe('Repository last commit component', () => { }); it('does not render description expander when description is null', () => { - factory(createCommitData({ description: null })); + factory(createCommitData({ descriptionHtml: null })); return vm.vm.$nextTick(() => { expect(vm.find('.text-expander').exists()).toBe(false); @@ -117,7 +117,7 @@ describe('Repository last commit component', () => { }); it('expands commit description when clicking expander', () => { - factory(createCommitData({ description: 'Test description' })); + factory(createCommitData({ descriptionHtml: 'Test description' })); return vm.vm .$nextTick() diff --git a/spec/frontend/repository/components/preview/index_spec.js b/spec/frontend/repository/components/preview/index_spec.js index 6ae323f5c3f..ebd985e640c 100644 --- a/spec/frontend/repository/components/preview/index_spec.js +++ b/spec/frontend/repository/components/preview/index_spec.js @@ -30,7 +30,7 @@ describe('Repository file preview component', () => { it('renders file HTML', () => { factory({ - webUrl: 'http://test.com', + webPath: 'http://test.com', name: 'README.md', }); @@ -43,7 +43,7 @@ describe('Repository file preview component', () => { it('handles hash after render', () => { factory({ - webUrl: 'http://test.com', + webPath: 'http://test.com', name: 'README.md', }); @@ -59,7 +59,7 @@ describe('Repository file preview component', () => { it('renders loading icon', () => { factory({ - webUrl: 'http://test.com', + webPath: 'http://test.com', name: 'README.md', }); diff --git a/spec/frontend/repository/components/table/index_spec.js b/spec/frontend/repository/components/table/index_spec.js index ed50f292b8c..10669330b61 100644 --- a/spec/frontend/repository/components/table/index_spec.js +++ b/spec/frontend/repository/components/table/index_spec.js @@ -13,7 +13,7 @@ const MOCK_BLOBS = [ flatPath: 'blob', name: 'blob.md', type: 'blob', - webUrl: 'http://test.com', + webPath: '/blob', }, { id: '124abc', diff --git a/spec/frontend/repository/components/tree_content_spec.js b/spec/frontend/repository/components/tree_content_spec.js index da892ce51d8..ea85cd34743 100644 --- a/spec/frontend/repository/components/tree_content_spec.js +++ b/spec/frontend/repository/components/tree_content_spec.js @@ -1,5 +1,6 @@ import { shallowMount } from '@vue/test-utils'; -import TreeContent from '~/repository/components/tree_content.vue'; +import { GlButton } from '@gitlab/ui'; +import TreeContent, { INITIAL_FETCH_COUNT } from '~/repository/components/tree_content.vue'; import FilePreview from '~/repository/components/preview/index.vue'; let vm; @@ -25,14 +26,24 @@ describe('Repository table component', () => { vm.destroy(); }); - it('renders file preview', () => { + it('renders file preview', async () => { factory('/'); vm.setData({ entries: { blobs: [{ name: 'README.md' }] } }); - return vm.vm.$nextTick().then(() => { - expect(vm.find(FilePreview).exists()).toBe(true); - }); + await vm.vm.$nextTick(); + + expect(vm.find(FilePreview).exists()).toBe(true); + }); + + it('trigger fetchFiles when mounted', async () => { + factory('/'); + + jest.spyOn(vm.vm, 'fetchFiles').mockImplementation(() => {}); + + await vm.vm.$nextTick(); + + expect(vm.vm.fetchFiles).toHaveBeenCalled(); }); describe('normalizeData', () => { @@ -70,4 +81,59 @@ describe('Repository table component', () => { expect(output).toEqual({ hasNextPage: true, nextCursor: 'test' }); }); }); + + describe('Show more button', () => { + const showMoreButton = () => vm.find(GlButton); + + describe('when is present', () => { + beforeEach(async () => { + factory('/'); + + vm.setData({ fetchCounter: 10, clickedShowMore: false }); + + await vm.vm.$nextTick(); + }); + + it('is not rendered once it is clicked', async () => { + showMoreButton().vm.$emit('click'); + await vm.vm.$nextTick(); + + expect(showMoreButton().exists()).toBe(false); + }); + + it('is rendered', async () => { + expect(showMoreButton().exists()).toBe(true); + }); + + it('changes clickedShowMore when show more button is clicked', async () => { + showMoreButton().vm.$emit('click'); + + expect(vm.vm.clickedShowMore).toBe(true); + }); + + it('triggers fetchFiles when show more button is clicked', async () => { + jest.spyOn(vm.vm, 'fetchFiles'); + + showMoreButton().vm.$emit('click'); + + expect(vm.vm.fetchFiles).toBeCalled(); + }); + }); + + it('is not rendered if less than 1000 files', async () => { + factory('/'); + + vm.setData({ fetchCounter: 5, clickedShowMore: false }); + + await vm.vm.$nextTick(); + + expect(showMoreButton().exists()).toBe(false); + }); + + it('has limit of 1000 files on initial load', () => { + factory('/'); + + expect(INITIAL_FETCH_COUNT * vm.vm.pageSize).toBe(1000); + }); + }); }); diff --git a/spec/frontend/repository/components/web_ide_link_spec.js b/spec/frontend/repository/components/web_ide_link_spec.js index 59e1a4fd719..877756db364 100644 --- a/spec/frontend/repository/components/web_ide_link_spec.js +++ b/spec/frontend/repository/components/web_ide_link_spec.js @@ -1,5 +1,5 @@ -import WebIdeLink from '~/repository/components/web_ide_link.vue'; import { mount } from '@vue/test-utils'; +import WebIdeLink from '~/repository/components/web_ide_link.vue'; describe('Web IDE link component', () => { let wrapper; diff --git a/spec/frontend/repository/utils/dom_spec.js b/spec/frontend/repository/utils/dom_spec.js index e8b0565868e..26ed57f0392 100644 --- a/spec/frontend/repository/utils/dom_spec.js +++ b/spec/frontend/repository/utils/dom_spec.js @@ -1,6 +1,6 @@ +import { TEST_HOST } from 'helpers/test_constants'; import { setHTMLFixture } from '../../helpers/fixtures'; import { updateElementsVisibility, updateFormAction } from '~/repository/utils/dom'; -import { TEST_HOST } from 'helpers/test_constants'; describe('updateElementsVisibility', () => { it('adds hidden class', () => { |