Commit 8bd09ba8 authored by Thomas Randolph's avatar Thomas Randolph

Test showing repository symlink files

The basic premise of these tests is: pass along the additional
symlink file mode and make sure it always works correctly
parent aa52dc14
...@@ -8,6 +8,7 @@ exports[`Blob Header Filepath rendering matches the snapshot 1`] = ` ...@@ -8,6 +8,7 @@ exports[`Blob Header Filepath rendering matches the snapshot 1`] = `
<file-icon-stub <file-icon-stub
aria-hidden="true" aria-hidden="true"
cssclasses="mr-2" cssclasses="mr-2"
filemode=""
filename="foo/bar/dummy.md" filename="foo/bar/dummy.md"
size="18" size="18"
/> />
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // 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`] = ` exports[`Repository table row component renders table row 1`] = `
<tr <tr
class="tree-item" class="tree-item"
...@@ -15,6 +68,7 @@ exports[`Repository table row component renders table row 1`] = ` ...@@ -15,6 +68,7 @@ exports[`Repository table row component renders table row 1`] = `
<file-icon-stub <file-icon-stub
class="mr-1 position-relative text-secondary" class="mr-1 position-relative text-secondary"
cssclasses="position-relative file-icon" cssclasses="position-relative file-icon"
filemode=""
filename="test" filename="test"
size="16" size="16"
/> />
...@@ -67,6 +121,7 @@ exports[`Repository table row component renders table row for path with special ...@@ -67,6 +121,7 @@ exports[`Repository table row component renders table row for path with special
<file-icon-stub <file-icon-stub
class="mr-1 position-relative text-secondary" class="mr-1 position-relative text-secondary"
cssclasses="position-relative file-icon" cssclasses="position-relative file-icon"
filemode=""
filename="test" filename="test"
size="16" size="16"
/> />
......
...@@ -23,6 +23,15 @@ const MOCK_BLOBS = [ ...@@ -23,6 +23,15 @@ const MOCK_BLOBS = [
type: 'blob', type: 'blob',
webUrl: 'http://test.com', 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 = {} }) { function factory({ path, isLoading = false, entries = {} }) {
...@@ -74,7 +83,9 @@ describe('Repository table component', () => { ...@@ -74,7 +83,9 @@ describe('Repository table component', () => {
}, },
}); });
expect(vm.find(TableRow).exists()).toBe(true); const rows = vm.findAll(TableRow);
expect(vm.findAll(TableRow).length).toBe(2);
expect(rows.length).toEqual(3);
expect(rows.at(2).attributes().mode).toEqual('120000');
}); });
}); });
...@@ -2,6 +2,7 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; ...@@ -2,6 +2,7 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { GlBadge, GlLink, GlIcon } from '@gitlab/ui'; import { GlBadge, GlLink, GlIcon } from '@gitlab/ui';
import TableRow from '~/repository/components/table/row.vue'; import TableRow from '~/repository/components/table/row.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue';
import { FILE_SYMLINK_MODE } from '~/vue_shared/constants';
let vm; let vm;
let $router; let $router;
...@@ -48,6 +49,21 @@ describe('Repository table row component', () => { ...@@ -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', () => { it('renders table row for path with special character', () => {
factory({ factory({
id: '1', id: '1',
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import FileIcon from '~/vue_shared/components/file_icon.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue';
import { FILE_SYMLINK_MODE } from '~/vue_shared/constants';
describe('File Icon component', () => { describe('File Icon component', () => {
let wrapper; let wrapper;
const findIcon = () => wrapper.find('svg'); const findSvgIcon = () => wrapper.find('svg');
const findGlIcon = () => wrapper.find(GlIcon);
const getIconName = () => const getIconName = () =>
findIcon() findSvgIcon()
.find('use') .find('use')
.element.getAttribute('xlink:href') .element.getAttribute('xlink:href')
.replace(`${gon.sprite_file_icons}#`, ''); .replace(`${gon.sprite_file_icons}#`, '');
...@@ -27,7 +29,7 @@ describe('File Icon component', () => { ...@@ -27,7 +29,7 @@ describe('File Icon component', () => {
}); });
expect(wrapper.element.tagName).toEqual('SPAN'); expect(wrapper.element.tagName).toEqual('SPAN');
expect(findIcon().exists()).toBeDefined(); expect(findSvgIcon().exists()).toBeDefined();
}); });
it.each` it.each`
...@@ -46,8 +48,8 @@ describe('File Icon component', () => { ...@@ -46,8 +48,8 @@ describe('File Icon component', () => {
folder: true, folder: true,
}); });
expect(findIcon().exists()).toBe(false); expect(findSvgIcon().exists()).toBe(false);
expect(wrapper.find(GlIcon).classes()).toContain('folder-icon'); expect(findGlIcon().classes()).toContain('folder-icon');
}); });
it('should render a loading icon', () => { it('should render a loading icon', () => {
...@@ -66,8 +68,19 @@ describe('File Icon component', () => { ...@@ -66,8 +68,19 @@ describe('File Icon component', () => {
cssClasses: 'extraclasses', cssClasses: 'extraclasses',
size, size,
}); });
const classes = findSvgIcon().classes();
expect(findIcon().classes()).toContain(`s${size}`); expect(classes).toContain(`s${size}`);
expect(findIcon().classes()).toContain('extraclasses'); expect(classes).toContain('extraclasses');
});
it('should render a symlink icon', () => {
createComponent({
fileName: 'anything',
fileMode: FILE_SYMLINK_MODE,
});
expect(findSvgIcon().exists()).toBe(false);
expect(findGlIcon().attributes('name')).toBe('symlink');
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment