diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/repository | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/repository')
5 files changed, 137 insertions, 3 deletions
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 97597ed8063..ac60fc4917d 100644 --- a/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap +++ b/spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap @@ -1,5 +1,58 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Repository table row component renders a symlink table row 1`] = ` +<tr + class="tree-item" +> + <td + class="tree-item-file-name cursor-default position-relative" + > + <a + class="tree-item-link str-truncated" + data-qa-selector="file_name_link" + href="https://test.com" + > + <file-icon-stub + class="mr-1 position-relative text-secondary" + cssclasses="position-relative file-icon" + filemode="120000" + filename="test" + size="16" + /> + <span + class="position-relative" + > + test + </span> + </a> + + <!----> + + <!----> + + <!----> + </td> + + <td + class="d-none d-sm-table-cell tree-commit cursor-default" + > + <gl-skeleton-loading-stub + class="h-auto" + lines="1" + /> + </td> + + <td + class="tree-time-ago text-right cursor-default" + > + <gl-skeleton-loading-stub + class="ml-auto h-auto w-50" + lines="1" + /> + </td> +</tr> +`; + exports[`Repository table row component renders table row 1`] = ` <tr class="tree-item" @@ -15,6 +68,7 @@ exports[`Repository table row component renders table row 1`] = ` <file-icon-stub class="mr-1 position-relative text-secondary" cssclasses="position-relative file-icon" + filemode="" filename="test" size="16" /> @@ -67,6 +121,7 @@ exports[`Repository table row component renders table row for path with special <file-icon-stub class="mr-1 position-relative text-secondary" cssclasses="position-relative file-icon" + filemode="" filename="test" size="16" /> diff --git a/spec/frontend/repository/components/table/index_spec.js b/spec/frontend/repository/components/table/index_spec.js index 9db90839b29..ed50f292b8c 100644 --- a/spec/frontend/repository/components/table/index_spec.js +++ b/spec/frontend/repository/components/table/index_spec.js @@ -23,6 +23,15 @@ const MOCK_BLOBS = [ type: 'blob', webUrl: 'http://test.com', }, + { + id: '125abc', + sha: '125abc', + flatPath: 'blob3', + name: 'blob3.md', + type: 'blob', + webUrl: 'http://test.com', + mode: '120000', + }, ]; function factory({ path, isLoading = false, entries = {} }) { @@ -74,7 +83,9 @@ describe('Repository table component', () => { }, }); - expect(vm.find(TableRow).exists()).toBe(true); - expect(vm.findAll(TableRow).length).toBe(2); + const rows = vm.findAll(TableRow); + + expect(rows.length).toEqual(3); + expect(rows.at(2).attributes().mode).toEqual('120000'); }); }); diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index 800a7e586a8..767b117c798 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -2,6 +2,7 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; import { GlBadge, GlLink, GlIcon } from '@gitlab/ui'; import TableRow from '~/repository/components/table/row.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue'; +import { FILE_SYMLINK_MODE } from '~/vue_shared/constants'; let vm; let $router; @@ -48,6 +49,21 @@ describe('Repository table row component', () => { }); }); + it('renders a symlink table row', () => { + factory({ + id: '1', + sha: '123', + path: 'test', + type: 'blob', + currentPath: '/', + mode: FILE_SYMLINK_MODE, + }); + + return vm.vm.$nextTick().then(() => { + expect(vm.element).toMatchSnapshot(); + }); + }); + it('renders table row for path with special character', () => { factory({ id: '1', diff --git a/spec/frontend/repository/components/web_ide_link_spec.js b/spec/frontend/repository/components/web_ide_link_spec.js new file mode 100644 index 00000000000..59e1a4fd719 --- /dev/null +++ b/spec/frontend/repository/components/web_ide_link_spec.js @@ -0,0 +1,51 @@ +import WebIdeLink from '~/repository/components/web_ide_link.vue'; +import { mount } from '@vue/test-utils'; + +describe('Web IDE link component', () => { + let wrapper; + + function createComponent(props) { + wrapper = mount(WebIdeLink, { + propsData: { ...props }, + mocks: { + $route: { + params: {}, + }, + }, + }); + } + + afterEach(() => { + wrapper.destroy(); + }); + + it('renders link to the Web IDE for a project if only projectPath is given', () => { + createComponent({ projectPath: 'gitlab-org/gitlab', refSha: 'master' }); + + expect(wrapper.attributes('href')).toBe('/-/ide/project/gitlab-org/gitlab/edit/master/-/'); + expect(wrapper.text()).toBe('Web IDE'); + }); + + it('renders link to the Web IDE for a project even if both projectPath and forkPath are given', () => { + createComponent({ + projectPath: 'gitlab-org/gitlab', + refSha: 'master', + forkPath: 'my-namespace/gitlab', + }); + + expect(wrapper.attributes('href')).toBe('/-/ide/project/gitlab-org/gitlab/edit/master/-/'); + expect(wrapper.text()).toBe('Web IDE'); + }); + + it('renders link to the forked project if it exists and cannot write to the repo', () => { + createComponent({ + projectPath: 'gitlab-org/gitlab', + refSha: 'master', + forkPath: 'my-namespace/gitlab', + canPushCode: false, + }); + + expect(wrapper.attributes('href')).toBe('/-/ide/project/my-namespace/gitlab/edit/master/-/'); + expect(wrapper.text()).toBe('Edit fork in Web IDE'); + }); +}); diff --git a/spec/frontend/repository/utils/dom_spec.js b/spec/frontend/repository/utils/dom_spec.js index 0b61161c9d0..e8b0565868e 100644 --- a/spec/frontend/repository/utils/dom_spec.js +++ b/spec/frontend/repository/utils/dom_spec.js @@ -1,5 +1,6 @@ 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', () => { @@ -31,7 +32,7 @@ describe('updateFormAction', () => { updateFormAction('.js-test', '/gitlab/create', path); expect(document.querySelector('.js-test').action).toBe( - `http://localhost/gitlab/create/${path.replace(/^\//, '')}`, + `${TEST_HOST}/gitlab/create/${path.replace(/^\//, '')}`, ); }); }); |