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
Hide 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 @@
...
@@ -2,6 +2,7 @@
import
{
uniqueId
}
from
'
lodash
'
;
import
{
uniqueId
}
from
'
lodash
'
;
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
needsArkoseLabsChallenge
}
from
'
ee/rest_api
'
;
import
{
needsArkoseLabsChallenge
}
from
'
ee/rest_api
'
;
import
{
logError
}
from
'
~/lib/logger
'
;
import
{
loadingIconForLegacyJS
}
from
'
~/loading_icon_for_legacy_js
'
;
import
{
loadingIconForLegacyJS
}
from
'
~/loading_icon_for_legacy_js
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
DomElementListener
from
'
~/vue_shared/components/dom_element_listener.vue
'
;
import
DomElementListener
from
'
~/vue_shared/components/dom_element_listener.vue
'
;
...
@@ -144,8 +145,7 @@ export default {
...
@@ -144,8 +145,7 @@ export default {
this
.
hideErrors
();
this
.
hideErrors
();
},
},
handleArkoseLabsFailure
(
e
)
{
handleArkoseLabsFailure
(
e
)
{
// eslint-disable-next-line no-console
logError
(
'
ArkoseLabs initialization error
'
,
e
);
console
.
error
(
'
ArkoseLabs initialization error
'
,
e
);
this
.
showArkoseFailure
=
true
;
this
.
showArkoseFailure
=
true
;
},
},
updateSubmitButtonLoading
(
val
)
{
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';
...
@@ -3,9 +3,11 @@ import AxiosMockAdapter from 'axios-mock-adapter';
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
SignInArkoseApp
from
'
ee/arkose_labs/components/sign_in_arkose_app.vue
'
;
import
SignInArkoseApp
from
'
ee/arkose_labs/components/sign_in_arkose_app.vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
logError
}
from
'
~/lib/logger
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
initArkoseLabsScript
}
from
'
ee/arkose_labs/init_arkose_labs_script
'
;
import
{
initArkoseLabsScript
}
from
'
ee/arkose_labs/init_arkose_labs_script
'
;
jest
.
mock
(
'
~/lib/logger
'
);
// ArkoseLabs enforcement mocks
// ArkoseLabs enforcement mocks
jest
.
mock
(
'
ee/arkose_labs/init_arkose_labs_script
'
);
jest
.
mock
(
'
ee/arkose_labs/init_arkose_labs_script
'
);
let
onShown
;
let
onShown
;
...
@@ -20,6 +22,7 @@ initArkoseLabsScript.mockImplementation(() => ({
...
@@ -20,6 +22,7 @@ initArkoseLabsScript.mockImplementation(() => ({
}));
}));
const
MOCK_USERNAME
=
'
cassiopeia
'
;
const
MOCK_USERNAME
=
'
cassiopeia
'
;
const
MOCK_PUBLIC_KEY
=
'
arkose-labs-public-api-key
'
;
describe
(
'
SignInArkoseApp
'
,
()
=>
{
describe
(
'
SignInArkoseApp
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
@@ -44,7 +47,7 @@ describe('SignInArkoseApp', () => {
...
@@ -44,7 +47,7 @@ describe('SignInArkoseApp', () => {
createForm
(
username
);
createForm
(
username
);
wrapper
=
mountExtended
(
SignInArkoseApp
,
{
wrapper
=
mountExtended
(
SignInArkoseApp
,
{
propsData
:
{
propsData
:
{
publicKey
:
'
arkose-labs-public-api-key
'
,
publicKey
:
MOCK_PUBLIC_KEY
,
formSelector
:
makeTestIdSelector
(
'
sign-in-form
'
),
formSelector
:
makeTestIdSelector
(
'
sign-in-form
'
),
usernameSelector
:
makeTestIdSelector
(
'
username-field
'
),
usernameSelector
:
makeTestIdSelector
(
'
username-field
'
),
submitSelector
:
makeTestIdSelector
(
'
sign-in-button
'
),
submitSelector
:
makeTestIdSelector
(
'
sign-in-button
'
),
...
@@ -64,7 +67,7 @@ describe('SignInArkoseApp', () => {
...
@@ -64,7 +67,7 @@ describe('SignInArkoseApp', () => {
// Assertions
// Assertions
const
itInitializesArkoseLabs
=
()
=>
{
const
itInitializesArkoseLabs
=
()
=>
{
it
(
"
includes ArkoseLabs' script
"
,
()
=>
{
it
(
"
includes ArkoseLabs' script
"
,
()
=>
{
expect
(
initArkoseLabsScript
).
toHaveBeenCalled
(
);
expect
(
initArkoseLabsScript
).
toHaveBeenCalled
With
({
publicKey
:
MOCK_PUBLIC_KEY
}
);
});
});
it
(
'
creates a hidden input for the verification token
'
,
()
=>
{
it
(
'
creates a hidden input for the verification token
'
,
()
=>
{
...
@@ -86,6 +89,7 @@ describe('SignInArkoseApp', () => {
...
@@ -86,6 +89,7 @@ describe('SignInArkoseApp', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
axiosMock
.
restore
();
wrapper
?.
destroy
();
wrapper
?.
destroy
();
});
});
...
@@ -173,15 +177,12 @@ describe('SignInArkoseApp', () => {
...
@@ -173,15 +177,12 @@ describe('SignInArkoseApp', () => {
});
});
it
(
'
shows an error alert if the challenge fails to load
'
,
async
()
=>
{
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
);
expect
(
wrapper
.
text
()).
not
.
toContain
(
wrapper
.
vm
.
$options
.
MSG_ARKOSE_FAILURE_BODY
);
const
error
=
new
Error
();
const
error
=
new
Error
();
onError
(
error
);
onError
(
error
);
// eslint-disable-next-line no-console
expect
(
logError
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
expect
(
console
.
error
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
await
nextTick
();
await
nextTick
();
...
@@ -215,10 +216,6 @@ describe('SignInArkoseApp', () => {
...
@@ -215,10 +216,6 @@ describe('SignInArkoseApp', () => {
});
});
describe
(
'
when the username check fails
'
,
()
=>
{
describe
(
'
when the username check fails
'
,
()
=>
{
beforeEach
(
async
()
=>
{
jest
.
spyOn
(
console
,
'
error
'
).
mockImplementation
(()
=>
{});
});
it
(
'
with a 404, nothing happens
'
,
async
()
=>
{
it
(
'
with a 404, nothing happens
'
,
async
()
=>
{
axiosMock
.
onGet
().
reply
(
404
);
axiosMock
.
onGet
().
reply
(
404
);
initArkoseLabs
(
MOCK_USERNAME
);
initArkoseLabs
(
MOCK_USERNAME
);
...
@@ -247,8 +244,7 @@ describe('SignInArkoseApp', () => {
...
@@ -247,8 +244,7 @@ describe('SignInArkoseApp', () => {
await
waitForPromises
();
await
waitForPromises
();
expectArkoseLabsInitError
();
expectArkoseLabsInitError
();
// eslint-disable-next-line no-console
expect
(
logError
).
toHaveBeenCalledWith
(
'
ArkoseLabs initialization error
'
,
error
);
expect
(
console
.
error
).
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