diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-12 15:09:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-12 15:09:47 +0300 |
commit | ef7cfec30c9fab7b9e757877c472ca7ca2eccc2d (patch) | |
tree | f69647e6f64c16fad044d564db65cb51c7a0b63f /spec/frontend | |
parent | 0e1a6f6a2b28464e6ad151da4dced6d603bd11b0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
5 files changed, 68 insertions, 20 deletions
diff --git a/spec/frontend/alert_management/components/alert_management_detail_spec.js b/spec/frontend/alert_management/components/alert_management_detail_spec.js index 55ac62eccdf..fa32707ead5 100644 --- a/spec/frontend/alert_management/components/alert_management_detail_spec.js +++ b/spec/frontend/alert_management/components/alert_management_detail_spec.js @@ -1,11 +1,16 @@ import { shallowMount } from '@vue/test-utils'; +import { GlLoadingIcon } from '@gitlab/ui'; import AlertDetails from '~/alert_management/components/alert_details.vue'; describe('AlertDetails', () => { let wrapper; const newIssuePath = 'root/alerts/-/issues/new'; - function mountComponent(alert = {}, createIssueFromAlertEnabled = false) { + function mountComponent({ + alert = {}, + createIssueFromAlertEnabled = false, + loading = false, + } = {}) { wrapper = shallowMount(AlertDetails, { propsData: { alertId: 'alertId', @@ -18,6 +23,15 @@ describe('AlertDetails', () => { provide: { glFeatures: { createIssueFromAlertEnabled }, }, + mocks: { + $apollo: { + queries: { + alert: { + loading, + }, + }, + }, + }, }); } @@ -32,17 +46,11 @@ describe('AlertDetails', () => { describe('Alert details', () => { describe('when alert is null', () => { beforeEach(() => { - mountComponent(null); + mountComponent({ alert: null }); }); - describe('when alert is null', () => { - beforeEach(() => { - mountComponent(null); - }); - - it('shows an empty state', () => { - expect(wrapper.find('[data-testid="alertDetailsTabs"]').exists()).toBe(false); - }); + it('shows an empty state', () => { + expect(wrapper.find('[data-testid="alertDetailsTabs"]').exists()).toBe(false); }); }); @@ -71,7 +79,7 @@ describe('AlertDetails', () => { describe('Create issue from alert', () => { describe('createIssueFromAlertEnabled feature flag enabled', () => { it('should display a button that links to new issue page', () => { - mountComponent({}, true); + mountComponent({ createIssueFromAlertEnabled: true }); expect(findCreatedIssueBtn().exists()).toBe(true); expect(findCreatedIssueBtn().attributes('href')).toBe(newIssuePath); }); @@ -79,10 +87,20 @@ describe('AlertDetails', () => { describe('createIssueFromAlertEnabled feature flag disabled', () => { it('should display a button that links to a new issue page', () => { - mountComponent({}, false); + mountComponent({ createIssueFromAlertEnabled: false }); expect(findCreatedIssueBtn().exists()).toBe(false); }); }); }); + + describe('loading state', () => { + beforeEach(() => { + mountComponent({ loading: true }); + }); + + it('displays a loading state when loading', () => { + expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); + }); + }); }); }); diff --git a/spec/frontend/alert_management/components/alert_management_list_spec.js b/spec/frontend/alert_management/components/alert_management_list_spec.js index d7170e71a96..81d966a42b5 100644 --- a/spec/frontend/alert_management/components/alert_management_list_spec.js +++ b/spec/frontend/alert_management/components/alert_management_list_spec.js @@ -26,6 +26,7 @@ describe('AlertManagementList', () => { const findStatusFilterTabs = () => wrapper.findAll(GlTab); const findNumberOfAlertsBadge = () => wrapper.findAll(GlBadge); const findDateFields = () => wrapper.findAll(TimeAgo); + const findSeverityFields = () => wrapper.findAll('[data-testid="severityField"]'); function mountComponent({ props = { @@ -201,6 +202,20 @@ describe('AlertManagementList', () => { }); }); + it('Internationalizes severity text', () => { + mountComponent({ + props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, + data: { alerts: mockAlerts, errored: false }, + loading: false, + }); + + expect( + findSeverityFields() + .at(0) + .text(), + ).toBe('Critical'); + }); + describe('handle date fields', () => { it('should display time ago dates when values provided', () => { mountComponent({ diff --git a/spec/frontend/alert_management/mocks/alerts.json b/spec/frontend/alert_management/mocks/alerts.json index d4667eb21f8..e0b8fa55507 100644 --- a/spec/frontend/alert_management/mocks/alerts.json +++ b/spec/frontend/alert_management/mocks/alerts.json @@ -2,7 +2,7 @@ { "iid": "1527542", "title": "SyntaxError: Invalid or unexpected token", - "severity": "Critical", + "severity": "CRITICAL", "eventCount": 7, "startedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z", @@ -11,7 +11,7 @@ { "iid": "1527542", "title": "Some otherr alert Some otherr alert Some otherr alert Some otherr alert Some otherr alert Some otherr alert", - "severity": "Medium", + "severity": "MEDIUM", "eventCount": 1, "startedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z", @@ -20,7 +20,7 @@ { "iid": "1527542", "title": "SyntaxError: Invalid or unexpected token", - "severity": "Low", + "severity": "LOW", "eventCount": 4, "startedAt": "2020-04-17T23:18:14.996Z", "endedAt": "2020-04-17T23:18:14.996Z", diff --git a/spec/frontend/diffs/components/edit_button_spec.js b/spec/frontend/diffs/components/edit_button_spec.js index f9a1d4a84a8..71512c1c4af 100644 --- a/spec/frontend/diffs/components/edit_button_spec.js +++ b/spec/frontend/diffs/components/edit_button_spec.js @@ -1,4 +1,5 @@ import { shallowMount } from '@vue/test-utils'; +import { GlDeprecatedButton } from '@gitlab/ui'; import EditButton from '~/diffs/components/edit_button.vue'; const editPath = 'test-path'; @@ -22,7 +23,7 @@ describe('EditButton', () => { canCurrentUserFork: false, }); - expect(wrapper.attributes('href')).toBe(editPath); + expect(wrapper.find(GlDeprecatedButton).attributes('href')).toBe(editPath); }); it('emits a show fork message event if current user can fork', () => { @@ -30,7 +31,7 @@ describe('EditButton', () => { editPath, canCurrentUserFork: true, }); - wrapper.trigger('click'); + wrapper.find(GlDeprecatedButton).trigger('click'); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted('showForkMessage')).toBeTruthy(); @@ -42,7 +43,7 @@ describe('EditButton', () => { editPath, canCurrentUserFork: false, }); - wrapper.trigger('click'); + wrapper.find(GlDeprecatedButton).trigger('click'); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted('showForkMessage')).toBeFalsy(); @@ -55,10 +56,20 @@ describe('EditButton', () => { canCurrentUserFork: true, canModifyBlob: true, }); - wrapper.trigger('click'); + wrapper.find(GlDeprecatedButton).trigger('click'); return wrapper.vm.$nextTick().then(() => { expect(wrapper.emitted('showForkMessage')).toBeFalsy(); }); }); + + it('disables button if editPath is empty', () => { + createComponent({ + editPath: '', + canCurrentUserFork: true, + canModifyBlob: true, + }); + + expect(wrapper.find(GlDeprecatedButton).attributes('disabled')).toBe('true'); + }); }); diff --git a/spec/frontend/monitoring/store/actions_spec.js b/spec/frontend/monitoring/store/actions_spec.js index d9794c34b3b..901b698b703 100644 --- a/spec/frontend/monitoring/store/actions_spec.js +++ b/spec/frontend/monitoring/store/actions_spec.js @@ -97,7 +97,11 @@ describe('Monitoring store actions', () => { null, state, [], - [{ type: 'fetchEnvironmentsData' }, { type: 'fetchDashboard' }], + [ + { type: 'fetchEnvironmentsData' }, + { type: 'fetchDashboard' }, + { type: 'fetchAnnotations' }, + ], ); }); |