Commit a7d06d42 authored by Alexander Turinske's avatar Alexander Turinske

Fix linking url creation of incident

- add tests
parent 2c056e66
......@@ -131,7 +131,13 @@ export default {
getIssueMeta({ issue: { iid, state } }) {
return {
state: state === 'closed' ? `(${this.$options.i18n.CLOSED})` : '',
link: joinPaths(gon.relative_url_root, 'issues/incident', iid),
link: joinPaths(
gon.relative_url_root || '/',
this.projectPath,
'-',
'issues/incident',
iid,
),
};
},
handleAlertError(msg) {
......
......@@ -45,8 +45,7 @@ describe('AlertsList component', () => {
const findIdColumn = () => wrapper.findByTestId('threat-alerts-id');
const findEventCountColumn = () => wrapper.findByTestId('threat-alerts-event-count');
const findIssueColumn = () => wrapper.findByTestId('threat-alerts-issue');
const findIssueColumnTextAt = (id) =>
wrapper.findAllByTestId('threat-alerts-issue').at(id).text();
const findIssueColumnAt = (id) => wrapper.findAllByTestId('threat-alerts-issue').at(id);
const findStatusColumn = () => wrapper.findComponent(AlertStatus);
const findStatusColumnHeader = () => wrapper.findByTestId('threat-alerts-status-header');
const findEmptyState = () => wrapper.findByTestId('threat-alerts-empty-state');
......@@ -182,11 +181,26 @@ describe('AlertsList component', () => {
});
it.each`
description | id | text
${'when an issue is created and is open'} | ${0} | ${'#5'}
${'when an issue is created and is closed'} | ${1} | ${'#6 (closed)'}
`('displays the correct text $description', ({ id, text }) => {
expect(findIssueColumnTextAt(id)).toBe(text);
description | id | text | link
${'when an issue is created and is open'} | ${0} | ${'#5'} | ${'/#/-/issues/incident/5'}
${'when an issue is created and is closed'} | ${1} | ${'#6 (closed)'} | ${'/#/-/issues/incident/6'}
`('displays the correct text $description', ({ id, text, link }) => {
expect(findIssueColumnAt(id).text()).toBe(text);
expect(findIssueColumnAt(id).attributes('href')).toBe(link);
});
describe('gon.relative_url_root', () => {
beforeAll(() => {
gon.relative_url_root = '/test';
});
afterEach(() => {
gon.relative_url_root = '';
});
it('creates the correct href when the gon.relative_url_root is set', () => {
expect(findIssueColumnAt(0).attributes('href')).toBe('/test/#/-/issues/incident/5');
});
});
});
});
......
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