diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-12 00:10:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-12 00:10:21 +0300 |
commit | 0ae8428c8e77d5d7e098827be688b1f146321af1 (patch) | |
tree | cfc80aac796be0dd42ce32a1bd79c8327071993d /spec/frontend/pipeline_new | |
parent | f020d5dc9bf42fe27b1451af34e7ab3a0c38d344 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipeline_new')
-rw-r--r-- | spec/frontend/pipeline_new/components/pipeline_new_form_spec.js | 37 | ||||
-rw-r--r-- | spec/frontend/pipeline_new/mock_data.js | 6 |
2 files changed, 42 insertions, 1 deletions
diff --git a/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js b/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js index dc70db42b4a..2a3f4f56f36 100644 --- a/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js +++ b/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js @@ -1,13 +1,22 @@ import { GlForm, GlSprintf, GlLoadingIcon } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; +import CreditCardValidationRequiredAlert from 'ee_component/billings/components/cc_validation_required_alert.vue'; +import { TEST_HOST } from 'helpers/test_constants'; import waitForPromises from 'helpers/wait_for_promises'; import axios from '~/lib/utils/axios_utils'; import httpStatusCodes from '~/lib/utils/http_status'; import { redirectTo } from '~/lib/utils/url_utility'; import PipelineNewForm from '~/pipeline_new/components/pipeline_new_form.vue'; import RefsDropdown from '~/pipeline_new/components/refs_dropdown.vue'; -import { mockQueryParams, mockPostParams, mockProjectId, mockError, mockRefs } from '../mock_data'; +import { + mockQueryParams, + mockPostParams, + mockProjectId, + mockError, + mockRefs, + mockCreditCardValidationRequiredError, +} from '../mock_data'; jest.mock('~/lib/utils/url_utility', () => ({ redirectTo: jest.fn(), @@ -376,6 +385,32 @@ describe('Pipeline New Form', () => { it('re-enables the submit button', () => { expect(findSubmitButton().props('disabled')).toBe(false); }); + + it('does not show the credit card validation required alert', () => { + expect(wrapper.findComponent(CreditCardValidationRequiredAlert).exists()).toBe(false); + }); + + describe('when the error response is credit card validation required', () => { + beforeEach(async () => { + mock + .onPost(pipelinesPath) + .reply(httpStatusCodes.BAD_REQUEST, mockCreditCardValidationRequiredError); + + window.gon = { + subscriptions_url: TEST_HOST, + payment_form_url: TEST_HOST, + }; + + findForm().vm.$emit('submit', dummySubmitEvent); + + await waitForPromises(); + }); + + it('shows credit card validation required alert', () => { + expect(findErrorAlert().exists()).toBe(false); + expect(wrapper.findComponent(CreditCardValidationRequiredAlert).exists()).toBe(true); + }); + }); }); describe('when the error response cannot be handled', () => { diff --git a/spec/frontend/pipeline_new/mock_data.js b/spec/frontend/pipeline_new/mock_data.js index 3174b73098a..e99684ff417 100644 --- a/spec/frontend/pipeline_new/mock_data.js +++ b/spec/frontend/pipeline_new/mock_data.js @@ -40,6 +40,12 @@ export const mockError = { total_warnings: 7, }; +export const mockCreditCardValidationRequiredError = { + errors: ['Credit card required to be on file in order to create a pipeline'], + warnings: [], + total_warnings: 0, +}; + export const mockBranchRefs = ['main', 'dev', 'release']; export const mockTagRefs = ['1.0.0', '1.1.0', '1.2.0']; |