diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-05-27 15:49:47 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-05-27 15:49:47 +0300 |
commit | a66cbb6e733f90ce42c53fdc605678ebcbaf79e7 (patch) | |
tree | d65fa773693c412a593da53d12a2369bbddf7449 /spec/frontend | |
parent | fe225fd9289acb8d50157703849363de39046bca (diff) | |
parent | 2d980fadb8fe6c54ebcbb56130c88aae2832c9c6 (diff) |
Merge commit '2d980fadb8fe6c54ebcbb56130c88aae2832c9c6' into backstage/gb/improve-jobs-controller-performance
* commit '2d980fadb8fe6c54ebcbb56130c88aae2832c9c6': (51 commits)
Diffstat (limited to 'spec/frontend')
5 files changed, 72 insertions, 17 deletions
diff --git a/spec/frontend/clusters/clusters_bundle_spec.js b/spec/frontend/clusters/clusters_bundle_spec.js index 73897107f67..66b22fa2681 100644 --- a/spec/frontend/clusters/clusters_bundle_spec.js +++ b/spec/frontend/clusters/clusters_bundle_spec.js @@ -209,6 +209,22 @@ describe('Clusters', () => { expect(cluster.errorContainer.classList.contains('hidden')).toBeFalsy(); }); }); + + describe('when cluster is unreachable', () => { + it('should show the unreachable warning container', () => { + cluster.updateContainer(null, 'unreachable'); + + expect(cluster.unreachableContainer.classList.contains('hidden')).toBe(false); + }); + }); + + describe('when cluster has an authentication failure', () => { + it('should show the authentication failure warning container', () => { + cluster.updateContainer(null, 'authentication_failure'); + + expect(cluster.authenticationFailureContainer.classList.contains('hidden')).toBe(false); + }); + }); }); describe('installApplication', () => { diff --git a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap index f0b72343b6e..1b4564303e4 100644 --- a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap +++ b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap @@ -16,7 +16,9 @@ exports[`Repository table row component renders table row 1`] = ` <a class="str-truncated" > + test + </a> <!----> diff --git a/spec/frontend/repository/components/table/index_spec.js b/spec/frontend/repository/components/table/index_spec.js index 6f52cffe077..827927e6d9a 100644 --- a/spec/frontend/repository/components/table/index_spec.js +++ b/spec/frontend/repository/components/table/index_spec.js @@ -3,18 +3,19 @@ import { GlLoadingIcon } from '@gitlab/ui'; import Table from '~/repository/components/table/index.vue'; let vm; +let $apollo; + +function factory(path, data = () => ({})) { + $apollo = { + query: jest.fn().mockReturnValue(Promise.resolve({ data: data() })), + }; -function factory(path, loading = false) { vm = shallowMount(Table, { propsData: { path, }, mocks: { - $apollo: { - queries: { - files: { loading }, - }, - }, + $apollo, }, }); } @@ -39,9 +40,41 @@ describe('Repository table component', () => { ); }); - it('renders loading icon', () => { - factory('/', true); + it('shows loading icon', () => { + factory('/'); + + vm.setData({ isLoadingFiles: true }); + + expect(vm.find(GlLoadingIcon).isVisible()).toBe(true); + }); + + describe('normalizeData', () => { + it('normalizes edge nodes', () => { + const output = vm.vm.normalizeData('blobs', [{ node: '1' }, { node: '2' }]); + + expect(output).toEqual(['1', '2']); + }); + }); + + describe('hasNextPage', () => { + it('returns undefined when hasNextPage is false', () => { + const output = vm.vm.hasNextPage({ + trees: { pageInfo: { hasNextPage: false } }, + submodules: { pageInfo: { hasNextPage: false } }, + blobs: { pageInfo: { hasNextPage: false } }, + }); + + expect(output).toBe(undefined); + }); + + it('returns pageInfo object when hasNextPage is true', () => { + const output = vm.vm.hasNextPage({ + trees: { pageInfo: { hasNextPage: false } }, + submodules: { pageInfo: { hasNextPage: false } }, + blobs: { pageInfo: { hasNextPage: true, nextCursor: 'test' } }, + }); - expect(vm.find(GlLoadingIcon).exists()).toBe(true); + expect(output).toEqual({ hasNextPage: true, nextCursor: 'test' }); + }); }); }); diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index 216128dce25..6b4508c418e 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -29,9 +29,10 @@ describe('Repository table row component', () => { it('renders table row', () => { factory({ - id: 1, + id: '1', path: 'test', type: 'file', + currentPath: '/', }); expect(vm.element).toMatchSnapshot(); @@ -39,14 +40,15 @@ describe('Repository table row component', () => { it.each` type | component | componentName - ${'folder'} | ${RouterLinkStub} | ${'RouterLink'} + ${'tree'} | ${RouterLinkStub} | ${'RouterLink'} ${'file'} | ${'a'} | ${'hyperlink'} ${'commit'} | ${'a'} | ${'hyperlink'} `('renders a $componentName for type $type', ({ type, component }) => { factory({ - id: 1, + id: '1', path: 'test', type, + currentPath: '/', }); expect(vm.find(component).exists()).toBe(true); @@ -54,14 +56,15 @@ describe('Repository table row component', () => { it.each` type | pushes - ${'folder'} | ${true} + ${'tree'} | ${true} ${'file'} | ${false} ${'commit'} | ${false} - `('pushes new router if type $type is folder', ({ type, pushes }) => { + `('pushes new router if type $type is tree', ({ type, pushes }) => { factory({ - id: 1, + id: '1', path: 'test', type, + currentPath: '/', }); vm.trigger('click'); @@ -75,9 +78,10 @@ describe('Repository table row component', () => { it('renders commit ID for submodule', () => { factory({ - id: 1, + id: '1', path: 'test', type: 'commit', + currentPath: '/', }); expect(vm.find('.commit-sha').text()).toContain('1'); diff --git a/spec/frontend/repository/utils/icon_spec.js b/spec/frontend/repository/utils/icon_spec.js index 52787327bef..3d84705f7ea 100644 --- a/spec/frontend/repository/utils/icon_spec.js +++ b/spec/frontend/repository/utils/icon_spec.js @@ -6,7 +6,7 @@ describe('getIconName', () => { // file types it.each` type | path | icon - ${'folder'} | ${''} | ${'folder'} + ${'tree'} | ${''} | ${'folder'} ${'commit'} | ${''} | ${'archive'} ${'file'} | ${'test.pdf'} | ${'file-pdf-o'} ${'file'} | ${'test.jpg'} | ${'file-image-o'} |