@@ -13,7 +13,7 @@ const formErrors = {
1313 linkDescription : "max-80-characters-error" ,
1414 email : "invalid-email-address-error" ,
1515 links : {
16- url :"link-reference-description-1-error" ,
16+ url : "link-reference-description-1-error" ,
1717 description : "link-reference-description-1-error" ,
1818 } ,
1919 identity : {
@@ -160,21 +160,52 @@ export default class DRepForm {
160160 for ( const err of formErrors . dRepName ) {
161161 await expect ( this . form . getByTestId ( err ) ) . toBeHidden ( ) ;
162162 }
163+ const objectivesInputText = await this . objectivesInput . textContent ( ) ;
164+ const motivationsInputText = await this . motivationsInput . textContent ( ) ;
165+ const qualificationsInputText =
166+ await this . qualificationsInput . textContent ( ) ;
167+ const isReferenceLinkErrorVisible = await this . form
168+ . getByTestId ( formErrors . links . url )
169+ . isVisible ( ) ;
170+ const isIdentityLinkErrorVisible = await this . form
171+ . getByTestId ( formErrors . identity . url )
172+ . isVisible ( ) ;
173+ const isPaymentAddressErrorVisible = await this . form
174+ . getByTestId ( formErrors . paymentAddress )
175+ . isVisible ( ) ;
163176
164- expect ( await this . objectivesInput . textContent ( ) ) . toEqual (
165- dRepInfo . objectives
166- ) ;
177+ expect ( await this . objectivesInput . textContent ( ) , {
178+ message :
179+ objectivesInputText !== dRepInfo . objectives &&
180+ `${ dRepInfo . objectives } is not equal to ${ await this . objectivesInput . textContent ( ) } ` ,
181+ } ) . toEqual ( dRepInfo . objectives ) ;
167182
168- expect ( await this . motivationsInput . textContent ( ) ) . toEqual (
169- dRepInfo . motivations
170- ) ;
171- expect ( await this . qualificationsInput . textContent ( ) ) . toEqual (
172- dRepInfo . qualifications
173- ) ;
183+ expect ( await this . motivationsInput . textContent ( ) , {
184+ message :
185+ motivationsInputText !== dRepInfo . motivations &&
186+ `${ dRepInfo . motivations } is not equal to ${ await this . motivationsInput . textContent ( ) } ` ,
187+ } ) . toEqual ( dRepInfo . motivations ) ;
188+ expect ( await this . qualificationsInput . textContent ( ) , {
189+ message :
190+ qualificationsInputText !== dRepInfo . qualifications &&
191+ `${ dRepInfo . qualifications } is not equal to ${ await this . qualificationsInput . textContent ( ) } ` ,
192+ } ) . toEqual ( dRepInfo . qualifications ) ;
174193
175- await expect ( this . form . getByTestId ( formErrors . links . url ) ) . toBeHidden ( ) ;
176- await expect ( this . form . getByTestId ( formErrors . identity . url ) ) . toBeHidden ( ) ;
177- await expect ( this . form . getByTestId ( formErrors . paymentAddress ) ) . toBeHidden ( ) ;
194+ await expect ( this . form . getByTestId ( formErrors . links . url ) , {
195+ message :
196+ isReferenceLinkErrorVisible &&
197+ `${ dRepInfo . linksReferenceLinks [ 0 ] . url } is an invalid url` ,
198+ } ) . toBeHidden ( ) ;
199+ await expect ( this . form . getByTestId ( formErrors . identity . url ) , {
200+ message :
201+ isIdentityLinkErrorVisible &&
202+ `${ dRepInfo . identityReferenceLinks [ 0 ] . url } is an invalid url` ,
203+ } ) . toBeHidden ( ) ;
204+ await expect ( this . form . getByTestId ( formErrors . paymentAddress ) , {
205+ message :
206+ isPaymentAddressErrorVisible &&
207+ `${ dRepInfo . paymentAddress } is an invalid paymentAddress` ,
208+ } ) . toBeHidden ( ) ;
178209 await expect ( this . continueBtn ) . toBeEnabled ( ) ;
179210 }
180211
@@ -200,28 +231,68 @@ export default class DRepForm {
200231
201232 expect ( nameErrors . length ) . toBeGreaterThanOrEqual ( 1 ) ;
202233
203- await expect (
204- this . form . getByTestId ( formErrors . paymentAddress )
205- ) . toBeVisible ( ) ;
234+ const objectivesInputText = await this . objectivesInput . textContent ( ) ;
235+ const motivationsInputText = await this . motivationsInput . textContent ( ) ;
236+ const qualificationsInputText =
237+ await this . qualificationsInput . textContent ( ) ;
238+ const isReferenceLinkErrorVisible = await this . form
239+ . getByTestId ( formErrors . links . url )
240+ . isVisible ( ) ;
241+ const isReferenceLinkDescriptionErrorVisible = await this . form
242+ . getByTestId ( formErrors . links . description )
243+ . isVisible ( ) ;
244+ const isIdentityLinkErrorVisible = await this . form
245+ . getByTestId ( formErrors . identity . url )
246+ . isVisible ( ) ;
247+ const isIdentityLinkDescriptionErrorVisible = await this . form
248+ . getByTestId ( formErrors . identity . description )
249+ . isVisible ( ) ;
250+ const isPaymentAddressErrorVisible = await this . form
251+ . getByTestId ( formErrors . paymentAddress )
252+ . isVisible ( ) ;
206253
207- expect ( await this . objectivesInput . textContent ( ) ) . not . toEqual (
208- dRepInfo . objectives
209- ) ;
210- expect ( await this . motivationsInput . textContent ( ) ) . not . toEqual (
211- dRepInfo . qualifications
212- ) ;
213- expect ( await this . qualificationsInput . textContent ( ) ) . not . toEqual (
214- dRepInfo . qualifications
215- ) ;
254+ await expect ( this . form . getByTestId ( formErrors . paymentAddress ) , {
255+ message :
256+ ! isPaymentAddressErrorVisible &&
257+ `${ dRepInfo . paymentAddress } is a valid paymentAddress` ,
258+ } ) . toBeVisible ( ) ;
259+
260+ expect ( await this . objectivesInput . textContent ( ) , {
261+ message :
262+ objectivesInputText === dRepInfo . objectives &&
263+ `${ dRepInfo . objectives } is equal to ${ await this . objectivesInput . textContent ( ) } ` ,
264+ } ) . not . toEqual ( dRepInfo . objectives ) ;
265+ expect ( await this . motivationsInput . textContent ( ) , {
266+ message :
267+ motivationsInputText === dRepInfo . motivations &&
268+ `${ dRepInfo . motivations } is equal to ${ await this . motivationsInput . textContent ( ) } ` ,
269+ } ) . not . toEqual ( dRepInfo . qualifications ) ;
270+ expect ( await this . qualificationsInput . textContent ( ) , {
271+ message :
272+ qualificationsInputText === dRepInfo . qualifications &&
273+ `${ dRepInfo . qualifications } is equal to ${ await this . qualificationsInput . textContent ( ) } ` ,
274+ } ) . not . toEqual ( dRepInfo . qualifications ) ;
216275
217- await expect ( this . form . getByTestId ( formErrors . links . url ) ) . toBeVisible ( ) ;
218- await expect (
219- this . form . getByTestId ( formErrors . links . description )
220- ) . toBeVisible ( ) ;
221- await expect ( this . form . getByTestId ( formErrors . identity . url ) ) . toBeVisible ( ) ;
222- await expect (
223- this . form . getByTestId ( formErrors . identity . description )
224- ) . toBeVisible ( ) ;
276+ await expect ( this . form . getByTestId ( formErrors . links . url ) , {
277+ message :
278+ ! isReferenceLinkErrorVisible &&
279+ `${ dRepInfo . linksReferenceLinks [ 0 ] . url } is a valid url` ,
280+ } ) . toBeVisible ( ) ;
281+ await expect ( this . form . getByTestId ( formErrors . links . description ) , {
282+ message :
283+ ! isReferenceLinkDescriptionErrorVisible &&
284+ `${ dRepInfo . linksReferenceLinks [ 0 ] . description } is a valid description` ,
285+ } ) . toBeVisible ( ) ;
286+ await expect ( this . form . getByTestId ( formErrors . identity . url ) , {
287+ message :
288+ ! isIdentityLinkErrorVisible &&
289+ `${ dRepInfo . identityReferenceLinks [ 0 ] . url } is a valid url` ,
290+ } ) . toBeVisible ( ) ;
291+ await expect ( this . form . getByTestId ( formErrors . identity . description ) , {
292+ message :
293+ ! isIdentityLinkDescriptionErrorVisible &&
294+ `${ dRepInfo . identityReferenceLinks [ 0 ] . description } is a valid description` ,
295+ } ) . toBeVisible ( ) ;
225296
226297 await expect ( this . continueBtn ) . toBeDisabled ( ) ;
227298 }
0 commit comments