@@ -27,6 +27,7 @@ import {
2727import { MessageStatusValue , MessageTypeValue } from "./e2e.values" ;
2828import { JwtDictionaryModel , JwtSignedWithDigitalModel } from "./e2e.models" ;
2929import jwts from "./jwt.json" with { type : "json" } ;
30+ import { EncodingValues } from "@/features/common/values/encoding.values" ;
3031
3132const TestJwts = ( jwts as JwtDictionaryModel ) . byAlgorithm ;
3233
@@ -39,7 +40,7 @@ test.describe("Can interact with JWT Decoder JWT editor", () => {
3940 const jwtEditorInput = getDecoderJwtEditorInput ( page ) ;
4041
4142 await expect ( jwtEditorInput ) . toHaveValue (
42- "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30" ,
43+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30"
4344 ) ;
4445 } ) ;
4546
@@ -53,8 +54,13 @@ test.describe("Can interact with JWT Decoder JWT editor", () => {
5354 await expect ( jwtEditorInput ) . toHaveValue ( inputValue ) ;
5455 } ) ;
5556
56- test ( "can copy value in JWT editor" , async ( { page, context, browserName } ) => {
57- const permissions = browserName === 'firefox' ? [ ] : [ "clipboard-read" , "clipboard-write" ]
57+ test ( "can copy value in JWT editor" , async ( {
58+ page,
59+ context,
60+ browserName,
61+ } ) => {
62+ const permissions =
63+ browserName === "firefox" ? [ ] : [ "clipboard-read" , "clipboard-write" ] ;
5864 const inputValue = ( TestJwts . RS512 as JwtSignedWithDigitalModel ) . withPemKey
5965 . jwt ;
6066 await context . grantPermissions ( permissions ) ;
@@ -76,7 +82,7 @@ test.describe("Can interact with JWT Decoder JWT editor", () => {
7682 await copyButton . click ( ) ;
7783
7884 const clipboardContent = await page . evaluate ( ( ) =>
79- navigator . clipboard . readText ( ) ,
85+ navigator . clipboard . readText ( )
8086 ) ;
8187
8288 expect ( clipboardContent ) . toBe ( inputValue ) ;
@@ -111,11 +117,8 @@ test.describe("Can generate JWT examples", () => {
111117 expectToBeNonNull ( lang ) ;
112118
113119 const pickersUiDictionary = getPickersUiDictionary ( lang ) ;
114-
115- const decoderWidget = page . getByTestId ( dataTestidDictionary . decoder . id ) ;
116-
117- const pickerIndicator = decoderWidget . getByText (
118- pickersUiDictionary . exampleAlgPicker . defaultValue ,
120+ const pickerIndicator = page . getByText (
121+ pickersUiDictionary . exampleAlgPicker . defaultValue
119122 ) ;
120123
121124 await pickerIndicator . click ( ) ;
@@ -140,7 +143,7 @@ test.describe("Can generate JWT examples", () => {
140143 const targetToken = DefaultTokensValues [ option ] ;
141144
142145 const jwtEditor = decoderWidget . getByTestId (
143- dataTestidDictionary . decoder . jwtEditor . id ,
146+ dataTestidDictionary . decoder . jwtEditor . id
144147 ) ;
145148 const jwtEditorInput = jwtEditor . getByRole ( "textbox" ) ;
146149
@@ -169,7 +172,7 @@ test.describe("Can generate JWT examples", () => {
169172 } ) ;
170173
171174 const secretKeyEditor = decoderWidget . getByTestId (
172- dataTestidDictionary . decoder . secretKeyEditor . id ,
175+ dataTestidDictionary . decoder . secretKeyEditor . id
173176 ) ;
174177 const secretKeyInput = secretKeyEditor . getByRole ( "textbox" ) ;
175178
@@ -183,9 +186,13 @@ test.describe("Can generate JWT examples", () => {
183186 status : MessageStatusValue . VISIBLE ,
184187 } ) ;
185188
186- const encodingValue = await secretKeyEditor
187- . locator ( ".react-select__single-value" )
188- . innerText ( ) ;
189+ const isEncodingSwitchChecked = await page
190+ . getByRole ( "switch" )
191+ . isChecked ( ) ;
192+
193+ const encodingValue = isEncodingSwitchChecked
194+ ? EncodingValues . BASE64URL
195+ : EncodingValues . UTF8 ;
189196
190197 expect ( encodingValue ) . toBe ( symmetricToken . secretEncoding ) ;
191198
@@ -202,8 +209,9 @@ test.describe("Can generate JWT examples", () => {
202209 status : MessageStatusValue . VISIBLE ,
203210 } ) ;
204211
205- const formatValue = await secretKeyEditor
212+ const formatValue = await page
206213 . locator ( ".react-select__single-value" )
214+ . nth ( 1 )
207215 . innerText ( ) ;
208216
209217 expect ( formatValue ) . toBe ( asymmetricToken . publicKeyFormat ) ;
@@ -236,7 +244,7 @@ test.describe("decode JWTs", () => {
236244 const decoderWidget = page . getByTestId ( dataTestidDictionary . decoder . id ) ;
237245
238246 const jwtEditor = decoderWidget . getByTestId (
239- dataTestidDictionary . decoder . jwtEditor . id ,
247+ dataTestidDictionary . decoder . jwtEditor . id
240248 ) ;
241249 const jwtEditorInput = jwtEditor . getByRole ( "textbox" ) ;
242250
@@ -293,14 +301,14 @@ test.describe("decode JWTs", () => {
293301 } ) ;
294302
295303 const secretKeyEditor = decoderWidget . getByTestId (
296- dataTestidDictionary . decoder . secretKeyEditor . id ,
304+ dataTestidDictionary . decoder . secretKeyEditor . id
297305 ) ;
298306 const secretKeyEditorInput = secretKeyEditor . getByRole ( "textbox" ) ;
299307
300308 await secretKeyEditorInput . fill ( entryWithUtf8Secret . secret ) ;
301309
302310 await expect ( secretKeyEditorInput ) . toHaveValue (
303- entryWithUtf8Secret . secret ,
311+ entryWithUtf8Secret . secret
304312 ) ;
305313
306314 await checkSecretKeyDecoderEditorStatusBarMessage ( {
@@ -309,9 +317,13 @@ test.describe("decode JWTs", () => {
309317 status : MessageStatusValue . VISIBLE ,
310318 } ) ;
311319
312- const encodingValue = await secretKeyEditor
313- . locator ( ".react-select__single-value" )
314- . innerText ( ) ;
320+ const isEncodingSwitchChecked = await page
321+ . getByRole ( "switch" )
322+ . isChecked ( ) ;
323+
324+ const encodingValue = isEncodingSwitchChecked
325+ ? EncodingValues . BASE64URL
326+ : EncodingValues . UTF8 ;
315327
316328 expect ( encodingValue ) . toBe ( entryWithUtf8Secret . secretEncoding ) ;
317329
@@ -354,17 +366,13 @@ test.describe("decode JWTs", () => {
354366 status : MessageStatusValue . VISIBLE ,
355367 } ) ;
356368
357- const formatPicker = secretKeyEditor . locator (
358- ".react-select__single-value" ,
359- ) ;
360-
361- await formatPicker . click ( ) ;
369+ const encodingSwitch = await page . getByTestId ( dataTestidDictionary . encoder . switch )
370+ expect ( encodingSwitch ) . toBeVisible ( )
362371
363- await page
364- . getByRole ( "option" , {
365- name : entryWithBase64urlSecret . secretEncoding ,
366- } )
367- . click ( ) ;
372+ if (
373+ entryWithBase64urlSecret . secretEncoding === EncodingValues . BASE64URL
374+ )
375+ await encodingSwitch . click ( ) ;
368376
369377 await secretKeyEditorInput . fill ( entryWithBase64urlSecret . secret ) ;
370378
@@ -417,7 +425,7 @@ test.describe("decode JWTs", () => {
417425 } ) ;
418426
419427 const secretKeyEditor = decoderWidget . getByTestId (
420- dataTestidDictionary . decoder . secretKeyEditor . id ,
428+ dataTestidDictionary . decoder . secretKeyEditor . id
421429 ) ;
422430 const secretKeyEditorInput = secretKeyEditor . getByRole ( "textbox" ) ;
423431
@@ -431,7 +439,7 @@ test.describe("decode JWTs", () => {
431439 status : MessageStatusValue . VISIBLE ,
432440 } ) ;
433441
434- const formatValue = await secretKeyEditor
442+ const formatValue = await page
435443 . locator ( ".react-select__single-value" )
436444 . innerText ( ) ;
437445
@@ -477,8 +485,8 @@ test.describe("decode JWTs", () => {
477485 status : MessageStatusValue . VISIBLE ,
478486 } ) ;
479487
480- const formatPicker = secretKeyEditor . locator (
481- ".react-select__single-value" ,
488+ const formatPicker = page . locator (
489+ ".react-select__single-value"
482490 ) ;
483491
484492 await formatPicker . click ( ) ;
@@ -496,7 +504,7 @@ test.describe("decode JWTs", () => {
496504 } ) ;
497505
498506 await secretKeyEditorInput . fill (
499- JSON . stringify ( entrywithJwkKey . publicKey , null , 2 ) ,
507+ JSON . stringify ( entrywithJwkKey . publicKey , null , 2 )
500508 ) ;
501509
502510 await checkJwtEditorStatusBarMessage ( {
@@ -547,8 +555,8 @@ test.describe("decode JWTs", () => {
547555 status : MessageStatusValue . VISIBLE ,
548556 } ) ;
549557
550- const formatPicker = secretKeyEditor . locator (
551- ".react-select__single-value" ,
558+ const formatPicker = page . locator (
559+ ".react-select__single-value"
552560 ) ;
553561
554562 await formatPicker . click ( ) ;
@@ -560,7 +568,7 @@ test.describe("decode JWTs", () => {
560568 . click ( ) ;
561569
562570 await secretKeyEditorInput . fill (
563- JSON . stringify ( entrywithJwkKey . publicKey , null , 2 ) ,
571+ JSON . stringify ( entrywithJwkKey . publicKey , null , 2 )
564572 ) ;
565573
566574 await checkJwtEditorStatusBarMessage ( {
@@ -608,10 +616,10 @@ test("Can decode JWTs signed with a non-supported algorithm", async ({
608616 kid : "sig" ,
609617 } ;
610618 const expectedDecodedPayload = {
611- " sub" : "1234567890" ,
612- " name" : "John Doe" ,
613- " admin" : true ,
614- " iat" : 1516239022
619+ sub : "1234567890" ,
620+ name : "John Doe" ,
621+ admin : true ,
622+ iat : 1516239022 ,
615623 } ;
616624
617625 await page . goto ( E2E_BASE_URL ) ;
@@ -622,7 +630,7 @@ test("Can decode JWTs signed with a non-supported algorithm", async ({
622630 const decoderWidget = page . getByTestId ( dataTestidDictionary . decoder . id ) ;
623631
624632 const jwtEditor = decoderWidget . getByTestId (
625- dataTestidDictionary . decoder . jwtEditor . id ,
633+ dataTestidDictionary . decoder . jwtEditor . id
626634 ) ;
627635 const jwtEditorInput = jwtEditor . getByRole ( "textbox" ) ;
628636
@@ -644,22 +652,22 @@ test("Can decode JWTs signed with a non-supported algorithm", async ({
644652
645653 await expect (
646654 decoderWidget . getByTestId (
647- dataTestidDictionary . decoder . decodedHeader . json . id ,
648- ) ,
655+ dataTestidDictionary . decoder . decodedHeader . json . id
656+ )
649657 ) . toHaveText ( JSON . stringify ( expectedDecodedHeader , null , 2 ) , {
650658 useInnerText : true ,
651659 } ) ;
652660
653661 await expect (
654662 decoderWidget . getByTestId (
655- dataTestidDictionary . decoder . decodedPayload . json . id ,
656- ) ,
663+ dataTestidDictionary . decoder . decodedPayload . json . id
664+ )
657665 ) . toHaveText ( JSON . stringify ( expectedDecodedPayload , null , 2 ) , {
658666 useInnerText : true ,
659667 } ) ;
660668
661669 const secretKeyEditor = decoderWidget . getByTestId (
662- dataTestidDictionary . decoder . secretKeyEditor . id ,
670+ dataTestidDictionary . decoder . secretKeyEditor . id
663671 ) ;
664672
665673 await expect ( secretKeyEditor ) . not . toBeVisible ( ) ;
@@ -677,10 +685,10 @@ test.describe("Decode pieces of JWTs in Base64Url", () => {
677685 jwtPiece :
678686 "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0" ,
679687 expectedDecodedOutput : {
680- " sub" : "1234567890" ,
681- " name" : "John Doe" ,
682- " admin" : true ,
683- " iat" : 1516239022
688+ sub : "1234567890" ,
689+ name : "John Doe" ,
690+ admin : true ,
691+ iat : 1516239022 ,
684692 } ,
685693 } ,
686694 {
@@ -703,7 +711,7 @@ test.describe("Decode pieces of JWTs in Base64Url", () => {
703711 const decoderWidget = page . getByTestId ( dataTestidDictionary . decoder . id ) ;
704712
705713 const jwtEditor = decoderWidget . getByTestId (
706- dataTestidDictionary . decoder . jwtEditor . id ,
714+ dataTestidDictionary . decoder . jwtEditor . id
707715 ) ;
708716 const jwtEditorInput = jwtEditor . getByRole ( "textbox" ) ;
709717
@@ -725,20 +733,20 @@ test.describe("Decode pieces of JWTs in Base64Url", () => {
725733
726734 await expect (
727735 decoderWidget . getByTestId (
728- dataTestidDictionary . decoder . decodedHeader . json . id ,
729- ) ,
736+ dataTestidDictionary . decoder . decodedHeader . json . id
737+ )
730738 ) . toHaveText ( JSON . stringify ( expectedDecodedOutput , null , 2 ) , {
731739 useInnerText : true ,
732740 } ) ;
733741
734742 await expect (
735743 decoderWidget . getByTestId (
736- dataTestidDictionary . decoder . decodedPayload . json . id ,
737- ) ,
744+ dataTestidDictionary . decoder . decodedPayload . json . id
745+ )
738746 ) . toBeEmpty ( ) ;
739747
740748 const secretKeyEditor = decoderWidget . getByTestId (
741- dataTestidDictionary . decoder . secretKeyEditor . id ,
749+ dataTestidDictionary . decoder . secretKeyEditor . id
742750 ) ;
743751
744752 await expect ( secretKeyEditor ) . not . toBeVisible ( ) ;
0 commit comments