Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UI
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
frontend
apps
UI
Commits
2c75dbc1
Commit
2c75dbc1
authored
2 years ago
by
Petar Hristov
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Added ORCID button and logout tests
parent
d3d5f3ea
No related branches found
No related tags found
2 merge requests
!211
Fix: Fields loading when info still not present
,
!210
Fix: Properly logging out the user on ORCID merge action
Pipeline
#938742
passed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/login/store.spec.ts
+51
-0
51 additions, 0 deletions
src/modules/login/store.spec.ts
src/modules/user/pages/UserProfile.spec.ts
+33
-0
33 additions, 0 deletions
src/modules/user/pages/UserProfile.spec.ts
with
84 additions
and
0 deletions
src/modules/login/store.spec.ts
0 → 100644
+
51
−
0
View file @
2c75dbc1
// stores/counter.spec.ts
import
{
setActivePinia
,
createPinia
}
from
"
pinia
"
;
import
useLoginStore
from
"
./store
"
;
describe
(
"
Login Store
"
,
()
=>
{
beforeEach
(()
=>
{
// creates a fresh pinia and make it active so it's automatically picked
// up by any useStore() call without having to pass it to it:
// `useStore(pinia)`
setActivePinia
(
createPinia
());
});
test
(
"
logout
"
,
()
=>
{
const
loginStore
=
useLoginStore
();
/* Make window.location.href writable for the logout method */
Object
.
defineProperty
(
window
,
"
location
"
,
{
value
:
{
href
:
"
/
"
,
},
writable
:
true
,
// possibility to override
});
/* Fill the local storage */
localStorage
.
setItem
(
"
coscine.clientcorrelation.id
"
,
"
f7aef8bc-77f4-4679-9f5d-5724fbdf4513
"
);
localStorage
.
setItem
(
"
coscine.authorization.bearer
"
,
"
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
"
);
localStorage
.
setItem
(
"
coscine.locale
"
,
"
en
"
);
localStorage
.
setItem
(
"
coscine.banner.maintenanceVisibility
"
,
""
);
localStorage
.
setItem
(
"
coscine.banner.pilotVisibility
"
,
"
false
"
);
localStorage
.
setItem
(
"
coscine.login.storedData
"
,
""
);
localStorage
.
setItem
(
"
coscine.sidebar.active
"
,
"
true
"
);
localStorage
.
setItem
(
"
coscine.banner.dateString
"
,
""
);
expect
(
localStorage
.
length
).
toBe
(
8
);
loginStore
.
logout
();
/* Check if prerequisites for logout are fulfilled */
expect
(
localStorage
.
length
).
toBeLessThan
(
8
);
expect
(
localStorage
.
getItem
(
"
coscine.authorization.bearer
"
)).
toBeNull
();
expect
(
sessionStorage
.
length
).
toBe
(
0
);
expect
(
window
.
location
.
href
).
toBe
(
"
/coscine/api/Coscine.Api.STS/account/logout
"
);
});
});
This diff is collapsed.
Click to expand it.
src/modules/user/pages/UserProfile.spec.ts
+
33
−
0
View file @
2c75dbc1
...
...
@@ -25,6 +25,7 @@ import {
}
from
"
@/data/mockup/testUser
"
;
import
useUserStore
from
"
@/modules/user/store
"
;
import
type
Vue
from
"
vue
"
;
import
useLoginStore
from
"
@/modules/login/store
"
;
/* Create a local Vue instance */
const
localVue
=
createLocalVue
();
...
...
@@ -152,4 +153,36 @@ describe("UserProfile.vue", () => {
"
disabled
"
);
});
/* Checks for correct ORCID connect button behavior */
test
(
"
orcidConnection
"
,
async
()
=>
{
testUserState
.
userProfile
.
userMemberships
=
[
testOrganization
,
testInstitute
,
];
/* Assign the test pinia store to a variable to use later */
const
testingPinia
=
createTestingPinia
({
createSpy
:
vitest
.
fn
,
initialState
:
{
user
:
testUserState
,
},
});
const
wrapper
=
mount
(
UserProfile
as
unknown
as
typeof
Vue
,
{
pinia
:
testingPinia
,
i18n
,
localVue
,
});
// Identify the ORCID button
const
orcidConnectButton
=
wrapper
.
find
(
'
button[name="orcidConnect"]
'
);
expect
(
(
orcidConnectButton
.
element
as
HTMLButtonElement
).
disabled
).
toBeFalsy
();
await
orcidConnectButton
.
trigger
(
"
click.prevent
"
);
await
wrapper
.
vm
.
$nextTick
();
const
loginStore
=
useLoginStore
(
testingPinia
);
expect
(
loginStore
.
logout
).
toHaveBeenCalledOnce
();
});
});
This diff is collapsed.
Click to expand it.
CoscineBot
@CoscineBot
mentioned in commit
8dd8b63b
·
2 years ago
mentioned in commit
8dd8b63b
mentioned in commit 8dd8b63bdcebdbd1517009ed964b545fddc2e8dd
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment