Commit 96a825cf authored by David O'Regan's avatar David O'Regan

Update from feedback

parent 55aa2d1f
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
GlEmptyState, GlEmptyState,
} from '@gitlab/ui'; } from '@gitlab/ui';
import Api from '~/api'; import Api from '~/api';
import Tracking from '~/tracking';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import FilteredSearchBar from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue'; import FilteredSearchBar from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue';
import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue'; import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue';
...@@ -41,6 +42,7 @@ import { ...@@ -41,6 +42,7 @@ import {
TH_SEVERITY_TEST_ID, TH_SEVERITY_TEST_ID,
TH_PUBLISHED_TEST_ID, TH_PUBLISHED_TEST_ID,
INCIDENT_DETAILS_PATH, INCIDENT_DETAILS_PATH,
trackIncidentCreateNewOptions,
} from '../constants'; } from '../constants';
const tdClass = const tdClass =
...@@ -58,6 +60,7 @@ const initialPaginationState = { ...@@ -58,6 +60,7 @@ const initialPaginationState = {
}; };
export default { export default {
trackIncidentCreateNewOptions,
i18n: I18N, i18n: I18N,
statusTabs: INCIDENT_STATUS_TABS, statusTabs: INCIDENT_STATUS_TABS,
fields: [ fields: [
...@@ -335,6 +338,11 @@ export default { ...@@ -335,6 +338,11 @@ export default {
navigateToIncidentDetails({ iid }) { navigateToIncidentDetails({ iid }) {
return visitUrl(joinPaths(this.issuePath, INCIDENT_DETAILS_PATH, iid)); return visitUrl(joinPaths(this.issuePath, INCIDENT_DETAILS_PATH, iid));
}, },
navigateToCreateNewIncident() {
const { category, action } = this.$options.trackIncidentCreateNewOptions;
Tracking.event(category, action);
this.redirecting = true;
},
handlePageChange(page) { handlePageChange(page) {
const { startCursor, endCursor } = this.incidents.pageInfo; const { startCursor, endCursor } = this.incidents.pageInfo;
...@@ -458,7 +466,7 @@ export default { ...@@ -458,7 +466,7 @@ export default {
category="primary" category="primary"
variant="success" variant="success"
:href="newIncidentPath" :href="newIncidentPath"
@click="redirecting = true" @click="navigateToCreateNewIncident"
> >
{{ $options.i18n.createIncidentBtnLabel }} {{ $options.i18n.createIncidentBtnLabel }}
</gl-button> </gl-button>
......
/* eslint-disable @gitlab/require-i18n-strings */
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
export const I18N = { export const I18N = {
...@@ -34,6 +35,14 @@ export const INCIDENT_STATUS_TABS = [ ...@@ -34,6 +35,14 @@ export const INCIDENT_STATUS_TABS = [
}, },
]; ];
/**
* Tracks snowplow event when user clicks create new incident
*/
export const trackIncidentCreateNewOptions = {
category: 'Incident Management',
action: 'create_incident_button_clicks',
};
export const DEFAULT_PAGE_SIZE = 20; export const DEFAULT_PAGE_SIZE = 20;
export const TH_CREATED_AT_TEST_ID = { 'data-testid': 'incident-management-created-at-sort' }; export const TH_CREATED_AT_TEST_ID = { 'data-testid': 'incident-management-created-at-sort' };
export const TH_SEVERITY_TEST_ID = { 'data-testid': 'incident-management-severity-sort' }; export const TH_SEVERITY_TEST_ID = { 'data-testid': 'incident-management-severity-sort' };
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
GlBadge, GlBadge,
GlEmptyState, GlEmptyState,
} from '@gitlab/ui'; } from '@gitlab/ui';
import Tracking from '~/tracking';
import { visitUrl, joinPaths, mergeUrlParams } from '~/lib/utils/url_utility'; import { visitUrl, joinPaths, mergeUrlParams } from '~/lib/utils/url_utility';
import IncidentsList from '~/incidents/components/incidents_list.vue'; import IncidentsList from '~/incidents/components/incidents_list.vue';
import SeverityToken from '~/sidebar/components/severity/severity.vue'; import SeverityToken from '~/sidebar/components/severity/severity.vue';
...@@ -22,6 +23,7 @@ import { ...@@ -22,6 +23,7 @@ import {
TH_CREATED_AT_TEST_ID, TH_CREATED_AT_TEST_ID,
TH_SEVERITY_TEST_ID, TH_SEVERITY_TEST_ID,
TH_PUBLISHED_TEST_ID, TH_PUBLISHED_TEST_ID,
trackIncidentCreateNewOptions,
} from '~/incidents/constants'; } from '~/incidents/constants';
import mockIncidents from '../mocks/incidents.json'; import mockIncidents from '../mocks/incidents.json';
import mockFilters from '../mocks/incidents_filter.json'; import mockFilters from '../mocks/incidents_filter.json';
...@@ -33,6 +35,7 @@ jest.mock('~/lib/utils/url_utility', () => ({ ...@@ -33,6 +35,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
setUrlParams: jest.fn(), setUrlParams: jest.fn(),
updateHistory: jest.fn(), updateHistory: jest.fn(),
})); }));
jest.mock('~/tracking');
describe('Incidents List', () => { describe('Incidents List', () => {
let wrapper; let wrapper;
...@@ -52,7 +55,7 @@ describe('Incidents List', () => { ...@@ -52,7 +55,7 @@ describe('Incidents List', () => {
const findLoader = () => wrapper.find(GlLoadingIcon); const findLoader = () => wrapper.find(GlLoadingIcon);
const findTimeAgo = () => wrapper.findAll(TimeAgoTooltip); const findTimeAgo = () => wrapper.findAll(TimeAgoTooltip);
const findSearch = () => wrapper.find(FilteredSearchBar); const findSearch = () => wrapper.find(FilteredSearchBar);
const findAssingees = () => wrapper.findAll('[data-testid="incident-assignees"]'); const findAssignees = () => wrapper.findAll('[data-testid="incident-assignees"]');
const findCreateIncidentBtn = () => wrapper.find('[data-testid="createIncidentBtn"]'); const findCreateIncidentBtn = () => wrapper.find('[data-testid="createIncidentBtn"]');
const findClosedIcon = () => wrapper.findAll("[data-testid='incident-closed']"); const findClosedIcon = () => wrapper.findAll("[data-testid='incident-closed']");
const findPagination = () => wrapper.find(GlPagination); const findPagination = () => wrapper.find(GlPagination);
...@@ -164,14 +167,14 @@ describe('Incidents List', () => { ...@@ -164,14 +167,14 @@ describe('Incidents List', () => {
describe('Assignees', () => { describe('Assignees', () => {
it('shows Unassigned when there are no assignees', () => { it('shows Unassigned when there are no assignees', () => {
expect( expect(
findAssingees() findAssignees()
.at(0) .at(0)
.text(), .text(),
).toBe(I18N.unassigned); ).toBe(I18N.unassigned);
}); });
it('renders an avatar component when there is an assignee', () => { it('renders an avatar component when there is an assignee', () => {
const avatar = findAssingees() const avatar = findAssignees()
.at(1) .at(1)
.find(GlAvatar); .find(GlAvatar);
const { src, label } = avatar.attributes(); const { src, label } = avatar.attributes();
...@@ -211,7 +214,7 @@ describe('Incidents List', () => { ...@@ -211,7 +214,7 @@ describe('Incidents List', () => {
}); });
}); });
it('shows the button linking to new incidents page with prefilled incident template when clicked', () => { it('shows the button linking to new incidents page with pre-filled incident template when clicked', () => {
expect(findCreateIncidentBtn().exists()).toBe(true); expect(findCreateIncidentBtn().exists()).toBe(true);
findCreateIncidentBtn().trigger('click'); findCreateIncidentBtn().trigger('click');
expect(mergeUrlParams).toHaveBeenCalledWith( expect(mergeUrlParams).toHaveBeenCalledWith(
...@@ -233,6 +236,13 @@ describe('Incidents List', () => { ...@@ -233,6 +236,13 @@ describe('Incidents List', () => {
}); });
expect(findCreateIncidentBtn().exists()).toBe(false); expect(findCreateIncidentBtn().exists()).toBe(false);
}); });
it('should track alert list page views', async () => {
findCreateIncidentBtn().vm.$emit('click');
await wrapper.vm.$nextTick();
const { category, action } = trackIncidentCreateNewOptions;
expect(Tracking.event).toHaveBeenCalledWith(category, action);
});
}); });
describe('Pagination', () => { describe('Pagination', () => {
......
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