Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
0f9144fc
Commit
0f9144fc
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
Handling corner case where consent date is not set
parent
ab1f9986
No related branches found
No related tags found
1 merge request
!307
GREG-243: Adding possibility to set date in consent endpoint. Showing ID for...
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/src/interfaces/index.ts
+1
-1
1 addition, 1 deletion
frontend/src/interfaces/index.ts
frontend/src/routes/landing/index.test.tsx
+107
-0
107 additions, 0 deletions
frontend/src/routes/landing/index.test.tsx
frontend/src/utils/index.ts
+3
-1
3 additions, 1 deletion
frontend/src/utils/index.ts
with
111 additions
and
2 deletions
frontend/src/interfaces/index.ts
+
1
−
1
View file @
0f9144fc
...
...
@@ -92,7 +92,7 @@ export type Consent = {
id
:
string
type
:
ConsentType
choice
:
ConsentChoice
consent_given_at
:
Date
consent_given_at
:
Date
|
null
}
export
interface
User
{
...
...
This diff is collapsed.
Click to expand it.
frontend/src/routes/landing/index.test.tsx
0 → 100644
+
107
−
0
View file @
0f9144fc
import
{
LocalizationProvider
}
from
'
@mui/lab
'
import
AdapterDateFns
from
'
@mui/lab/AdapterDateFns
'
import
React
from
'
react
'
import
_
from
'
lodash
'
import
GuestPage
from
'
./index
'
import
{
UserContext
}
from
'
../../contexts
'
import
{
render
,
screen
,
waitFor
}
from
'
../../test-utils
'
const
userData
=
{
user
:
{
auth
:
true
,
auth_type
:
'
oidc
'
,
fetched
:
true
,
first_name
:
'
Frank Foreleser
'
,
last_name
:
'
Føllesen
'
,
feide_id
:
'
frank_foreleser@spusers.feide.no
'
,
person_id
:
'
20622
'
,
sponsor_id
:
''
,
email
:
'
frank@example.org
'
,
mobile_phone
:
''
,
fnr
:
'
190663*****
'
,
passport
:
''
,
roles
:
[
{
id
:
'
20319
'
,
ou_nb
:
'
Det humanistiske fakultet, sekretariatet
'
,
ou_en
:
'
The Faculty of Humanities, faculty administration
'
,
name_nb
:
'
Konsulent
'
,
name_en
:
'
Consultant
'
,
start_date
:
'
2022-03-24
'
,
end_date
:
'
2022-03-31
'
,
max_days
:
100
,
contact_person_at_unit
:
'
None
'
,
comments
:
'
Test
'
,
},
],
consents
:
[
{
id
:
'
8656
'
,
type
:
{
name_en
:
'
Search
'
,
name_nb
:
'
Søk
'
,
name_nn
:
'
Søk
'
},
choice
:
{
text_en
:
'
Yes
'
,
text_nb
:
'
Yes
'
,
text_nn
:
'
Yes
'
},
consent_given_at
:
'
2022-03-24
'
,
},
],
registration_completed_date
:
'
2022-03-23T23:00:00.000Z
'
,
},
fetchUserInfo
:
()
=>
{},
clearUserInfo
:
()
=>
{},
getUserInfo
:
()
=>
{},
}
test
(
'
Guest values showing
'
,
async
()
=>
{
render
(
// @ts-ignore
<
UserContext
.
Provider
value
=
{
userData
}
>
<
LocalizationProvider
dateAdapter
=
{
AdapterDateFns
}
>
<
GuestPage
/>
</
LocalizationProvider
>
</
UserContext
.
Provider
>
)
await
waitFor
(
()
=>
{
screen
.
findByDisplayValue
(
`
${
userData
.
user
.
first_name
}
${
userData
.
user
.
last_name
}
`
)
screen
.
findByDisplayValue
(
userData
.
user
.
feide_id
)
screen
.
findByDisplayValue
(
userData
.
user
.
email
)
screen
.
findByDisplayValue
(
userData
.
user
.
mobile_phone
)
screen
.
findByDisplayValue
(
userData
.
user
.
roles
[
0
].
name_en
)
screen
.
findByDisplayValue
(
userData
.
user
.
roles
[
0
].
ou_en
)
screen
.
findByDisplayValue
(
`
${
userData
.
user
.
roles
[
0
].
start_date
}
-
${
userData
.
user
.
roles
[
0
].
end_date
}
`
)
screen
.
findByDisplayValue
(
userData
.
user
.
consents
[
0
].
type
.
name_en
)
screen
.
findByDisplayValue
(
userData
.
user
.
consents
[
0
].
choice
.
text_en
)
screen
.
findByDisplayValue
(
userData
.
user
.
consents
[
0
].
consent_given_at
)
},
{
timeout
:
5000
}
)
})
test
(
'
Guest values showing when consent date is not set
'
,
async
()
=>
{
const
userDataCopy
=
_
.
cloneDeep
(
userData
)
// @ts-ignore
userDataCopy
.
user
.
consents
[
0
].
consent_given_at
=
null
render
(
// @ts-ignore
<
UserContext
.
Provider
value
=
{
userData
}
>
<
LocalizationProvider
dateAdapter
=
{
AdapterDateFns
}
>
<
GuestPage
/>
</
LocalizationProvider
>
</
UserContext
.
Provider
>
)
// Just check that the page is showing
await
waitFor
(
()
=>
{
screen
.
findByDisplayValue
(
`
${
userData
.
user
.
first_name
}
${
userData
.
user
.
last_name
}
`
)
},
{
timeout
:
5000
}
)
})
This diff is collapsed.
Click to expand it.
frontend/src/utils/index.ts
+
3
−
1
View file @
0f9144fc
...
...
@@ -158,7 +158,9 @@ export function parseConsent(cons: FetchedConsent): Consent {
id
:
cons
.
id
,
type
:
cons
.
type
,
choice
:
cons
.
choice
,
consent_given_at
:
parseISO
(
cons
.
consent_given_at
),
consent_given_at
:
cons
.
consent_given_at
?
parseISO
(
cons
.
consent_given_at
)
:
null
,
}
}
...
...
This diff is collapsed.
Click to expand it.
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