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