Commit ffe48ac4 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '334790-navblock-display-correctly' into 'master'

Display correct nav block when viewing blob

See merge request gitlab-org/gitlab!67557
parents 5800c70c 9860f64c
......@@ -247,7 +247,8 @@ export default {
return items;
},
renderAddToTreeDropdown() {
return this.canCollaborate || this.canCreateMrFromFork;
const isBlobPath = this.$route.name === 'blobPath' || this.$route.name === 'blobPathDecoded';
return !isBlobPath && (this.canCollaborate || this.canCreateMrFromFork);
},
},
methods: {
......
......@@ -3,10 +3,14 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import Breadcrumbs from '~/repository/components/breadcrumbs.vue';
import UploadBlobModal from '~/repository/components/upload_blob_modal.vue';
const defaultMockRoute = {
name: 'blobPath',
};
describe('Repository breadcrumbs component', () => {
let wrapper;
const factory = (currentPath, extraProps = {}) => {
const factory = (currentPath, extraProps = {}, mockRoute = {}) => {
const $apollo = {
queries: {
userPermissions: {
......@@ -23,7 +27,13 @@ describe('Repository breadcrumbs component', () => {
stubs: {
RouterLink: RouterLinkStub,
},
mocks: { $apollo },
mocks: {
$route: {
defaultMockRoute,
...mockRoute,
},
$apollo,
},
});
};
......@@ -69,6 +79,21 @@ describe('Repository breadcrumbs component', () => {
expect(wrapper.find(GlDropdown).exists()).toBe(false);
});
it.each`
routeName | isRendered
${'blobPath'} | ${false}
${'blobPathDecoded'} | ${false}
${'treePath'} | ${true}
${'treePathDecoded'} | ${true}
${'projectRoot'} | ${true}
`(
'does render add to tree dropdown $isRendered when route is $routeName',
({ routeName, isRendered }) => {
factory('app/assets/javascripts.js', { canCollaborate: true }, { name: routeName });
expect(wrapper.find(GlDropdown).exists()).toBe(isRendered);
},
);
it('renders add to tree dropdown when permissions are true', async () => {
factory('/', { canCollaborate: true });
......
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