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
7ecc4b66
Commit
7ecc4b66
authored
Mar 24, 2022
by
Paul Gascou-Vaillancourt
Committed by
Paul Gascou-Vaillancourt
Mar 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leverage logError helper
parent
5b09c084
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
+10
-14
ee/app/assets/javascripts/arkose_labs/components/sign_in_arkose_app.vue
...javascripts/arkose_labs/components/sign_in_arkose_app.vue
+2
-2
ee/spec/frontend/arkose_labs/components/sign_in_arkose_app_spec.js
...rontend/arkose_labs/components/sign_in_arkose_app_spec.js
+8
-12
No files found.
ee/app/assets/javascripts/arkose_labs/components/sign_in_arkose_app.vue
View file @
7ecc4b66
...
...
@@ -2,6 +2,7 @@
import
{
uniqueId
}
from
'
lodash
'
;
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
needsArkoseLabsChallenge
}
from
'
ee/rest_api
'
;
import
{
logError
}
from
'
~/lib/logger
'
;
import
{
loadingIconForLegacyJS
}
from
'
~/loading_icon_for_legacy_js
'
;
import
{
__
}
from
'
~/locale
'
;
import
DomElementListener
from
'
~/vue_shared/components/dom_element_listener.vue
'
;
...
...
@@ -144,8 +145,7 @@ export default {
this
.
hideErrors
();
},
handleArkoseLabsFailure
(
e
)
{
// eslint-disable-next-line no-console
console
.
error
(
'
ArkoseLabs initialization error
'
,
e
);
logError
(
'
ArkoseLabs initialization error
'
,
e
);
this
.
showArkoseFailure
=
true
;
},
updateSubmitButtonLoading
(
val
)
{
...
...
ee/spec/frontend/arkose_labs/components/sign_in_arkose_app_spec.js
View file @
7ecc4b66
...
...
@@ -3,9 +3,11 @@ import AxiosMockAdapter from 'axios-mock-adapter';
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
SignInArkoseApp
from
'
ee/arkose_labs/components/sign_in_arkose_app.vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
logError
}
from
'
~/lib/logger
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
initArkoseLabsScript
}
from
'
ee/arkose_labs/init_arkose_labs_script
'
;
jest
.
mock
(
'
~/lib/logger
'
);
// ArkoseLabs enforcement mocks
jest
.
mock
(
'
ee/arkose_labs/init_arkose_labs_script
'
);
let
onShown
;
...
...
@@ -20,6 +22,7 @@ initArkoseLabsScript.mockImplementation(() => ({
}));
const
MOCK_USERNAME
=
'
cassiopeia
'
;
const
MOCK_PUBLIC_KEY
=
'
arkose-labs-public-api-key
'
;
describe
(
'
SignInArkoseApp
'
,
()
=>
{
let
wrapper
;
...
...
@@ -44,7 +47,7 @@ describe('SignInArkoseApp', () => {
createForm
(
username
);
wrapper
=
mountExtended
(
SignInArkoseApp
,
{
propsData
:
{
publicKey
:
'
arkose-labs-public-api-key
'
,
publicKey
:
MOCK_PUBLIC_KEY
,
formSelector
:
makeTestIdSelector
(
'
sign-in-form
'
),
usernameSelector
:
makeTestIdSelector
(
'
username-field
'
),
submitSelector
:
makeTestIdSelector
(
'
sign-in-button
'
),
...
...
@@ -64,7 +67,7 @@ describe('SignInArkoseApp', () => {
// Assertions
const
itInitializesArkoseLabs
=
()
=>
{
it
(
"
includes ArkoseLabs' script
"
,
()
=>
{
expect
(
initArkoseLabsScript
).
toHaveBeenCalled
(
);
expect
(
initArkoseLabsScript
).
toHaveBeenCalled
With
({
publicKey
:
MOCK_PUBLIC_KEY
}
);
});
it
(
'
creates a hidden input for the verification token
'
,
()
=>
{
...
...
@@ -86,6 +89,7 @@ describe('SignInArkoseApp', () => {
});
afterEach
(()
=>
{
axiosMock
.
restore
();
wrapper
?.
destroy
();
});
...
...
@@ -173,15 +177,12 @@ describe('SignInArkoseApp', () => {
});
it
(
'
shows an error alert if the challenge fails to load
'
,
async
()
=>
{
jest
.
spyOn
(
console
,
'
error
'
).
mockImplementation
(()
=>
{});
expect
(
wrapper
.
text
()).
not
.
toContain
(
wrapper
.
vm
.
$options
.
MSG_ARKOSE_FAILURE_BODY
);
const
error
=
new
Error
();
onError
(
error
);
// eslint-disable-next-line no-console
expect
(
console
.
error
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
expect
(
logError
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
await
nextTick
();
...
...
@@ -215,10 +216,6 @@ describe('SignInArkoseApp', () => {
});
describe
(
'
when the username check fails
'
,
()
=>
{
beforeEach
(
async
()
=>
{
jest
.
spyOn
(
console
,
'
error
'
).
mockImplementation
(()
=>
{});
});
it
(
'
with a 404, nothing happens
'
,
async
()
=>
{
axiosMock
.
onGet
().
reply
(
404
);
initArkoseLabs
(
MOCK_USERNAME
);
...
...
@@ -247,8 +244,7 @@ describe('SignInArkoseApp', () => {
await
waitForPromises
();
expectArkoseLabsInitError
();
// eslint-disable-next-line no-console
expect
(
console
.
error
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
expect
(
logError
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
});
});
});
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