@@ -9,6 +9,7 @@ describe('Unit | Identity Access Management | Domain | Email | create-warning-co
9
9
email : 'test@example.com' ,
10
10
locale : 'fr' ,
11
11
firstName : 'John' ,
12
+ validationToken : 'token' ,
12
13
} ;
13
14
14
15
const email = createWarningConnectionEmail ( emailParams ) ;
@@ -40,56 +41,100 @@ describe('Unit | Identity Access Management | Domain | Email | create-warning-co
40
41
} ) ;
41
42
42
43
describe ( 'when the locale is en' , function ( ) {
43
- it ( 'provides the correct reset password URL ' , function ( ) {
44
+ it ( 'provides the correct urls ' , function ( ) {
44
45
// given
45
46
const emailParams = {
46
47
email : 'toto@example.net' ,
47
48
locale : 'en' ,
48
49
firstName : 'John' ,
50
+ validationToken : 'token' ,
49
51
} ;
50
52
51
53
// when
52
54
const email = createWarningConnectionEmail ( emailParams ) ;
53
55
54
56
// then
55
- const resetUrl = email . variables . resetUrl ;
56
- expect ( resetUrl ) . to . equal ( 'https://test.app.pix.org/mot-de-passe-oublie?lang=en' ) ;
57
+ const { helpDeskUrl, resetUrl } = email . variables ;
58
+ const expectedSupportUrl =
59
+ 'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.org%2Fen%2Fsupport' ;
60
+
61
+ const expectedResetUrl =
62
+ 'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.org%2Fmot-de-passe-oublie%3Flang%3Den' ;
63
+ expect ( resetUrl ) . to . equal ( expectedResetUrl ) ;
64
+ expect ( helpDeskUrl ) . to . equal ( expectedSupportUrl ) ;
57
65
} ) ;
58
66
} ) ;
59
67
60
68
describe ( 'when the locale is fr-fr' , function ( ) {
61
- it ( 'provides the correct reset password URL ' , function ( ) {
69
+ it ( 'provides the correct urls ' , function ( ) {
62
70
// given
63
71
const emailParams = {
64
72
email : 'toto@example.net' ,
65
73
locale : 'fr-fr' ,
66
74
firstName : 'John' ,
75
+ validationToken : 'token' ,
67
76
} ;
68
77
69
78
// when
70
79
const email = createWarningConnectionEmail ( emailParams ) ;
71
80
72
81
// then
73
- const resetUrl = email . variables . resetUrl ;
74
- expect ( resetUrl ) . to . equal ( 'https://test.app.pix.fr/mot-de-passe-oublie?lang=fr' ) ;
82
+ const { helpDeskUrl, resetUrl } = email . variables ;
83
+ const expectedSupportUrl =
84
+ 'https://test.app.pix.fr/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.fr%2Fsupport' ;
85
+ const expectedResetUrl =
86
+ 'https://test.app.pix.fr/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.fr%2Fmot-de-passe-oublie%3Flang%3Dfr' ;
87
+ expect ( resetUrl ) . to . equal ( expectedResetUrl ) ;
88
+ expect ( helpDeskUrl ) . to . equal ( expectedSupportUrl ) ;
89
+ } ) ;
90
+ } ) ;
91
+
92
+ describe ( 'when the locale is fr' , function ( ) {
93
+ it ( 'provides the correct urls' , function ( ) {
94
+ // given
95
+ const emailParams = {
96
+ email : 'toto@example.net' ,
97
+ locale : 'fr' ,
98
+ firstName : 'John' ,
99
+ validationToken : 'token' ,
100
+ } ;
101
+
102
+ // when
103
+ const email = createWarningConnectionEmail ( emailParams ) ;
104
+
105
+ // then
106
+ const { helpDeskUrl, resetUrl } = email . variables ;
107
+ const expectedSupportUrl =
108
+ 'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.org%2Ffr%2Fsupport' ;
109
+ const expectedResetUrl =
110
+ 'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.org%2Fmot-de-passe-oublie%3Flang%3Dfr' ;
111
+ expect ( resetUrl ) . to . equal ( expectedResetUrl ) ;
112
+ expect ( helpDeskUrl ) . to . equal ( expectedSupportUrl ) ;
75
113
} ) ;
76
114
} ) ;
77
115
78
116
describe ( 'when the locale is nl-BE' , function ( ) {
79
- it ( 'provides the correct reset password URL ' , function ( ) {
117
+ it ( 'provides the correct urls ' , function ( ) {
80
118
// given
81
119
const emailParams = {
82
120
email : 'toto@example.net' ,
83
121
locale : 'nl-BE' ,
84
122
firstName : 'John' ,
123
+ validationToken : 'token' ,
85
124
} ;
86
125
87
126
// when
88
127
const email = createWarningConnectionEmail ( emailParams ) ;
89
128
90
129
// then
91
- const resetUrl = email . variables . resetUrl ;
92
- expect ( resetUrl ) . to . equal ( 'https://test.app.pix.org/mot-de-passe-oublie?lang=nl' ) ;
130
+ const { resetUrl, helpDeskUrl } = email . variables ;
131
+ const expectedResetUrl =
132
+ 'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.org%2Fmot-de-passe-oublie%3Flang%3Dnl' ;
133
+
134
+ const expectedSupportUrl =
135
+ 'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.org%2Fnl-be%2Fsupport' ;
136
+ expect ( resetUrl ) . to . equal ( expectedResetUrl ) ;
137
+ expect ( helpDeskUrl ) . to . equal ( expectedSupportUrl ) ;
93
138
} ) ;
94
139
} ) ;
95
140
} ) ;
0 commit comments