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
e012b4a8
Commit
e012b4a8
authored
Jun 22, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $emit call with single arg in ProtectedBranchesSelector
See
https://gitlab.com/groups/gitlab-org/-/epics/3334
parent
0a36b1ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
14 deletions
+38
-14
ee/app/assets/javascripts/status_checks/components/form.vue
ee/app/assets/javascripts/status_checks/components/form.vue
+1
-1
ee/app/assets/javascripts/vue_shared/components/branches_selector/protected_branches_selector.vue
...ponents/branches_selector/protected_branches_selector.vue
+2
-2
ee/spec/frontend/status_checks/components/form_spec.js
ee/spec/frontend/status_checks/components/form_spec.js
+21
-6
ee/spec/frontend/vue_shared/components/branches_selector/protected_branches_selector_spec.js
...nts/branches_selector/protected_branches_selector_spec.js
+14
-5
No files found.
ee/app/assets/javascripts/status_checks/components/form.vue
View file @
e012b4a8
...
...
@@ -105,7 +105,7 @@ export default {
this
.
$emit
(
'
submit
'
,
{
branches
,
name
,
url
});
}
},
setBranchApiError
(
hasErrored
,
error
)
{
setBranchApiError
(
{
hasErrored
,
error
}
)
{
if
(
!
this
.
branchesApiFailed
&&
error
)
{
Sentry
.
captureException
(
error
);
}
...
...
ee/app/assets/javascripts/vue_shared/components/branches_selector/protected_branches_selector.vue
View file @
e012b4a8
...
...
@@ -52,11 +52,11 @@ export default {
return
Api
.
projectProtectedBranches
(
this
.
projectId
,
term
)
.
then
((
branches
)
=>
{
this
.
$emit
(
'
apiError
'
,
false
);
this
.
$emit
(
'
apiError
'
,
{
hasErrored
:
false
}
);
this
.
branches
=
excludeAnyBranch
?
branches
:
[
ANY_BRANCH
,
...
branches
];
})
.
catch
((
error
)
=>
{
this
.
$emit
(
'
apiError
'
,
true
,
error
);
this
.
$emit
(
'
apiError
'
,
{
hasErrored
:
true
,
error
}
);
this
.
branches
=
excludeAnyBranch
?
[]
:
[
ANY_BRANCH
];
})
.
finally
(()
=>
{
...
...
ee/spec/frontend/status_checks/components/form_spec.js
View file @
e012b4a8
...
...
@@ -152,7 +152,10 @@ describe('Status checks form', () => {
});
it
(
'
sends the error to sentry
'
,
()
=>
{
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
true
,
sentryError
);
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
{
hasErrored
:
true
,
error
:
sentryError
,
});
expect
(
Sentry
.
captureException
.
mock
.
calls
[
0
][
0
]).
toStrictEqual
(
sentryError
);
});
...
...
@@ -160,22 +163,34 @@ describe('Status checks form', () => {
it
(
'
shows the alert
'
,
async
()
=>
{
expect
(
findBranchesErrorAlert
().
exists
()).
toBe
(
false
);
await
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
true
,
sentryError
);
await
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
{
hasErrored
:
true
,
error
:
sentryError
,
});
expect
(
findBranchesErrorAlert
().
exists
()).
toBe
(
true
);
});
it
(
'
hides the alert if the apiError is reset
'
,
async
()
=>
{
await
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
true
,
sentryError
);
await
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
{
hasErrored
:
true
,
error
:
sentryError
,
});
expect
(
findBranchesErrorAlert
().
exists
()).
toBe
(
true
);
await
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
false
);
await
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
{
hasErrored
:
false
}
);
expect
(
findBranchesErrorAlert
().
exists
()).
toBe
(
false
);
});
it
(
'
only calls sentry once while the branches api is failing
'
,
()
=>
{
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
true
,
sentryError
);
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
true
,
sentryError
);
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
{
hasErrored
:
true
,
error
:
sentryError
,
});
findProtectedBranchesSelector
().
vm
.
$emit
(
'
apiError
'
,
{
hasErrored
:
true
,
error
:
sentryError
,
});
expect
(
Sentry
.
captureException
.
mock
.
calls
).
toEqual
([[
sentryError
]]);
});
...
...
ee/spec/frontend/vue_shared/components/branches_selector/protected_branches_selector_spec.js
View file @
e012b4a8
...
...
@@ -82,7 +82,7 @@ describe('Protected Branches Selector', () => {
expect
(
findDropdown
().
props
(
'
loading
'
)).
toBe
(
true
);
await
waitForPromises
();
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
false
]]);
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
{
hasErrored
:
false
}
]]);
expect
(
findDropdownItems
()).
toHaveLength
(
branchNames
().
length
);
expect
(
findDropdown
().
props
(
'
loading
'
)).
toBe
(
false
);
});
...
...
@@ -94,7 +94,7 @@ describe('Protected Branches Selector', () => {
});
it
(
'
emits the `apiError` event
'
,
()
=>
{
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
true
,
error
]]);
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
{
hasErrored
:
true
,
error
}
]]);
});
it
(
'
returns just the any branch dropdown items
'
,
()
=>
{
...
...
@@ -119,7 +119,10 @@ describe('Protected Branches Selector', () => {
await
waitForPromises
();
expect
(
Api
.
projectProtectedBranches
).
toHaveBeenCalledWith
(
TEST_PROJECT_ID
,
term
);
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
false
],
[
false
]]);
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([
[{
hasErrored
:
false
}],
[{
hasErrored
:
false
}],
]);
expect
(
findSearch
().
props
(
'
isLoading
'
)).
toBe
(
false
);
});
...
...
@@ -146,7 +149,10 @@ describe('Protected Branches Selector', () => {
});
it
(
'
emits the `apiError` event
'
,
()
=>
{
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
false
],
[
true
,
error
]]);
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([
[{
hasErrored
:
false
}],
[{
hasErrored
:
true
,
error
}],
]);
});
it
(
'
returns no dropdown items
'
,
()
=>
{
...
...
@@ -163,7 +169,10 @@ describe('Protected Branches Selector', () => {
});
it
(
'
emits the `apiError` event
'
,
()
=>
{
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([[
false
],
[
true
,
error
]]);
expect
(
wrapper
.
emitted
(
'
apiError
'
)).
toStrictEqual
([
[{
hasErrored
:
false
}],
[{
hasErrored
:
true
,
error
}],
]);
});
it
(
'
returns just the any branch dropdown item
'
,
()
=>
{
...
...
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