Commit a9697e60 authored by Clement Ho's avatar Clement Ho

Merge branch '218045-remove-create-issue-feature-flag-FE' into 'master'

Remove create issue feature flag

See merge request gitlab-org/gitlab!33213
parents 9d6ae6d6 cda08103
...@@ -14,7 +14,6 @@ import { s__ } from '~/locale'; ...@@ -14,7 +14,6 @@ import { s__ } from '~/locale';
import query from '../graphql/queries/details.query.graphql'; import query from '../graphql/queries/details.query.graphql';
import { fetchPolicies } from '~/lib/graphql'; import { fetchPolicies } from '~/lib/graphql';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { ALERTS_SEVERITY_LABELS, trackAlertsDetailsViewsOptions } from '../constants'; import { ALERTS_SEVERITY_LABELS, trackAlertsDetailsViewsOptions } from '../constants';
import createIssueQuery from '../graphql/mutations/create_issue_from_alert.graphql'; import createIssueQuery from '../graphql/mutations/create_issue_from_alert.graphql';
import { visitUrl, joinPaths } from '~/lib/utils/url_utility'; import { visitUrl, joinPaths } from '~/lib/utils/url_utility';
...@@ -47,7 +46,6 @@ export default { ...@@ -47,7 +46,6 @@ export default {
TimeAgoTooltip, TimeAgoTooltip,
AlertSidebar, AlertSidebar,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
alertId: { alertId: {
type: String, type: String,
...@@ -204,29 +202,27 @@ export default { ...@@ -204,29 +202,27 @@ export default {
<template #tool>{{ alert.monitoringTool }}</template> <template #tool>{{ alert.monitoringTool }}</template>
</gl-sprintf> </gl-sprintf>
</div> </div>
<div v-if="glFeatures.alertManagementCreateAlertIssue"> <gl-button
<gl-button v-if="alert.issueIid"
v-if="alert.issueIid" class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-issue-button"
class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-issue-button" data-testid="viewIssueBtn"
data-testid="viewIssueBtn" :href="issuePath(alert.issueIid)"
:href="issuePath(alert.issueIid)" category="primary"
category="primary" variant="success"
variant="success" >
> {{ s__('AlertManagement|View issue') }}
{{ s__('AlertManagement|View issue') }} </gl-button>
</gl-button> <gl-button
<gl-button v-else
v-else class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-issue-button"
class="gl-mt-3 mt-sm-0 align-self-center align-self-sm-baseline alert-details-issue-button" data-testid="createIssueBtn"
data-testid="createIssueBtn" :loading="issueCreationInProgress"
:loading="issueCreationInProgress" category="primary"
category="primary" variant="success"
variant="success" @click="createIssue()"
@click="createIssue()" >
> {{ s__('AlertManagement|Create issue') }}
{{ s__('AlertManagement|Create issue') }} </gl-button>
</gl-button>
</div>
<gl-button <gl-button
:aria-label="__('Toggle sidebar')" :aria-label="__('Toggle sidebar')"
category="primary" category="primary"
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
class Projects::AlertManagementController < Projects::ApplicationController class Projects::AlertManagementController < Projects::ApplicationController
before_action :authorize_read_alert_management_alert! before_action :authorize_read_alert_management_alert!
before_action do before_action do
push_frontend_feature_flag(:alert_management_create_alert_issue, project)
push_frontend_feature_flag(:alert_assignee, project) push_frontend_feature_flag(:alert_assignee, project)
end end
......
---
title: Create issue from alert
merge_request: 33213
author:
type: added
...@@ -17,13 +17,7 @@ describe('AlertDetails', () => { ...@@ -17,13 +17,7 @@ describe('AlertDetails', () => {
const findDetailsTable = () => wrapper.find(GlTable); const findDetailsTable = () => wrapper.find(GlTable);
function mountComponent({ function mountComponent({ data, loading = false, mountMethod = shallowMount, stubs = {} } = {}) {
data,
alertManagementCreateAlertIssue = false,
loading = false,
mountMethod = shallowMount,
stubs = {},
} = {}) {
wrapper = mountMethod(AlertDetails, { wrapper = mountMethod(AlertDetails, {
propsData: { propsData: {
alertId: 'alertId', alertId: 'alertId',
...@@ -33,9 +27,6 @@ describe('AlertDetails', () => { ...@@ -33,9 +27,6 @@ describe('AlertDetails', () => {
data() { data() {
return { alert: { ...mockAlert }, ...data }; return { alert: { ...mockAlert }, ...data };
}, },
provide: {
glFeatures: { alertManagementCreateAlertIssue },
},
mocks: { mocks: {
$apollo: { $apollo: {
mutate: jest.fn(), mutate: jest.fn(),
...@@ -123,69 +114,54 @@ describe('AlertDetails', () => { ...@@ -123,69 +114,54 @@ describe('AlertDetails', () => {
}); });
describe('Create issue from alert', () => { describe('Create issue from alert', () => {
describe('createIssueFromAlertEnabled feature flag enabled', () => { it('should display "View issue" button that links the issue page when issue exists', () => {
it('should display "View issue" button that links the issue page when issue exists', () => { const issueIid = '3';
const issueIid = '3'; mountComponent({
mountComponent({ data: { alert: { ...mockAlert, issueIid } },
alertManagementCreateAlertIssue: true,
data: { alert: { ...mockAlert, issueIid } },
});
expect(findViewIssueBtn().exists()).toBe(true);
expect(findViewIssueBtn().attributes('href')).toBe(
joinPaths(projectIssuesPath, issueIid),
);
expect(findCreateIssueBtn().exists()).toBe(false);
}); });
expect(findViewIssueBtn().exists()).toBe(true);
expect(findViewIssueBtn().attributes('href')).toBe(joinPaths(projectIssuesPath, issueIid));
expect(findCreateIssueBtn().exists()).toBe(false);
});
it('should display "Create issue" button when issue doesn\'t exist yet', () => { it('should display "Create issue" button when issue doesn\'t exist yet', () => {
const issueIid = null; const issueIid = null;
mountComponent({ mountComponent({
mountMethod: mount, mountMethod: mount,
alertManagementCreateAlertIssue: true, data: { alert: { ...mockAlert, issueIid } },
data: { alert: { ...mockAlert, issueIid } },
});
expect(findViewIssueBtn().exists()).toBe(false);
expect(findCreateIssueBtn().exists()).toBe(true);
}); });
expect(findViewIssueBtn().exists()).toBe(false);
it('calls `$apollo.mutate` with `createIssueQuery`', () => { expect(findCreateIssueBtn().exists()).toBe(true);
const issueIid = '10'; });
jest
.spyOn(wrapper.vm.$apollo, 'mutate') it('calls `$apollo.mutate` with `createIssueQuery`', () => {
.mockResolvedValue({ data: { createAlertIssue: { issue: { iid: issueIid } } } }); const issueIid = '10';
jest
findCreateIssueBtn().trigger('click'); .spyOn(wrapper.vm.$apollo, 'mutate')
expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({ .mockResolvedValue({ data: { createAlertIssue: { issue: { iid: issueIid } } } });
mutation: createIssueQuery,
variables: { findCreateIssueBtn().trigger('click');
iid: mockAlert.iid, expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
projectPath, mutation: createIssueQuery,
}, variables: {
}); iid: mockAlert.iid,
projectPath,
},
}); });
});
it('shows error alert when issue creation fails ', () => { it('shows error alert when issue creation fails ', () => {
const errorMsg = 'Something went wrong'; const errorMsg = 'Something went wrong';
mountComponent({ mountComponent({
mountMethod: mount, mountMethod: mount,
alertManagementCreateAlertIssue: true, data: { alert: { ...mockAlert, alertIid: 1 } },
data: { alert: { ...mockAlert, alertIid: 1 } },
});
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockRejectedValue(errorMsg);
findCreateIssueBtn().trigger('click');
setImmediate(() => {
expect(findIssueCreationAlert().text()).toBe(errorMsg);
});
}); });
});
describe('createIssueFromAlertEnabled feature flag disabled', () => { jest.spyOn(wrapper.vm.$apollo, 'mutate').mockRejectedValue(errorMsg);
it('should not display a View or Create issue button', () => { findCreateIssueBtn().trigger('click');
mountComponent({ alertManagementCreateAlertIssue: false });
expect(findCreateIssueBtn().exists()).toBe(false); setImmediate(() => {
expect(findViewIssueBtn().exists()).toBe(false); expect(findIssueCreationAlert().text()).toBe(errorMsg);
}); });
}); });
}); });
......
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