Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/alerts_service_settings/components')
-rw-r--r--spec/frontend/alerts_service_settings/components/__snapshots__/alerts_service_form_spec.js.snap9
-rw-r--r--spec/frontend/alerts_service_settings/components/alerts_service_form_spec.js152
2 files changed, 0 insertions, 161 deletions
diff --git a/spec/frontend/alerts_service_settings/components/__snapshots__/alerts_service_form_spec.js.snap b/spec/frontend/alerts_service_settings/components/__snapshots__/alerts_service_form_spec.js.snap
deleted file mode 100644
index 0d4171a20b3..00000000000
--- a/spec/frontend/alerts_service_settings/components/__snapshots__/alerts_service_form_spec.js.snap
+++ /dev/null
@@ -1,9 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AlertsServiceForm with default values renders "authorization-key" input 1`] = `"<gl-form-input-stub id=\\"authorization-key\\" readonly=\\"true\\" value=\\"abcedfg123\\"></gl-form-input-stub>"`;
-
-exports[`AlertsServiceForm with default values renders "url" input 1`] = `"<gl-form-input-stub id=\\"url\\" readonly=\\"true\\" value=\\"https://gitlab.com/endpoint-url\\"></gl-form-input-stub>"`;
-
-exports[`AlertsServiceForm with default values renders toggle button 1`] = `"<toggle-button-stub id=\\"activated\\"></toggle-button-stub>"`;
-
-exports[`AlertsServiceForm with default values shows description and docs links 1`] = `"<p><gl-sprintf-stub message=\\"You must provide this URL and authorization key to authorize an external service to send alerts to GitLab. You can provide this URL and key to multiple services. After configuring an external service, alerts from your service will display on the GitLab %{linkStart}Alerts%{linkEnd} page.\\"></gl-sprintf-stub></p><p><gl-sprintf-stub message=\\"Review your external service's documentation to learn where to provide this information to your external service, and the %{linkStart}GitLab documentation%{linkEnd} to learn more about configuring your endpoint.\\"></gl-sprintf-stub></p>"`;
diff --git a/spec/frontend/alerts_service_settings/components/alerts_service_form_spec.js b/spec/frontend/alerts_service_settings/components/alerts_service_form_spec.js
deleted file mode 100644
index 346059ed7be..00000000000
--- a/spec/frontend/alerts_service_settings/components/alerts_service_form_spec.js
+++ /dev/null
@@ -1,152 +0,0 @@
-import { nextTick } from 'vue';
-import axios from 'axios';
-import MockAdapter from 'axios-mock-adapter';
-import { shallowMount } from '@vue/test-utils';
-import { GlModal } from '@gitlab/ui';
-import AlertsServiceForm from '~/alerts_service_settings/components/alerts_service_form.vue';
-import ToggleButton from '~/vue_shared/components/toggle_button.vue';
-import { deprecatedCreateFlash as createFlash } from '~/flash';
-
-jest.mock('~/flash');
-
-const defaultProps = {
- initialAuthorizationKey: 'abcedfg123',
- formPath: 'http://invalid',
- url: 'https://gitlab.com/endpoint-url',
- alertsSetupUrl: 'http://invalid',
- alertsUsageUrl: 'http://invalid',
- initialActivated: false,
- isDisabled: false,
-};
-
-describe('AlertsServiceForm', () => {
- let wrapper;
- let mockAxios;
-
- const createComponent = (props = defaultProps) => {
- wrapper = shallowMount(AlertsServiceForm, {
- propsData: {
- ...defaultProps,
- ...props,
- },
- });
- };
-
- const findUrl = () => wrapper.find('#url');
- const findAuthorizationKey = () => wrapper.find('#authorization-key');
- const findDescription = () => wrapper.find('[data-testid="description"');
-
- beforeEach(() => {
- mockAxios = new MockAdapter(axios);
- });
-
- afterEach(() => {
- wrapper.destroy();
- mockAxios.restore();
- });
-
- describe('with default values', () => {
- beforeEach(() => {
- createComponent();
- });
-
- it('renders "url" input', () => {
- expect(findUrl().html()).toMatchSnapshot();
- });
-
- it('renders "authorization-key" input', () => {
- expect(findAuthorizationKey().html()).toMatchSnapshot();
- });
-
- it('renders toggle button', () => {
- expect(wrapper.find(ToggleButton).html()).toMatchSnapshot();
- });
-
- it('shows description and docs links', () => {
- expect(findDescription().element.innerHTML).toMatchSnapshot();
- });
- });
-
- describe('reset key', () => {
- it('updates the authorization key on success', async () => {
- const formPath = 'some/path';
- mockAxios.onPut(formPath).replyOnce(200, { token: 'newToken' });
-
- createComponent({ formPath });
-
- wrapper.find(GlModal).vm.$emit('ok');
- await axios.waitForAll();
-
- expect(findAuthorizationKey().attributes('value')).toBe('newToken');
- });
-
- it('shows flash message on error', () => {
- const formPath = 'some/path';
- mockAxios.onPut(formPath).replyOnce(404);
-
- createComponent({ formPath });
-
- return wrapper.vm.resetKey().then(() => {
- expect(findAuthorizationKey().attributes('value')).toBe(
- defaultProps.initialAuthorizationKey,
- );
- expect(createFlash).toHaveBeenCalled();
- });
- });
- });
-
- describe('activate toggle', () => {
- describe('successfully completes', () => {
- describe.each`
- initialActivated | value
- ${false} | ${true}
- ${true} | ${false}
- `(
- 'when initialActivated=$initialActivated and value=$value',
- ({ initialActivated, value }) => {
- beforeEach(() => {
- const formPath = 'some/path';
- mockAxios
- .onPut(formPath, { service: { active: value } })
- .replyOnce(200, { active: value });
- createComponent({ initialActivated, formPath });
-
- return wrapper.vm.toggleActivated(value);
- });
-
- it(`updates toggle button value to ${value}`, () => {
- expect(wrapper.find(ToggleButton).props('value')).toBe(value);
- });
- },
- );
- });
-
- describe('error is encountered', () => {
- beforeEach(() => {
- const formPath = 'some/path';
- mockAxios.onPut(formPath).replyOnce(500);
- });
-
- it('restores previous value', () => {
- createComponent({ initialActivated: false });
-
- return wrapper.vm.toggleActivated(true).then(() => {
- expect(wrapper.find(ToggleButton).props('value')).toBe(false);
- });
- });
- });
- });
-
- describe('form is disabled', () => {
- beforeEach(() => {
- createComponent({ isDisabled: true });
- });
-
- it('cannot be toggled', () => {
- wrapper.find(ToggleButton).vm.$emit('change');
- return nextTick().then(() => {
- expect(wrapper.find(ToggleButton).props('disabledInput')).toBe(true);
- });
- });
- });
-});