diff options
Diffstat (limited to 'spec/frontend/pipeline_new/components/pipeline_new_form_spec.js')
-rw-r--r-- | spec/frontend/pipeline_new/components/pipeline_new_form_spec.js | 17 |
1 files changed, 15 insertions, 2 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 2a3f4f56f36..9e2bf1bd367 100644 --- a/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js +++ b/spec/frontend/pipeline_new/components/pipeline_new_form_spec.js @@ -45,6 +45,7 @@ describe('Pipeline New Form', () => { const findWarningAlertSummary = () => findWarningAlert().find(GlSprintf); const findWarnings = () => wrapper.findAll('[data-testid="run-pipeline-warning"]'); const findLoadingIcon = () => wrapper.find(GlLoadingIcon); + const findCCAlert = () => wrapper.findComponent(CreditCardValidationRequiredAlert); const getFormPostParams = () => JSON.parse(mock.history.post[0].data); const selectBranch = (branch) => { @@ -387,7 +388,7 @@ describe('Pipeline New Form', () => { }); it('does not show the credit card validation required alert', () => { - expect(wrapper.findComponent(CreditCardValidationRequiredAlert).exists()).toBe(false); + expect(findCCAlert().exists()).toBe(false); }); describe('when the error response is credit card validation required', () => { @@ -408,7 +409,19 @@ describe('Pipeline New Form', () => { it('shows credit card validation required alert', () => { expect(findErrorAlert().exists()).toBe(false); - expect(wrapper.findComponent(CreditCardValidationRequiredAlert).exists()).toBe(true); + expect(findCCAlert().exists()).toBe(true); + }); + + it('clears error and hides the alert on dismiss', async () => { + expect(findCCAlert().exists()).toBe(true); + expect(wrapper.vm.$data.error).toBe(mockCreditCardValidationRequiredError.errors[0]); + + findCCAlert().vm.$emit('dismiss'); + + await wrapper.vm.$nextTick(); + + expect(findCCAlert().exists()).toBe(false); + expect(wrapper.vm.$data.error).toBe(null); }); }); }); |