Commit 4fc571e0 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '273573-remove-multiple_http_integrations_custom_mapping-ff' into 'master'

Remove `multiple_http_integrations_custom_mapping` feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!56021
parents 20828283 138c6e1e
......@@ -16,7 +16,6 @@ import {
import * as Sentry from '@sentry/browser';
import { isEmpty, omit } from 'lodash';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import {
integrationTypes,
integrationSteps,
......@@ -60,7 +59,6 @@ export default {
directives: {
GlModal: GlModalDirective,
},
mixins: [glFeatureFlagsMixin()],
inject: {
generic: {
default: {},
......@@ -163,12 +161,7 @@ export default {
};
},
showMappingBuilder() {
return (
this.multiIntegrations &&
this.glFeatures.multipleHttpIntegrationsCustomMapping &&
this.isHttp &&
this.alertFields?.length
);
return this.multiIntegrations && this.isHttp && this.alertFields?.length;
},
hasSamplePayload() {
return this.isValidNonEmptyJSON(this.currentIntegration?.payloadExample);
......@@ -234,12 +227,10 @@ export default {
},
submit() {
const { name, apiUrl } = this.integrationForm;
const customMappingVariables = this.glFeatures.multipleHttpIntegrationsCustomMapping
? {
const customMappingVariables = {
payloadAttributeMappings: this.mapping,
payloadExample: this.samplePayload.json || '{}',
}
: {};
};
const variables =
this.selectedIntegration === typeSet.http
......
......@@ -63,10 +63,7 @@ export default (el) => {
render(createElement) {
return createElement('alert-settings-wrapper', {
props: {
alertFields:
gon.features?.multipleHttpIntegrationsCustomMapping && parseBoolean(multiIntegrations)
? JSON.parse(alertFields)
: null,
alertFields: parseBoolean(multiIntegrations) ? JSON.parse(alertFields) : null,
},
});
},
......
......@@ -6,10 +6,6 @@ module Projects
before_action :authorize_admin_operations!
before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token]
before_action do
push_frontend_feature_flag(:multiple_http_integrations_custom_mapping, @project)
end
respond_to :json, only: [:reset_alerting_token, :reset_pagerduty_token]
helper_method :error_tracking_setting
......
---
name: multiple_http_integrations_custom_mapping
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46437
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/273573
milestone: '13.6'
type: development
group: group::monitor
default_enabled: false
---
title: Custom mapping for HTTP endpoints
merge_request: 56021
author:
type: added
......@@ -3,7 +3,6 @@
module Gitlab
module AlertManagement
def self.custom_mapping_available?(project)
::Feature.enabled?(:multiple_http_integrations_custom_mapping, project) &&
project.feature_available?(:multiple_alert_http_integrations)
end
......
......@@ -85,11 +85,6 @@ RSpec.describe OperationsHelper, :routing do
it { is_expected.to include('multi_integrations' => 'true') }
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: true)
end
it 'has the correct list of fields', :aggregate_failures do
fields = Gitlab::Json.parse(alerts_settings_data['alert_fields'])
......@@ -101,15 +96,6 @@ RSpec.describe OperationsHelper, :routing do
end
end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it { is_expected.not_to have_key('alert_fields') }
end
end
context 'when not available' do
let(:multi_integrations) { false }
......
......@@ -106,7 +106,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do
stub_licensed_features(multiple_alert_http_integrations: project)
end
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
let_it_be(:attribute_mapping) do
{
title: { path: %w(alert name), type: 'string' },
......@@ -124,10 +123,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do
let(:parsed_payload) { described_class.new(project: project, payload: raw_payload, integration: integration) }
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
context 'with defined custom mapping' do
let_it_be(:integration) do
create(:alert_management_http_integration, project: project, payload_attribute_mapping: attribute_mapping)
......@@ -271,15 +266,6 @@ RSpec.describe Gitlab::AlertManagement::Payload::Generic do
end
end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'parsing alert payload fields with default paths'
end
end
context 'with multiple HTTP integrations feature unavailable' do
before do
stub_licensed_features(multiple_alert_http_integrations: false)
......
......@@ -71,7 +71,6 @@ RSpec.describe 'Creating a new HTTP Integration' do
project.add_maintainer(current_user)
stub_licensed_features(multiple_alert_http_integrations: true)
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
it_behaves_like 'creating a new HTTP integration'
......@@ -108,14 +107,6 @@ RSpec.describe 'Creating a new HTTP Integration' do
it_behaves_like 'ignoring the custom mapping'
end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
it_behaves_like 'validating the payload_example'
it_behaves_like 'validating the payload_attribute_mappings'
end
......@@ -61,7 +61,6 @@ RSpec.describe 'Updating an existing HTTP Integration' do
project.add_maintainer(current_user)
stub_licensed_features(multiple_alert_http_integrations: true)
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
it_behaves_like 'updating an existing HTTP integration'
......@@ -75,12 +74,4 @@ RSpec.describe 'Updating an existing HTTP Integration' do
it_behaves_like 'ignoring the custom mapping'
end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
end
......@@ -57,7 +57,6 @@ RSpec.describe 'getting Alert Management HTTP Integrations' do
before do
stub_licensed_features(multiple_alert_http_integrations: true)
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
before_all do
......
......@@ -47,7 +47,6 @@ RSpec.describe 'parse alert payload fields' do
before do
stub_licensed_features(multiple_alert_http_integrations: license)
stub_feature_flags(multiple_http_integrations_custom_mapping: feature_flag)
post_graphql(query, current_user: current_user)
end
......@@ -94,10 +93,4 @@ RSpec.describe 'parse alert payload fields' do
it_behaves_like 'query with error', 'Failed to parse payload'
end
context 'without feature flag' do
let(:feature_flag) { false }
it_behaves_like 'query with error', 'Feature not available'
end
end
......@@ -22,11 +22,6 @@ RSpec.describe AlertManagement::ExtractAlertPayloadFieldsService do
stub_licensed_features(multiple_alert_http_integrations: true)
end
context 'with feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
context 'with permissions' do
before do
project.add_maintainer(user_with_permissions)
......@@ -83,16 +78,4 @@ RSpec.describe AlertManagement::ExtractAlertPayloadFieldsService do
end
end
end
context 'with feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it 'returns feature not available error' do
is_expected.to be_error
expect(response.message).to eq('Feature not available')
end
end
end
end
......@@ -68,11 +68,6 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService do
end
end
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
it 'successfully creates a new integration with the custom mappings' do
expect(response).to be_success
......@@ -83,14 +78,5 @@ RSpec.describe AlertManagement::HttpIntegrations::CreateService do
expect(integration.payload_attribute_mapping).to eq(payload_attribute_mapping)
end
end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
end
end
end
......@@ -36,17 +36,6 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do
end
describe '#execute' do
shared_examples 'ignoring the custom mapping' do
it 'creates integration without the custom mapping params' do
expect(response).to be_success
integration = response.payload[:integration]
expect(integration).to be_a(::AlertManagement::HttpIntegration)
expect(integration.payload_example).to eq({})
expect(integration.payload_attribute_mapping).to eq({})
end
end
subject(:response) { service.execute }
context 'with multiple HTTP integrations feature available' do
......@@ -54,11 +43,6 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do
stub_licensed_features(multiple_alert_http_integrations: true)
end
context 'with multiple_http_integrations_custom_mapping feature flag enabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: project)
end
it 'successfully creates a new integration with the custom mappings' do
expect(response).to be_success
......@@ -69,16 +53,5 @@ RSpec.describe AlertManagement::HttpIntegrations::UpdateService do
expect(integration.payload_attribute_mapping).to eq(payload_attribute_mapping)
end
end
context 'with multiple_http_integrations_custom_mapping feature flag disabled' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
end
it_behaves_like 'ignoring the custom mapping'
end
end
it_behaves_like 'ignoring the custom mapping'
end
end
......@@ -19,7 +19,6 @@ RSpec.describe 'Alert integrations settings form', :js do
describe 'when viewing alert integrations as a maintainer' do
context 'with the default page permissions' do
before do
stub_feature_flags(multiple_http_integrations_custom_mapping: false)
visit project_settings_operations_path(project, anchor: 'js-alert-management-settings')
wait_for_requests
end
......
......@@ -12,12 +12,7 @@ describe('AlertsSettingsForm', () => {
let wrapper;
const mockToastShow = jest.fn();
const createComponent = ({
data = {},
props = {},
multipleHttpIntegrationsCustomMapping = false,
multiIntegrations = true,
} = {}) => {
const createComponent = ({ data = {}, props = {}, multiIntegrations = true } = {}) => {
wrapper = mount(AlertsSettingsForm, {
data() {
return { ...data };
......@@ -29,7 +24,6 @@ describe('AlertsSettingsForm', () => {
},
provide: {
...defaultAlertSettingsConfig,
glFeatures: { multipleHttpIntegrationsCustomMapping },
multiIntegrations,
},
mocks: {
......@@ -142,27 +136,8 @@ describe('AlertsSettingsForm', () => {
describe('submitting integration form', () => {
describe('HTTP', () => {
it('create', async () => {
createComponent();
const integrationName = 'Test integration';
await selectOptionAtIndex(1);
enableIntegration(0, integrationName);
const submitBtn = findSubmitButton();
expect(submitBtn.exists()).toBe(true);
expect(submitBtn.text()).toBe('Save integration');
findForm().trigger('submit');
expect(wrapper.emitted('create-new-integration')[0]).toEqual([
{ type: typeSet.http, variables: { name: integrationName, active: true } },
]);
});
it('create with custom mapping', async () => {
createComponent({
multipleHttpIntegrationsCustomMapping: true,
multiIntegrations: true,
props: { alertFields },
});
......@@ -208,9 +183,19 @@ describe('AlertsSettingsForm', () => {
findForm().trigger('submit');
expect(wrapper.emitted('update-integration')[0]).toEqual([
{ type: typeSet.http, variables: { name: updatedIntegrationName, active: true } },
]);
expect(wrapper.emitted('update-integration')[0]).toEqual(
expect.arrayContaining([
{
type: typeSet.http,
variables: {
name: updatedIntegrationName,
active: true,
payloadAttributeMappings: [],
payloadExample: '{}',
},
},
]),
);
});
});
......@@ -301,7 +286,6 @@ describe('AlertsSettingsForm', () => {
beforeEach(() => {
createComponent({
multipleHttpIntegrationsCustomMapping: true,
data: {
currentIntegration: {
type: typeSet.http,
......@@ -408,22 +392,18 @@ describe('AlertsSettingsForm', () => {
describe('Mapping builder section', () => {
describe.each`
alertFieldsProvided | multiIntegrations | featureFlag | integrationOption | visible
${true} | ${true} | ${true} | ${1} | ${true}
${true} | ${true} | ${true} | ${2} | ${false}
${true} | ${true} | ${false} | ${1} | ${false}
${true} | ${true} | ${false} | ${2} | ${false}
${true} | ${false} | ${true} | ${1} | ${false}
${false} | ${true} | ${true} | ${1} | ${false}
`('', ({ alertFieldsProvided, multiIntegrations, featureFlag, integrationOption, visible }) => {
alertFieldsProvided | multiIntegrations | integrationOption | visible
${true} | ${true} | ${1} | ${true}
${true} | ${true} | ${2} | ${false}
${true} | ${false} | ${1} | ${false}
${false} | ${true} | ${1} | ${false}
`('', ({ alertFieldsProvided, multiIntegrations, integrationOption, visible }) => {
const visibleMsg = visible ? 'is rendered' : 'is not rendered';
const featureFlagMsg = featureFlag ? 'is enabled' : 'is disabled';
const alertFieldsMsg = alertFieldsProvided ? 'are provided' : 'are not provided';
const integrationType = integrationOption === 1 ? typeSet.http : typeSet.prometheus;
it(`${visibleMsg} when multipleHttpIntegrationsCustomMapping feature flag ${featureFlagMsg} and integration type is ${integrationType} and alert fields ${alertFieldsMsg}`, async () => {
it(`${visibleMsg} when integration type is ${integrationType} and alert fields ${alertFieldsMsg}`, async () => {
createComponent({
multipleHttpIntegrationsCustomMapping: featureFlag,
multiIntegrations,
props: {
alertFields: alertFieldsProvided ? alertFields : [],
......
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