Commit 3aa32bf7 authored by David O'Regan's avatar David O'Regan Committed by Martin Wortschack

Use visitUrl in Alert management

parent e4d0c250
...@@ -13,7 +13,7 @@ import { ...@@ -13,7 +13,7 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths, visitUrl } from '~/lib/utils/url_utility';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import getAlerts from '../graphql/queries/getAlerts.query.graphql'; import getAlerts from '../graphql/queries/getAlerts.query.graphql';
import { ALERTS_STATUS, ALERTS_STATUS_TABS, ALERTS_SEVERITY_LABELS } from '../constants'; import { ALERTS_STATUS, ALERTS_STATUS_TABS, ALERTS_SEVERITY_LABELS } from '../constants';
...@@ -173,8 +173,8 @@ export default { ...@@ -173,8 +173,8 @@ export default {
); );
}); });
}, },
handleRowClick({ iid }) { navigateToAlertDetails({ iid }) {
window.location.assign(joinPaths(window.location.pathname, iid, 'details')); return visitUrl(joinPaths(window.location.pathname, iid, 'details'));
}, },
}, },
}; };
...@@ -209,7 +209,7 @@ export default { ...@@ -209,7 +209,7 @@ export default {
:busy="loading" :busy="loading"
stacked="md" stacked="md"
:tbody-tr-class="$options.bodyTrClass" :tbody-tr-class="$options.bodyTrClass"
@row-clicked="handleRowClick" @row-clicked="navigateToAlertDetails"
> >
<template #cell(severity)="{ item }"> <template #cell(severity)="{ item }">
<div <div
......
---
title: Use visitUrl in Alert management
merge_request: 32414
author:
type: other
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
GlIcon, GlIcon,
GlTab, GlTab,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility';
import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue';
import createFlash from '~/flash'; import createFlash from '~/flash';
import AlertManagementList from '~/alert_management/components/alert_management_list.vue'; import AlertManagementList from '~/alert_management/components/alert_management_list.vue';
...@@ -18,6 +19,11 @@ import mockAlerts from '../mocks/alerts.json'; ...@@ -18,6 +19,11 @@ import mockAlerts from '../mocks/alerts.json';
jest.mock('~/flash'); jest.mock('~/flash');
jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn().mockName('visitUrlMock'),
joinPaths: jest.requireActual('~/lib/utils/url_utility').joinPaths,
}));
describe('AlertManagementList', () => { describe('AlertManagementList', () => {
let wrapper; let wrapper;
...@@ -220,12 +226,10 @@ describe('AlertManagementList', () => { ...@@ -220,12 +226,10 @@ describe('AlertManagementList', () => {
loading: false, loading: false,
}); });
window.location.assign = jest.fn();
findAlerts() findAlerts()
.at(0) .at(0)
.trigger('click'); .trigger('click');
expect(window.location.assign).toHaveBeenCalledWith('/1527542/details'); expect(visitUrl).toHaveBeenCalledWith('/1527542/details');
}); });
describe('handle date fields', () => { describe('handle date fields', () => {
......
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