Commit d8fa67ba authored by Dave Pisek's avatar Dave Pisek

Reviewer feedback: Minor changes

parent 3a367350
...@@ -16,7 +16,8 @@ export default { ...@@ -16,7 +16,8 @@ export default {
computed: { computed: {
commitPath() { commitPath() {
const { projectFullPath, value } = this; const { projectFullPath, value } = this;
// this ensures an absolute path, as `projectFullPath` can be relative in some cases (e.g.: pipeline security tab) // `projectFullPath` comes in two flavors: relative (e.g.: `group/project`) and absolute (e.g.: `/group/project`)
// adding a leading slash to the relative path makes sure we always link to an absolute path
const absoluteProjectPath = isRootRelative(projectFullPath) const absoluteProjectPath = isRootRelative(projectFullPath)
? projectFullPath ? projectFullPath
: `/${projectFullPath}`; : `/${projectFullPath}`;
......
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Url from 'ee/vulnerabilities/components/generic_report/types/commit.vue'; import Commit from 'ee/vulnerabilities/components/generic_report/types/commit.vue';
const TEST_DATA = { const TEST_DATA = {
value: '24922148', value: '24922148',
...@@ -10,10 +10,8 @@ describe('ee/vulnerabilities/components/generic_report/types/commit.vue', () => ...@@ -10,10 +10,8 @@ describe('ee/vulnerabilities/components/generic_report/types/commit.vue', () =>
let wrapper; let wrapper;
const createWrapper = ({ provide } = {}) => { const createWrapper = ({ provide } = {}) => {
return shallowMount(Url, { return shallowMount(Commit, {
propsData: { propsData: TEST_DATA,
...TEST_DATA,
},
provide: { provide: {
projectFullPath: '', projectFullPath: '',
...provide, ...provide,
...@@ -28,7 +26,7 @@ describe('ee/vulnerabilities/components/generic_report/types/commit.vue', () => ...@@ -28,7 +26,7 @@ describe('ee/vulnerabilities/components/generic_report/types/commit.vue', () =>
}); });
it.each(['/foo/bar', 'foo/bar'])( it.each(['/foo/bar', 'foo/bar'])(
'given `projectFullPath` is "%s" it links links to the absolute path of the commit', 'given `projectFullPath` is "%s" it links to the absolute path of the commit',
(projectFullPath) => { (projectFullPath) => {
const absoluteCommitPath = `/foo/bar/-/commit/${TEST_DATA.value}`; const absoluteCommitPath = `/foo/bar/-/commit/${TEST_DATA.value}`;
......
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