Commit 7291484d authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'blob-row-click-to-open' into 'master'

Click file row in repository Vue app to view file

See merge request gitlab-org/gitlab-ce!29596
parents 63e56515 8d2ee368
<script>
import { GlBadge } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility';
import { getIconName } from '../../utils/icon';
import getRefMixin from '../../mixins/get_ref';
......@@ -63,6 +64,8 @@ export default {
openRow() {
if (this.isFolder) {
this.$router.push(this.routerLinkTo);
} else {
visitUrl(this.url);
}
},
},
......
......@@ -15,6 +15,7 @@ exports[`Repository table row component renders table row 1`] = `
<a
class="str-truncated"
href="https://test.com"
>
test
......
import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { GlBadge } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility';
import TableRow from '~/repository/components/table/row.vue';
jest.mock('~/lib/utils/url_utility');
let vm;
let $router;
......@@ -11,7 +14,10 @@ function factory(propsData = {}) {
};
vm = shallowMount(TableRow, {
propsData,
propsData: {
...propsData,
url: `https://test.com`,
},
mocks: {
$router,
},
......@@ -26,6 +32,7 @@ function factory(propsData = {}) {
describe('Repository table row component', () => {
afterEach(() => {
vm.destroy();
jest.clearAllMocks();
});
it('renders table row', () => {
......@@ -77,6 +84,28 @@ describe('Repository table row component', () => {
}
});
it.each`
type | pushes
${'tree'} | ${true}
${'file'} | ${false}
${'commit'} | ${false}
`('calls visitUrl if $type is not tree', ({ type, pushes }) => {
factory({
id: '1',
path: 'test',
type,
currentPath: '/',
});
vm.trigger('click');
if (pushes) {
expect(visitUrl).not.toHaveBeenCalled();
} else {
expect(visitUrl).toHaveBeenCalledWith('https://test.com');
}
});
it('renders commit ID for submodule', () => {
factory({
id: '1',
......
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