diff options
Diffstat (limited to 'spec/frontend/runner/components/runner_update_form_spec.js')
-rw-r--r-- | spec/frontend/runner/components/runner_update_form_spec.js | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/spec/frontend/runner/components/runner_update_form_spec.js b/spec/frontend/runner/components/runner_update_form_spec.js index 6333ed7118a..15029d7a911 100644 --- a/spec/frontend/runner/components/runner_update_form_spec.js +++ b/spec/frontend/runner/components/runner_update_form_spec.js @@ -15,9 +15,11 @@ import { ACCESS_LEVEL_NOT_PROTECTED, } from '~/runner/constants'; import runnerUpdateMutation from '~/runner/graphql/runner_update.mutation.graphql'; +import { captureException } from '~/runner/sentry_utils'; import { runnerData } from '../mock_data'; jest.mock('~/flash'); +jest.mock('~/runner/sentry_utils'); const mockRunner = runnerData.data.runner; @@ -205,13 +207,11 @@ describe('RunnerUpdateForm', () => { }); it.each` - value | submitted - ${''} | ${{ tagList: [] }} - ${'tag1, tag2'} | ${{ tagList: ['tag1', 'tag2'] }} - ${'with spaces'} | ${{ tagList: ['with spaces'] }} - ${',,,,, commas'} | ${{ tagList: ['commas'] }} - ${'more ,,,,, commas'} | ${{ tagList: ['more', 'commas'] }} - ${' trimmed , trimmed2 '} | ${{ tagList: ['trimmed', 'trimmed2'] }} + value | submitted + ${''} | ${{ tagList: [] }} + ${'tag1, tag2'} | ${{ tagList: ['tag1', 'tag2'] }} + ${'with spaces'} | ${{ tagList: ['with spaces'] }} + ${'more ,,,,, commas'} | ${{ tagList: ['more', 'commas'] }} `('Field updates runner\'s tags for "$value"', async ({ value, submitted }) => { const runner = { ...mockRunner, tagList: ['tag1'] }; createComponent({ props: { runner } }); @@ -232,22 +232,30 @@ describe('RunnerUpdateForm', () => { }); it('On network error, error message is shown', async () => { - runnerUpdateHandler.mockRejectedValue(new Error('Something went wrong')); + const mockErrorMsg = 'Update error!'; + + runnerUpdateHandler.mockRejectedValue(new Error(mockErrorMsg)); await submitFormAndWait(); expect(createFlash).toHaveBeenLastCalledWith({ - message: 'Network error: Something went wrong', + message: `Network error: ${mockErrorMsg}`, + }); + expect(captureException).toHaveBeenCalledWith({ + component: 'RunnerUpdateForm', + error: new Error(`Network error: ${mockErrorMsg}`), }); expect(findSubmitDisabledAttr()).toBeUndefined(); }); - it('On validation error, error message is shown', async () => { + it('On validation error, error message is shown and it is not sent to sentry', async () => { + const mockErrorMsg = 'Invalid value!'; + runnerUpdateHandler.mockResolvedValue({ data: { runnerUpdate: { runner: mockRunner, - errors: ['A value is invalid'], + errors: [mockErrorMsg], }, }, }); @@ -255,8 +263,9 @@ describe('RunnerUpdateForm', () => { await submitFormAndWait(); expect(createFlash).toHaveBeenLastCalledWith({ - message: 'A value is invalid', + message: mockErrorMsg, }); + expect(captureException).not.toHaveBeenCalled(); expect(findSubmitDisabledAttr()).toBeUndefined(); }); }); |