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`] = `
<file-icon-stub
aria-hidden="true"
cssclasses="mr-2"
filemode=""
filename="foo/bar/dummy.md"
size="18"
/>
......
// 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"
/>
......
......@@ -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');
});
});
......@@ -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',
......
import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import FileIcon from '~/vue_shared/components/file_icon.vue';
import { FILE_SYMLINK_MODE } from '~/vue_shared/constants';
describe('File Icon component', () => {
let wrapper;
const findIcon = () => wrapper.find('svg');
const findSvgIcon = () => wrapper.find('svg');
const findGlIcon = () => wrapper.find(GlIcon);
const getIconName = () =>
findIcon()
findSvgIcon()
.find('use')
.element.getAttribute('xlink:href')
.replace(`${gon.sprite_file_icons}#`, '');
......@@ -27,7 +29,7 @@ describe('File Icon component', () => {
});
expect(wrapper.element.tagName).toEqual('SPAN');
expect(findIcon().exists()).toBeDefined();
expect(findSvgIcon().exists()).toBeDefined();
});
it.each`
......@@ -46,8 +48,8 @@ describe('File Icon component', () => {
folder: true,
});
expect(findIcon().exists()).toBe(false);
expect(wrapper.find(GlIcon).classes()).toContain('folder-icon');
expect(findSvgIcon().exists()).toBe(false);
expect(findGlIcon().classes()).toContain('folder-icon');
});
it('should render a loading icon', () => {
......@@ -66,8 +68,19 @@ describe('File Icon component', () => {
cssClasses: 'extraclasses',
size,
});
const classes = findSvgIcon().classes();
expect(findIcon().classes()).toContain(`s${size}`);
expect(findIcon().classes()).toContain('extraclasses');
expect(classes).toContain(`s${size}`);
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