@@ -13,18 +13,15 @@ module('Unit | Component | users | user-overview', function (hooks) {
13
13
module ( '#externalURL' , function ( ) {
14
14
test ( 'it should generate dashboard URL based on environment and object' , async function ( assert ) {
15
15
// given
16
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
17
-
18
- const args = {
16
+ const baseUrl = 'https://metabase.pix.fr/dashboard/132?id=' ;
17
+ ENV . APP . USER_DASHBOARD_URL = baseUrl ;
18
+ const component = createGlimmerComponent ( 'component:users/user-overview' , {
19
19
user : {
20
20
id : 1 ,
21
+ authenticationMethods : [ ] ,
21
22
} ,
22
- } ;
23
- const baseUrl = 'https://metabase.pix.fr/dashboard/132?id=' ;
24
- const expectedUrl = baseUrl + args . user . id ;
25
-
26
- ENV . APP . USER_DASHBOARD_URL = baseUrl ;
27
- component . args = args ;
23
+ } ) ;
24
+ const expectedUrl = baseUrl + '1' ;
28
25
29
26
// when
30
27
const actualUrl = component . externalURL ;
@@ -38,9 +35,8 @@ module('Unit | Component | users | user-overview', function (hooks) {
38
35
module ( 'when user already has an email' , function ( ) {
39
36
test ( 'it should allow email modification' , async function ( assert ) {
40
37
// given
41
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
42
- const user = { email : 'lisa@example.net' , firstName : 'Lisa' , lastName : 'Dupont' } ;
43
- component . args . user = user ;
38
+ const user = { email : 'lisa@example.net' , firstName : 'Lisa' , lastName : 'Dupont' , authenticationMethods : [ ] } ;
39
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
44
40
45
41
// when & then
46
42
assert . true ( component . canModifyEmail ) ;
@@ -50,9 +46,8 @@ module('Unit | Component | users | user-overview', function (hooks) {
50
46
module ( 'when user has an username' , function ( ) {
51
47
test ( 'it should also allow email modification' , async function ( assert ) {
52
48
// given
53
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
54
- const user = { username : 'lisa.dupont' , firstName : 'Lisa' , lastName : 'Dupont' } ;
55
- component . args . user = user ;
49
+ const user = { username : 'lisa.dupont' , firstName : 'Lisa' , lastName : 'Dupont' , authenticationMethods : [ ] } ;
50
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
56
51
57
52
// when & then
58
53
assert . true ( component . canModifyEmail ) ;
@@ -62,9 +57,8 @@ module('Unit | Component | users | user-overview', function (hooks) {
62
57
module ( 'when user has neither a username nor an email' , function ( ) {
63
58
test ( 'it should not allow email modification' , async function ( assert ) {
64
59
// given
65
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
66
- const user = { firstName : 'Lisa' , lastName : 'Dupont' } ;
67
- component . args . user = user ;
60
+ const user = { firstName : 'Lisa' , lastName : 'Dupont' , authenticationMethods : [ ] } ;
61
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
68
62
69
63
// when & then
70
64
assert . false ( component . canModifyEmail ) ;
@@ -76,7 +70,8 @@ module('Unit | Component | users | user-overview', function (hooks) {
76
70
module ( 'when user has no login informations yet' , function ( ) {
77
71
test ( 'should not display temporary blocked date' , function ( assert ) {
78
72
// given
79
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
73
+ const user = { authenticationMethods : [ ] } ;
74
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
80
75
81
76
// when && then
82
77
assert . false ( component . shouldDisplayTemporaryBlockedDate ) ;
@@ -86,9 +81,8 @@ module('Unit | Component | users | user-overview', function (hooks) {
86
81
module ( 'when user has login but not temporary blocked' , function ( ) {
87
82
test ( 'should not display temporary blocked date' , function ( assert ) {
88
83
// given
89
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
90
- const user = { firstName : 'Lisa' , lastName : 'Dupont' } ;
91
- component . args . user = user ;
84
+ const user = { firstName : 'Lisa' , lastName : 'Dupont' , authenticationMethods : [ ] } ;
85
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
92
86
const getTemporaryBlockedUntilProperty = ( ) => null ;
93
87
const userLoginProxy = { get : getTemporaryBlockedUntilProperty } ;
94
88
component . args . user . userLogin = userLoginProxy ;
@@ -101,11 +95,10 @@ module('Unit | Component | users | user-overview', function (hooks) {
101
95
module ( 'when user has login and temporary blocked date' , function ( ) {
102
96
test ( 'should display temporary blocked date when now date is after temporaty blocked date' , function ( assert ) {
103
97
// given
104
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
105
- const user = { firstName : 'Lisa' , lastName : 'Dupont' } ;
98
+ const user = { firstName : 'Lisa' , lastName : 'Dupont' , authenticationMethods : [ ] } ;
106
99
const getTemporaryBlockedUntilProperty = ( ) => new Date ( Date . now ( ) + 3600 * 1000 ) ;
100
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
107
101
const userLoginProxy = { get : getTemporaryBlockedUntilProperty } ;
108
- component . args . user = user ;
109
102
component . args . user . userLogin = userLoginProxy ;
110
103
111
104
// when && then
@@ -114,9 +107,8 @@ module('Unit | Component | users | user-overview', function (hooks) {
114
107
115
108
test ( 'should not display temporary blocked date when now date is before temporaty blocked date' , function ( assert ) {
116
109
// given
117
- const component = createGlimmerComponent ( 'component:users/user-overview' ) ;
118
- const user = { firstName : 'Lisa' , lastName : 'Dupont' } ;
119
- component . args . user = user ;
110
+ const user = { firstName : 'Lisa' , lastName : 'Dupont' , authenticationMethods : [ ] } ;
111
+ const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
120
112
const getTemporaryBlockedUntilProperty = ( ) => new Date ( Date . now ( ) - 3600 * 1000 ) ;
121
113
const userLoginProxy = { get : getTemporaryBlockedUntilProperty } ;
122
114
component . args . user . userLogin = userLoginProxy ;
@@ -131,7 +123,7 @@ module('Unit | Component | users | user-overview', function (hooks) {
131
123
test ( 'should empty organization learners' , async function ( assert ) {
132
124
// given
133
125
const organizationLearners = [ { firstName : 'fanny' , lastName : 'epi' } ] ;
134
- const user = { organizationLearners, save : sinon . stub ( ) . resolves ( ) } ;
126
+ const user = { organizationLearners, save : sinon . stub ( ) . resolves ( ) , authenticationMethods : [ ] } ;
135
127
const component = createGlimmerComponent ( 'component:users/user-overview' , { user } ) ;
136
128
137
129
// when
0 commit comments