Commit 991ffa34 authored by Tristan Read's avatar Tristan Read Committed by Peter Leitzen

Update incident list specs

parent 9fc28484
...@@ -78,6 +78,7 @@ describe('Incidents List', () => { ...@@ -78,6 +78,7 @@ describe('Incidents List', () => {
authorUsernameQuery: '', authorUsernameQuery: '',
assigneeUsernameQuery: '', assigneeUsernameQuery: '',
slaFeatureAvailable: true, slaFeatureAvailable: true,
canCreateIncident: true,
...provide, ...provide,
}, },
stubs: { stubs: {
...@@ -105,21 +106,23 @@ describe('Incidents List', () => { ...@@ -105,21 +106,23 @@ describe('Incidents List', () => {
describe('empty state', () => { describe('empty state', () => {
const { const {
emptyState: { title, emptyClosedTabTitle, description }, emptyState: { title, emptyClosedTabTitle, description, cannotCreateIncidentDescription },
} = I18N; } = I18N;
it.each` it.each`
statusFilter | all | closed | expectedTitle | expectedDescription statusFilter | all | closed | expectedTitle | canCreateIncident | expectedDescription
${'all'} | ${2} | ${1} | ${title} | ${description} ${'all'} | ${2} | ${1} | ${title} | ${true} | ${description}
${'open'} | ${2} | ${0} | ${title} | ${description} ${'open'} | ${2} | ${0} | ${title} | ${true} | ${description}
${'closed'} | ${0} | ${0} | ${title} | ${description} ${'closed'} | ${0} | ${0} | ${title} | ${true} | ${description}
${'closed'} | ${2} | ${0} | ${emptyClosedTabTitle} | ${undefined} ${'closed'} | ${2} | ${0} | ${emptyClosedTabTitle} | ${true} | ${undefined}
${'all'} | ${2} | ${1} | ${title} | ${false} | ${cannotCreateIncidentDescription}
`( `(
`when active tab is $statusFilter and there are $all incidents in total and $closed closed incidents, the empty state `when active tab is $statusFilter and there are $all incidents in total and $closed closed incidents, the empty state
has title: $expectedTitle and description: $expectedDescription`, has title: $expectedTitle and description: $expectedDescription`,
({ statusFilter, all, closed, expectedTitle, expectedDescription }) => { ({ statusFilter, all, closed, expectedTitle, expectedDescription, canCreateIncident }) => {
mountComponent({ mountComponent({
data: { incidents: { list: [] }, incidentsCount: { all, closed }, statusFilter }, data: { incidents: { list: [] }, incidentsCount: { all, closed }, statusFilter },
provide: { canCreateIncident },
loading: false, loading: false,
}); });
expect(findEmptyState().exists()).toBe(true); expect(findEmptyState().exists()).toBe(true);
...@@ -219,6 +222,15 @@ describe('Incidents List', () => { ...@@ -219,6 +222,15 @@ describe('Incidents List', () => {
expect(findCreateIncidentBtn().exists()).toBe(false); expect(findCreateIncidentBtn().exists()).toBe(false);
}); });
it("doesn't show the button when user does not have incident creation permissions", () => {
mountComponent({
data: { incidents: { list: mockIncidents }, incidentsCount: {} },
provide: { canCreateIncident: false },
loading: false,
});
expect(findCreateIncidentBtn().exists()).toBe(false);
});
it('should track create new incident button', async () => { it('should track create new incident button', async () => {
findCreateIncidentBtn().vm.$emit('click'); findCreateIncidentBtn().vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
......
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