diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-05 00:09:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-05 00:09:06 +0300 |
commit | f4726e9f5029931fc74aee9d5eff93d6a762dcff (patch) | |
tree | bc6d47ea3d39afdf46c5df3d8328f3f266c38ae5 /spec/frontend/alerts_settings/components | |
parent | 7c221ba5ce130ca50b892e6dd32783e1327718df (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/alerts_settings/components')
3 files changed, 38 insertions, 20 deletions
diff --git a/spec/frontend/alerts_settings/components/__snapshots__/alerts_settings_form_spec.js.snap b/spec/frontend/alerts_settings/components/__snapshots__/alerts_settings_form_spec.js.snap index 66e3f180d92..eb2b82a0211 100644 --- a/spec/frontend/alerts_settings/components/__snapshots__/alerts_settings_form_spec.js.snap +++ b/spec/frontend/alerts_settings/components/__snapshots__/alerts_settings_form_spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AlertsSettingsFormNew with default values renders the initial template 1`] = ` +exports[`AlertsSettingsForm with default values renders the initial template 1`] = ` <form class="gl-mt-6" > diff --git a/spec/frontend/alerts_settings/components/alert_mapping_builder_spec.js b/spec/frontend/alerts_settings/components/alert_mapping_builder_spec.js index 92ea8b2f33c..1ec7b5c18f6 100644 --- a/spec/frontend/alerts_settings/components/alert_mapping_builder_spec.js +++ b/spec/frontend/alerts_settings/components/alert_mapping_builder_spec.js @@ -1,10 +1,10 @@ import { GlIcon, GlFormInput, GlDropdown, GlSearchBoxByType, GlDropdownItem } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import AlertMappingBuilder, { i18n } from '~/alerts_settings/components/alert_mapping_builder.vue'; -import gitlabFields from '~/alerts_settings/components/mocks/gitlabFields.json'; import parsedMapping from '~/alerts_settings/components/mocks/parsedMapping.json'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import * as transformationUtils from '~/alerts_settings/utils/mapping_transformations'; +import alertFields from '../mocks/alertFields.json'; describe('AlertMappingBuilder', () => { let wrapper; @@ -14,6 +14,7 @@ describe('AlertMappingBuilder', () => { propsData: { parsedPayload: parsedMapping.samplePayload.payloadAlerFields.nodes, savedMapping: parsedMapping.storedMapping.nodes, + alertFields, }, }); } @@ -44,28 +45,28 @@ describe('AlertMappingBuilder', () => { }); it('renders disabled form input for each mapped field', () => { - gitlabFields.forEach((field, index) => { + alertFields.forEach((field, index) => { const input = findColumnInRow(index + 1, 0).find(GlFormInput); - const types = field.type.map((t) => capitalizeFirstCharacter(t.toLowerCase())).join(' or '); + const types = field.types.map((t) => capitalizeFirstCharacter(t.toLowerCase())).join(' or '); expect(input.attributes('value')).toBe(`${field.label} (${types})`); expect(input.attributes('disabled')).toBe(''); }); }); it('renders right arrow next to each input', () => { - gitlabFields.forEach((field, index) => { + alertFields.forEach((field, index) => { const arrow = findColumnInRow(index + 1, 1).find('.right-arrow'); expect(arrow.exists()).toBe(true); }); }); it('renders mapping dropdown for each field', () => { - gitlabFields.forEach(({ compatibleTypes }, index) => { + alertFields.forEach(({ types }, index) => { const dropdown = findColumnInRow(index + 1, 2).find(GlDropdown); const searchBox = dropdown.findComponent(GlSearchBoxByType); const dropdownItems = dropdown.findAllComponents(GlDropdownItem); const { nodes } = parsedMapping.samplePayload.payloadAlerFields; - const mappingOptions = nodes.filter(({ type }) => compatibleTypes.includes(type)); + const mappingOptions = nodes.filter(({ type }) => types.includes(type)); expect(dropdown.exists()).toBe(true); expect(searchBox.exists()).toBe(true); @@ -74,7 +75,7 @@ describe('AlertMappingBuilder', () => { }); it('renders fallback dropdown only for the fields that have fallback', () => { - gitlabFields.forEach(({ compatibleTypes, numberOfFallbacks }, index) => { + alertFields.forEach(({ types, numberOfFallbacks }, index) => { const dropdown = findColumnInRow(index + 1, 3).find(GlDropdown); expect(dropdown.exists()).toBe(Boolean(numberOfFallbacks)); @@ -82,7 +83,7 @@ describe('AlertMappingBuilder', () => { const searchBox = dropdown.findComponent(GlSearchBoxByType); const dropdownItems = dropdown.findAllComponents(GlDropdownItem); const { nodes } = parsedMapping.samplePayload.payloadAlerFields; - const mappingOptions = nodes.filter(({ type }) => compatibleTypes.includes(type)); + const mappingOptions = nodes.filter(({ type }) => types.includes(type)); expect(searchBox.exists()).toBe(Boolean(numberOfFallbacks)); expect(dropdownItems).toHaveLength(mappingOptions.length); diff --git a/spec/frontend/alerts_settings/components/alerts_settings_form_spec.js b/spec/frontend/alerts_settings/components/alerts_settings_form_spec.js index 2afa714fcf8..b43c1318a86 100644 --- a/spec/frontend/alerts_settings/components/alerts_settings_form_spec.js +++ b/spec/frontend/alerts_settings/components/alerts_settings_form_spec.js @@ -11,9 +11,10 @@ import waitForPromises from 'helpers/wait_for_promises'; import AlertsSettingsForm from '~/alerts_settings/components/alerts_settings_form.vue'; import MappingBuilder from '~/alerts_settings/components/alert_mapping_builder.vue'; import { typeSet } from '~/alerts_settings/constants'; +import alertFields from '../mocks/alertFields.json'; import { defaultAlertSettingsConfig } from './util'; -describe('AlertsSettingsFormNew', () => { +describe('AlertsSettingsForm', () => { let wrapper; const mockToastShow = jest.fn(); @@ -21,6 +22,7 @@ describe('AlertsSettingsFormNew', () => { data = {}, props = {}, multipleHttpIntegrationsCustomMapping = false, + multiIntegrations = true, } = {}) => { wrapper = mount(AlertsSettingsForm, { data() { @@ -32,8 +34,9 @@ describe('AlertsSettingsFormNew', () => { ...props, }, provide: { - glFeatures: { multipleHttpIntegrationsCustomMapping }, ...defaultAlertSettingsConfig, + glFeatures: { multipleHttpIntegrationsCustomMapping }, + multiIntegrations, }, mocks: { $toast: { @@ -132,7 +135,11 @@ describe('AlertsSettingsFormNew', () => { }); it('create with custom mapping', async () => { - createComponent({ multipleHttpIntegrationsCustomMapping: true }); + createComponent({ + multipleHttpIntegrationsCustomMapping: true, + multiIntegrations: true, + props: { alertFields }, + }); const integrationName = 'Test integration'; await selectOptionAtIndex(1); @@ -275,6 +282,7 @@ describe('AlertsSettingsFormNew', () => { currentIntegration: { type: typeSet.http, }, + alertFields, }, }); }); @@ -347,18 +355,27 @@ describe('AlertsSettingsFormNew', () => { describe('Mapping builder section', () => { describe.each` - featureFlag | integrationOption | visible - ${true} | ${1} | ${true} - ${true} | ${2} | ${false} - ${false} | ${1} | ${false} - ${false} | ${2} | ${false} - `('', ({ featureFlag, integrationOption, visible }) => { + 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 }) => { 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}`, async () => { - createComponent({ multipleHttpIntegrationsCustomMapping: featureFlag }); + it(`${visibleMsg} when multipleHttpIntegrationsCustomMapping feature flag ${featureFlagMsg} and integration type is ${integrationType} and alert fields ${alertFieldsMsg}`, async () => { + createComponent({ + multipleHttpIntegrationsCustomMapping: featureFlag, + multiIntegrations, + props: { + alertFields: alertFieldsProvided ? alertFields : [], + }, + }); await selectOptionAtIndex(integrationOption); expect(findMappingBuilderSection().exists()).toBe(visible); |