diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 15:09:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 15:09:36 +0000 |
commit | 074d013e1eb3f6e0c27f96a3be8b9361254c8a98 (patch) | |
tree | f185c474ddc8624a4793c84b0b1f4cc07349694b /spec/frontend | |
parent | 8f9beefac3774b30e911fb00a68f4c7a5244cf27 (diff) | |
download | gitlab-ce-074d013e1eb3f6e0c27f96a3be8b9361254c8a98.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 36 insertions, 88 deletions
diff --git a/spec/frontend/helpers/dom_shims/element_scroll_by.js b/spec/frontend/helpers/dom_shims/element_scroll_by.js new file mode 100644 index 00000000000..7d91279e4aa --- /dev/null +++ b/spec/frontend/helpers/dom_shims/element_scroll_by.js @@ -0,0 +1 @@ +Element.prototype.scrollBy = jest.fn(); diff --git a/spec/frontend/helpers/dom_shims/index.js b/spec/frontend/helpers/dom_shims/index.js index bcd5da0ce48..17a2090d2f1 100644 --- a/spec/frontend/helpers/dom_shims/index.js +++ b/spec/frontend/helpers/dom_shims/index.js @@ -1,4 +1,5 @@ import './element_scroll_into_view'; +import './element_scroll_by'; import './form_element'; import './get_client_rects'; import './inner_text'; 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 2d411fcce79..5b5c9fd714e 100644 --- a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap +++ b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap @@ -2,25 +2,28 @@ exports[`Repository table row component renders table row 1`] = ` <tr - class="tree-item file_1" + class="tree-item" > <td - class="tree-item-file-name" + class="tree-item-file-name cursor-default position-relative" > - <i - aria-label="file" - class="fa fa-fw fa-file-text-o" - role="img" - /> + <!----> <a - class="str-truncated" + class="tree-item-link str-truncated" data-qa-selector="file_name_link" href="https://test.com" > - - test - + <i + aria-label="file" + class="fa fa-fw mr-1 fa-file-text-o" + role="img" + /> + <span + class="position-relative" + > + test + </span> </a> <!----> @@ -31,7 +34,7 @@ exports[`Repository table row component renders table row 1`] = ` </td> <td - class="d-none d-sm-table-cell tree-commit" + class="d-none d-sm-table-cell tree-commit cursor-default" > <gl-skeleton-loading-stub class="h-auto" @@ -40,7 +43,7 @@ exports[`Repository table row component renders table row 1`] = ` </td> <td - class="tree-time-ago text-right" + class="tree-time-ago text-right cursor-default" > <gl-skeleton-loading-stub class="ml-auto h-auto w-50" @@ -52,25 +55,28 @@ exports[`Repository table row component renders table row 1`] = ` exports[`Repository table row component renders table row for path with special character 1`] = ` <tr - class="tree-item file_1" + class="tree-item" > <td - class="tree-item-file-name" + class="tree-item-file-name cursor-default position-relative" > - <i - aria-label="file" - class="fa fa-fw fa-file-text-o" - role="img" - /> + <!----> <a - class="str-truncated" + class="tree-item-link str-truncated" data-qa-selector="file_name_link" href="https://test.com" > - - test - + <i + aria-label="file" + class="fa fa-fw mr-1 fa-file-text-o" + role="img" + /> + <span + class="position-relative" + > + test + </span> </a> <!----> @@ -81,7 +87,7 @@ exports[`Repository table row component renders table row for path with special </td> <td - class="d-none d-sm-table-cell tree-commit" + class="d-none d-sm-table-cell tree-commit cursor-default" > <gl-skeleton-loading-stub class="h-auto" @@ -90,7 +96,7 @@ exports[`Repository table row component renders table row for path with special </td> <td - class="tree-time-ago text-right" + class="tree-time-ago text-right cursor-default" > <gl-skeleton-loading-stub class="ml-auto h-auto w-50" diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index 22aacdc735c..7bb7ad6e5dd 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -1,14 +1,8 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; import { GlBadge, GlLink, GlLoadingIcon } from '@gitlab/ui'; -import { visitUrl } from '~/lib/utils/url_utility'; import TableRow from '~/repository/components/table/row.vue'; import Icon from '~/vue_shared/components/icon.vue'; -jest.mock('~/lib/utils/url_utility', () => ({ - ...jest.requireActual('~/lib/utils/url_utility'), - visitUrl: jest.fn(), -})); - let vm; let $router; @@ -88,31 +82,6 @@ describe('Repository table row component', () => { }); it.each` - type | pushes - ${'tree'} | ${true} - ${'file'} | ${false} - ${'commit'} | ${false} - `('pushes new router if type $type is tree', ({ type, pushes }) => { - factory({ - id: '1', - sha: '123', - path: 'test', - type, - currentPath: '/', - }); - - return vm.vm.$nextTick().then(() => { - vm.trigger('click'); - - if (pushes) { - expect($router.push).toHaveBeenCalledWith({ path: '/-/tree/master/test' }); - } else { - expect($router.push).not.toHaveBeenCalled(); - } - }); - }); - - it.each` path ${'test#'} ${'Ă„nderungen'} @@ -132,7 +101,7 @@ describe('Repository table row component', () => { }); }); - it('pushes new route for directory with hash', () => { + it('renders link for directory with hash', () => { factory({ id: '1', sha: '123', @@ -142,36 +111,7 @@ describe('Repository table row component', () => { }); return vm.vm.$nextTick().then(() => { - vm.trigger('click'); - - expect($router.push).toHaveBeenCalledWith({ path: '/-/tree/master/test%23' }); - }); - }); - - it.each` - type | pushes - ${'tree'} | ${true} - ${'file'} | ${false} - ${'commit'} | ${false} - `('calls visitUrl if $type is not tree', ({ type, pushes }) => { - factory({ - id: '1', - sha: '123', - path: 'test', - type, - currentPath: '/', - }); - - return vm.vm.$nextTick().then(() => { - vm.trigger('click'); - - if (pushes) { - expect(visitUrl).not.toHaveBeenCalled(); - } else { - const [url, external] = visitUrl.mock.calls[0]; - expect(url).toBe('https://test.com'); - expect(external).toBeFalsy(); - } + expect(vm.find('.tree-item-link').props('to')).toEqual({ path: '/-/tree/master/test%23' }); }); }); |