summaryrefslogtreecommitdiff
path: root/spec/frontend/issue_show
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/issue_show')
-rw-r--r--spec/frontend/issue_show/components/app_spec.js12
-rw-r--r--spec/frontend/issue_show/components/description_spec.js2
-rw-r--r--spec/frontend/issue_show/components/edit_actions_spec.js12
-rw-r--r--spec/frontend/issue_show/components/fields/description_spec.js4
-rw-r--r--spec/frontend/issue_show/components/form_spec.js2
-rw-r--r--spec/frontend/issue_show/components/header_actions_spec.js9
-rw-r--r--spec/frontend/issue_show/components/incidents/highlight_bar_spec.js2
-rw-r--r--spec/frontend/issue_show/components/incidents/incident_tabs_spec.js75
-rw-r--r--spec/frontend/issue_show/components/pinned_links_spec.js14
-rw-r--r--spec/frontend/issue_show/issue_spec.js2
10 files changed, 73 insertions, 61 deletions
diff --git a/spec/frontend/issue_show/components/app_spec.js b/spec/frontend/issue_show/components/app_spec.js
index dde4e8458d5..ec2055ca7d1 100644
--- a/spec/frontend/issue_show/components/app_spec.js
+++ b/spec/frontend/issue_show/components/app_spec.js
@@ -47,6 +47,7 @@ describe('Issuable output', () => {
provide: {
fullPath: 'gitlab-org/incidents',
iid: '19',
+ uploadMetricsFeatureAvailable: false,
},
stubs: {
HighlightBar: true,
@@ -398,8 +399,8 @@ describe('Issuable output', () => {
wrapper.vm.poll.makeRequest();
- return new Promise(resolve => {
- wrapper.vm.$watch('formState.lockedWarningVisible', value => {
+ return new Promise((resolve) => {
+ wrapper.vm.$watch('formState.lockedWarningVisible', (value) => {
if (value) {
resolve();
}
@@ -507,13 +508,6 @@ describe('Issuable output', () => {
expect(wrapper.vm.issueChanged).toBe(false);
});
- it('returns false when `initialTitleText` is null and `formState.title` is empty string', () => {
- wrapper.vm.store.formState.title = '';
- wrapper.setProps({ initialTitleText: null });
-
- expect(wrapper.vm.issueChanged).toBe(false);
- });
-
it('returns true when description is changed', () => {
wrapper.vm.store.formState.description = 'RandomText';
diff --git a/spec/frontend/issue_show/components/description_spec.js b/spec/frontend/issue_show/components/description_spec.js
index bc7511225a0..de53d98e6be 100644
--- a/spec/frontend/issue_show/components/description_spec.js
+++ b/spec/frontend/issue_show/components/description_spec.js
@@ -74,7 +74,7 @@ describe('Description component', () => {
let modal;
const recaptchaChild = vm.$children.find(
// eslint-disable-next-line no-underscore-dangle
- child => child.$options._componentTag === 'recaptcha-modal',
+ (child) => child.$options._componentTag === 'recaptcha-modal',
);
recaptchaChild.scriptSrc = '//scriptsrc';
diff --git a/spec/frontend/issue_show/components/edit_actions_spec.js b/spec/frontend/issue_show/components/edit_actions_spec.js
index 79a2bcd5eab..6a00eec4b1f 100644
--- a/spec/frontend/issue_show/components/edit_actions_spec.js
+++ b/spec/frontend/issue_show/components/edit_actions_spec.js
@@ -6,7 +6,7 @@ import Store from '~/issue_show/stores';
describe('Edit Actions components', () => {
let vm;
- beforeEach(done => {
+ beforeEach((done) => {
const Component = Vue.extend(editActions);
const store = new Store({
titleHtml: '',
@@ -34,7 +34,7 @@ describe('Edit Actions components', () => {
expect(vm.$el.querySelectorAll('[disabled]').length).toBe(0);
});
- it('does not render delete button if canUpdate is false', done => {
+ it('does not render delete button if canUpdate is false', (done) => {
vm.canDestroy = false;
Vue.nextTick(() => {
@@ -44,7 +44,7 @@ describe('Edit Actions components', () => {
});
});
- it('disables submit button when title is blank', done => {
+ it('disables submit button when title is blank', (done) => {
vm.formState.title = '';
Vue.nextTick(() => {
@@ -54,7 +54,7 @@ describe('Edit Actions components', () => {
});
});
- it('should not show delete button if showDeleteButton is false', done => {
+ it('should not show delete button if showDeleteButton is false', (done) => {
vm.showDeleteButton = false;
Vue.nextTick(() => {
@@ -70,7 +70,7 @@ describe('Edit Actions components', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
});
- it('disabled button after clicking save button', done => {
+ it('disabled button after clicking save button', (done) => {
vm.$el.querySelector('.btn-success').click();
Vue.nextTick(() => {
@@ -97,7 +97,7 @@ describe('Edit Actions components', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('delete.issuable', { destroy_confirm: true });
});
- it('does no actions when confirm is false', done => {
+ it('does no actions when confirm is false', (done) => {
jest.spyOn(window, 'confirm').mockReturnValue(false);
vm.$el.querySelector('.btn-danger').click();
diff --git a/spec/frontend/issue_show/components/fields/description_spec.js b/spec/frontend/issue_show/components/fields/description_spec.js
index 8ea326ad1ee..96c81c419d0 100644
--- a/spec/frontend/issue_show/components/fields/description_spec.js
+++ b/spec/frontend/issue_show/components/fields/description_spec.js
@@ -8,7 +8,7 @@ describe('Description field component', () => {
let vm;
let store;
- beforeEach(done => {
+ beforeEach((done) => {
const Component = Vue.extend(descriptionField);
const el = document.createElement('div');
store = new Store({
@@ -38,7 +38,7 @@ describe('Description field component', () => {
expect(vm.$el.querySelector('.md-area textarea').value).toBe('test');
});
- it('renders markdown field with a markdown description', done => {
+ it('renders markdown field with a markdown description', (done) => {
store.formState.description = '**test**';
Vue.nextTick(() => {
diff --git a/spec/frontend/issue_show/components/form_spec.js b/spec/frontend/issue_show/components/form_spec.js
index b06a3a89d3b..4e123f606f6 100644
--- a/spec/frontend/issue_show/components/form_spec.js
+++ b/spec/frontend/issue_show/components/form_spec.js
@@ -26,7 +26,7 @@ describe('Inline edit form component', () => {
vm.$destroy();
});
- const createComponent = props => {
+ const createComponent = (props) => {
const Component = Vue.extend(formComponent);
vm = mountComponent(Component, {
diff --git a/spec/frontend/issue_show/components/header_actions_spec.js b/spec/frontend/issue_show/components/header_actions_spec.js
index b9836ae7240..4df62ec8717 100644
--- a/spec/frontend/issue_show/components/header_actions_spec.js
+++ b/spec/frontend/issue_show/components/header_actions_spec.js
@@ -62,7 +62,7 @@ describe('HeaderActions component', () => {
const findToggleIssueStateButton = () => wrapper.find(GlButton);
- const findDropdownAt = index => wrapper.findAll(GlDropdown).at(index);
+ const findDropdownAt = (index) => wrapper.findAll(GlDropdown).at(index);
const findMobileDropdownItems = () => findDropdownAt(0).findAll(GlDropdownItem);
@@ -70,10 +70,7 @@ describe('HeaderActions component', () => {
const findModal = () => wrapper.find(GlModal);
- const findModalLinkAt = index =>
- findModal()
- .findAll(GlLink)
- .at(index);
+ const findModalLinkAt = (index) => findModal().findAll(GlLink).at(index);
const mountComponent = ({
props = {},
@@ -208,7 +205,7 @@ describe('HeaderActions component', () => {
it(`${isItemVisible ? 'shows' : 'hides'} "${itemText}" item`, () => {
expect(
findDropdownItems()
- .filter(item => item.text() === itemText)
+ .filter((item) => item.text() === itemText)
.exists(),
).toBe(isItemVisible);
});
diff --git a/spec/frontend/issue_show/components/incidents/highlight_bar_spec.js b/spec/frontend/issue_show/components/incidents/highlight_bar_spec.js
index c1ab4433761..112cb4d4c3a 100644
--- a/spec/frontend/issue_show/components/incidents/highlight_bar_spec.js
+++ b/spec/frontend/issue_show/components/incidents/highlight_bar_spec.js
@@ -17,7 +17,7 @@ describe('Highlight Bar', () => {
title: 'Alert 1',
};
- const mountComponent = options => {
+ const mountComponent = (options) => {
wrapper = shallowMount(
HighlightBar,
merge(
diff --git a/spec/frontend/issue_show/components/incidents/incident_tabs_spec.js b/spec/frontend/issue_show/components/incidents/incident_tabs_spec.js
index c6200fd69bf..416870d1408 100644
--- a/spec/frontend/issue_show/components/incidents/incident_tabs_spec.js
+++ b/spec/frontend/issue_show/components/incidents/incident_tabs_spec.js
@@ -1,5 +1,7 @@
import { shallowMount } from '@vue/test-utils';
+import merge from 'lodash/merge';
import { GlTab } from '@gitlab/ui';
+import waitForPromises from 'helpers/wait_for_promises';
import INVALID_URL from '~/lib/utils/invalid_url';
import IncidentTabs from '~/issue_show/components/incidents/incident_tabs.vue';
import { descriptionProps } from '../../mock_data';
@@ -18,36 +20,45 @@ const mockAlert = {
describe('Incident Tabs component', () => {
let wrapper;
- const mountComponent = (data = {}) => {
- wrapper = shallowMount(IncidentTabs, {
- propsData: {
- ...descriptionProps,
- },
- stubs: {
- DescriptionComponent: true,
- },
- provide: {
- fullPath: '',
- iid: '',
- },
- data() {
- return { alert: mockAlert, ...data };
- },
- mocks: {
- $apollo: {
- queries: {
- alert: {
- loading: true,
+ const mountComponent = (data = {}, options = {}) => {
+ wrapper = shallowMount(
+ IncidentTabs,
+ merge(
+ {
+ propsData: {
+ ...descriptionProps,
+ },
+ stubs: {
+ DescriptionComponent: true,
+ MetricsTab: true,
+ },
+ provide: {
+ fullPath: '',
+ iid: '',
+ uploadMetricsFeatureAvailable: true,
+ },
+ data() {
+ return { alert: mockAlert, ...data };
+ },
+ mocks: {
+ $apollo: {
+ queries: {
+ alert: {
+ loading: true,
+ },
+ },
},
},
},
- },
- });
+ options,
+ ),
+ );
};
const findTabs = () => wrapper.findAll(GlTab);
const findSummaryTab = () => findTabs().at(0);
- const findAlertDetailsTab = () => findTabs().at(1);
+ const findMetricsTab = () => wrapper.find('[data-testid="metrics-tab"]');
+ const findAlertDetailsTab = () => wrapper.find('[data-testid="alert-details-tab"]');
const findAlertDetailsComponent = () => wrapper.find(AlertDetailsTable);
const findDescriptionComponent = () => wrapper.find(DescriptionComponent);
const findHighlightBarComponent = () => wrapper.find(HighlightBar);
@@ -100,6 +111,24 @@ describe('Incident Tabs component', () => {
});
});
+ describe('upload metrics feature available', () => {
+ it('shows the metric tab when metrics are available', async () => {
+ mountComponent({}, { provide: { uploadMetricsFeatureAvailable: true } });
+
+ await waitForPromises();
+
+ expect(findMetricsTab().exists()).toBe(true);
+ });
+
+ it('hides the tab when metrics are not available', async () => {
+ mountComponent({}, { provide: { uploadMetricsFeatureAvailable: false } });
+
+ await waitForPromises();
+
+ expect(findMetricsTab().exists()).toBe(false);
+ });
+ });
+
describe('Snowplow tracking', () => {
beforeEach(() => {
jest.spyOn(Tracking, 'event');
diff --git a/spec/frontend/issue_show/components/pinned_links_spec.js b/spec/frontend/issue_show/components/pinned_links_spec.js
index bb67feee601..2d140fd068a 100644
--- a/spec/frontend/issue_show/components/pinned_links_spec.js
+++ b/spec/frontend/issue_show/components/pinned_links_spec.js
@@ -11,7 +11,7 @@ describe('PinnedLinks', () => {
const findButtons = () => wrapper.findAll(GlButton);
- const createComponent = props => {
+ const createComponent = (props) => {
wrapper = shallowMount(PinnedLinks, {
propsData: {
zoomMeetingUrl: '',
@@ -26,11 +26,7 @@ describe('PinnedLinks', () => {
zoomMeetingUrl: `<a href="${plainZoomUrl}">Zoom</a>`,
});
- expect(
- findButtons()
- .at(0)
- .text(),
- ).toBe(JOIN_ZOOM_MEETING);
+ expect(findButtons().at(0).text()).toBe(JOIN_ZOOM_MEETING);
});
it('displays Status link', () => {
@@ -38,11 +34,7 @@ describe('PinnedLinks', () => {
publishedIncidentUrl: `<a href="${plainStatusUrl}">Status</a>`,
});
- expect(
- findButtons()
- .at(0)
- .text(),
- ).toBe(STATUS_PAGE_PUBLISHED);
+ expect(findButtons().at(0).text()).toBe(STATUS_PAGE_PUBLISHED);
});
it('does not render if there are no links', () => {
diff --git a/spec/frontend/issue_show/issue_spec.js b/spec/frontend/issue_show/issue_spec.js
index cee9969d26a..818f501882b 100644
--- a/spec/frontend/issue_show/issue_spec.js
+++ b/spec/frontend/issue_show/issue_spec.js
@@ -14,7 +14,7 @@ useMockIntersectionObserver();
jest.mock('~/lib/utils/poll');
-const setupHTML = initialData => {
+const setupHTML = (initialData) => {
document.body.innerHTML = `<div id="js-issuable-app"></div>`;
document.getElementById('js-issuable-app').dataset.initial = JSON.stringify(initialData);
};