summaryrefslogtreecommitdiff
path: root/spec/frontend/incidents
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/frontend/incidents
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
downloadgitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/frontend/incidents')
-rw-r--r--spec/frontend/incidents/components/incidents_list_spec.js116
-rw-r--r--spec/frontend/incidents/mocks/incidents.json8
2 files changed, 85 insertions, 39 deletions
diff --git a/spec/frontend/incidents/components/incidents_list_spec.js b/spec/frontend/incidents/components/incidents_list_spec.js
index 1be6007d844..9ed0294e876 100644
--- a/spec/frontend/incidents/components/incidents_list_spec.js
+++ b/spec/frontend/incidents/components/incidents_list_spec.js
@@ -1,6 +1,7 @@
import { GlAlert, GlLoadingIcon, GlTable, GlAvatar, GlEmptyState } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import { nextTick } from 'vue';
+import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import IncidentsList from '~/incidents/components/incidents_list.vue';
import {
I18N,
@@ -19,7 +20,7 @@ import mockIncidents from '../mocks/incidents.json';
jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn().mockName('visitUrlMock'),
- joinPaths: jest.fn(),
+ joinPaths: jest.requireActual('~/lib/utils/url_utility').joinPaths,
mergeUrlParams: jest.fn(),
setUrlParams: jest.fn(),
updateHistory: jest.fn(),
@@ -48,47 +49,52 @@ describe('Incidents List', () => {
const findClosedIcon = () => wrapper.findAll("[data-testid='incident-closed']");
const findEmptyState = () => wrapper.find(GlEmptyState);
const findSeverity = () => wrapper.findAll(SeverityToken);
+ const findEscalationStatus = () => wrapper.findAll('[data-testid="incident-escalation-status"]');
+ const findIncidentLink = () => wrapper.findByTestId('incident-link');
function mountComponent({ data = {}, loading = false, provide = {} } = {}) {
- wrapper = mount(IncidentsList, {
- data() {
- return {
- incidents: [],
- incidentsCount: {},
- ...data,
- };
- },
- mocks: {
- $apollo: {
- queries: {
- incidents: {
- loading,
+ wrapper = extendedWrapper(
+ mount(IncidentsList, {
+ data() {
+ return {
+ incidents: [],
+ incidentsCount: {},
+ ...data,
+ };
+ },
+ mocks: {
+ $apollo: {
+ queries: {
+ incidents: {
+ loading,
+ },
},
},
},
- },
- provide: {
- projectPath: '/project/path',
- newIssuePath,
- incidentTemplateName,
- incidentType,
- issuePath: '/project/issues',
- publishedAvailable: true,
- emptyListSvgPath,
- textQuery: '',
- authorUsernameQuery: '',
- assigneeUsernameQuery: '',
- slaFeatureAvailable: true,
- canCreateIncident: true,
- ...provide,
- },
- stubs: {
- GlButton: true,
- GlAvatar: true,
- GlEmptyState: true,
- ServiceLevelAgreementCell: true,
- },
- });
+ provide: {
+ projectPath: '/project/path',
+ newIssuePath,
+ incidentTemplateName,
+ incidentType,
+ issuePath: '/project/issues',
+ publishedAvailable: true,
+ emptyListSvgPath,
+ textQuery: '',
+ authorUsernameQuery: '',
+ assigneeUsernameQuery: '',
+ slaFeatureAvailable: true,
+ canCreateIncident: true,
+ incidentEscalationsAvailable: true,
+ ...provide,
+ },
+ stubs: {
+ GlButton: true,
+ GlAvatar: true,
+ GlEmptyState: true,
+ ServiceLevelAgreementCell: true,
+ },
+ }),
+ );
}
afterEach(() => {
@@ -158,6 +164,14 @@ describe('Incidents List', () => {
expect(findTimeAgo().length).toBe(mockIncidents.length);
});
+ it('renders a link to the incident as the incident title', () => {
+ const { title, iid } = mockIncidents[0];
+ const link = findIncidentLink();
+
+ expect(link.text()).toBe(title);
+ expect(link.attributes('href')).toContain(`issues/incident/${iid}`);
+ });
+
describe('Assignees', () => {
it('shows Unassigned when there are no assignees', () => {
expect(findAssignees().at(0).text()).toBe(I18N.unassigned);
@@ -184,6 +198,34 @@ describe('Incidents List', () => {
expect(findSeverity().length).toBe(mockIncidents.length);
});
+ describe('Escalation status', () => {
+ it('renders escalation status per row', () => {
+ expect(findEscalationStatus().length).toBe(mockIncidents.length);
+
+ const actualStatuses = findEscalationStatus().wrappers.map((status) => status.text());
+ expect(actualStatuses).toEqual([
+ 'Triggered',
+ 'Acknowledged',
+ 'Resolved',
+ I18N.noEscalationStatus,
+ ]);
+ });
+
+ describe('when feature is disabled', () => {
+ beforeEach(() => {
+ mountComponent({
+ data: { incidents: { list: mockIncidents }, incidentsCount },
+ provide: { incidentEscalationsAvailable: false },
+ loading: false,
+ });
+ });
+
+ it('is absent if feature flag is disabled', () => {
+ expect(findEscalationStatus().length).toBe(0);
+ });
+ });
+ });
+
it('contains a link to the incident details page', async () => {
findTableRows().at(0).trigger('click');
expect(visitUrl).toHaveBeenCalledWith(
diff --git a/spec/frontend/incidents/mocks/incidents.json b/spec/frontend/incidents/mocks/incidents.json
index 357b94e5b6c..479b0809de3 100644
--- a/spec/frontend/incidents/mocks/incidents.json
+++ b/spec/frontend/incidents/mocks/incidents.json
@@ -7,6 +7,7 @@
"assignees": {},
"state": "opened",
"severity": "CRITICAL",
+ "escalationStatus": "TRIGGERED",
"slaDueAt": "2020-06-04T12:46:08Z"
},
{
@@ -26,6 +27,7 @@
},
"state": "opened",
"severity": "HIGH",
+ "escalationStatus": "ACKNOWLEDGED",
"slaDueAt": null
},
{
@@ -35,7 +37,8 @@
"createdAt": "2020-05-19T08:53:55Z",
"assignees": {},
"state": "closed",
- "severity": "LOW"
+ "severity": "LOW",
+ "escalationStatus": "RESOLVED"
},
{
"id": 4,
@@ -44,6 +47,7 @@
"createdAt": "2020-05-18T17:13:35Z",
"assignees": {},
"state": "closed",
- "severity": "MEDIUM"
+ "severity": "MEDIUM",
+ "escalationStatus": null
}
]