Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
aaa16315
Commit
aaa16315
authored
Dec 13, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address maintainer feedback
- add spec for test settings error state - capture non-user errors in Sentry
parent
b2755055
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
app/assets/javascripts/integrations/edit/components/integration_form.vue
...scripts/integrations/edit/components/integration_form.vue
+6
-3
spec/frontend/integrations/edit/components/integration_form_spec.js
...end/integrations/edit/components/integration_form_spec.js
+14
-6
No files found.
app/assets/javascripts/integrations/edit/components/integration_form.vue
View file @
aaa16315
<
script
>
import
{
GlButton
,
GlModalDirective
,
GlSafeHtmlDirective
as
SafeHtml
}
from
'
@gitlab/ui
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
mapState
,
mapActions
,
mapGetters
}
from
'
vuex
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
{
...
...
@@ -114,13 +115,15 @@ export default {
.
then
(({
data
:
{
error
,
message
=
I18N_FETCH_TEST_SETTINGS_DEFAULT_ERROR_MESSAGE
}
})
=>
{
if
(
error
)
{
eventHub
.
$emit
(
VALIDATE_INTEGRATION_FORM_EVENT
);
throw
new
Error
(
message
);
this
.
$toast
.
show
(
message
);
return
;
}
this
.
$toast
.
show
(
I18N_SUCCESSFUL_CONNECTION_MESSAGE
);
})
.
catch
(({
message
=
I18N_DEFAULT_ERROR_MESSAGE
})
=>
{
this
.
$toast
.
show
(
message
);
.
catch
((
error
)
=>
{
this
.
$toast
.
show
(
I18N_DEFAULT_ERROR_MESSAGE
);
Sentry
.
captureException
(
error
);
})
.
finally
(()
=>
{
this
.
testingLoading
=
false
;
...
...
spec/frontend/integrations/edit/components/integration_form_spec.js
View file @
aaa16315
import
axios
from
'
axios
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
setHTMLFixture
}
from
'
helpers/fixtures
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
mockIntegrationProps
}
from
'
jest/integrations/edit/mock_data
'
;
...
...
@@ -18,12 +19,14 @@ import {
I18N_SUCCESSFUL_CONNECTION_MESSAGE
,
VALIDATE_INTEGRATION_FORM_EVENT
,
SAVE_INTEGRATION_EVENT
,
I18N_DEFAULT_ERROR_MESSAGE
,
}
from
'
~/integrations/constants
'
;
import
{
createStore
}
from
'
~/integrations/edit/store
'
;
import
eventHub
from
'
~/integrations/edit/event_hub
'
;
import
httpStatus
from
'
~/lib/utils/http_status
'
;
jest
.
mock
(
'
~/integrations/edit/event_hub
'
);
jest
.
mock
(
'
@sentry/browser
'
);
describe
(
'
IntegrationForm
'
,
()
=>
{
const
mockToastShow
=
jest
.
fn
();
...
...
@@ -469,13 +472,14 @@ describe('IntegrationForm', () => {
});
describe
.
each
`
scenario | errorMessage | expectToast
${
'
when test settings succeeds
'
}
|
${
'
an error
'
}
|
${
'
an error
'
}
${
'
when test settings fails
'
}
|
${
undefined
}
|
${
I18N_SUCCESSFUL_CONNECTION_MESSAGE
}
`
(
'
$scenario
'
,
({
errorMessage
,
expectToast
})
=>
{
scenario | replyStatus | errorMessage | expectToast | expectSentry
${
'
when "test settings" request fails
'
}
|
${
httpStatus
.
INTERNAL_SERVER_ERROR
}
|
${
undefined
}
|
${
I18N_DEFAULT_ERROR_MESSAGE
}
|
${
true
}
${
'
when "test settings" returns an error
'
}
|
${
httpStatus
.
OK
}
|
${
'
an error
'
}
|
${
'
an error
'
}
|
${
false
}
${
'
when "test settings" succeeds
'
}
|
${
httpStatus
.
OK
}
|
${
undefined
}
|
${
I18N_SUCCESSFUL_CONNECTION_MESSAGE
}
|
${
false
}
`
(
'
$scenario
'
,
({
replyStatus
,
errorMessage
,
expectToast
,
expectSentry
})
=>
{
beforeEach
(
async
()
=>
{
mockAxios
.
onPut
(
mockTestPath
).
replyOnce
(
httpStatus
.
OK
,
{
error
:
Boolean
(
errorMessage
)
||
undefined
,
mockAxios
.
onPut
(
mockTestPath
).
replyOnce
(
replyStatus
,
{
error
:
Boolean
(
errorMessage
),
message
:
errorMessage
,
});
...
...
@@ -494,6 +498,10 @@ describe('IntegrationForm', () => {
it
(
'
sets save button `disabled` prop to `false`
'
,
()
=>
{
expect
(
findSaveButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
});
it
(
`
${
expectSentry
?
'
does
'
:
'
does not
'
}
capture exception in Sentry`
,
()
=>
{
expect
(
Sentry
.
captureException
).
toHaveBeenCalledTimes
(
expectSentry
?
1
:
0
);
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment