@@ -27,6 +27,7 @@ import {
2727 isNoneAlg ,
2828} from "@/features/common/services/jwt.service" ;
2929import { MessageStatusValue , MessageTypeValue } from "./e2e.values" ;
30+ import { EncodingValues } from "@/features/common/values/encoding.values" ;
3031
3132const TestJwts = ( jwts as JwtDictionaryModel ) . byAlgorithm ;
3233
@@ -41,7 +42,7 @@ test.describe("Can interact with header editor in JWT Encoder", () => {
4142 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
4243
4344 const headerEditor = encoderWidget . getByTestId (
44- dataTestidDictionary . encoder . headerEditor . id ,
45+ dataTestidDictionary . encoder . headerEditor . id
4546 ) ;
4647 const headerEditorInput = headerEditor . getByRole ( "textbox" ) ;
4748
@@ -65,7 +66,7 @@ test.describe("Can interact with header editor in JWT Encoder", () => {
6566 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
6667
6768 const headerEditor = encoderWidget . getByTestId (
68- dataTestidDictionary . encoder . headerEditor . id ,
69+ dataTestidDictionary . encoder . headerEditor . id
6970 ) ;
7071 const headerEditorInput = headerEditor . getByRole ( "textbox" ) ;
7172
@@ -83,7 +84,7 @@ test.describe("Can interact with header editor in JWT Encoder", () => {
8384 const encoder = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
8485
8586 const headerEditor = encoder . getByTestId (
86- dataTestidDictionary . encoder . headerEditor . id ,
87+ dataTestidDictionary . encoder . headerEditor . id
8788 ) ;
8889 const headerEditorInput = headerEditor . getByRole ( "textbox" ) ;
8990
@@ -107,7 +108,7 @@ test.describe("can interact with payload editor in JWT encoder", () => {
107108 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
108109
109110 const payloadEditor = encoderWidget . getByTestId (
110- dataTestidDictionary . encoder . payloadEditor . id ,
111+ dataTestidDictionary . encoder . payloadEditor . id
111112 ) ;
112113 const payloadEditorInput = payloadEditor . getByRole ( "textbox" ) ;
113114
@@ -131,7 +132,7 @@ test.describe("can interact with payload editor in JWT encoder", () => {
131132 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
132133
133134 const payloadEditor = encoderWidget . getByTestId (
134- dataTestidDictionary . encoder . payloadEditor . id ,
135+ dataTestidDictionary . encoder . payloadEditor . id
135136 ) ;
136137 const payloadEditorInput = payloadEditor . getByRole ( "textbox" ) ;
137138
@@ -149,7 +150,7 @@ test.describe("can interact with payload editor in JWT encoder", () => {
149150 const encoder = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
150151
151152 const payloadEditor = encoder . getByTestId (
152- dataTestidDictionary . encoder . payloadEditor . id ,
153+ dataTestidDictionary . encoder . payloadEditor . id
153154 ) ;
154155 const payloadEditorInput = payloadEditor . getByRole ( "textbox" ) ;
155156
@@ -173,7 +174,7 @@ test.describe("can interact with secret editor in JWT encoder", () => {
173174 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
174175
175176 const secretKeyEditor = encoderWidget . getByTestId (
176- dataTestidDictionary . encoder . secretKeyEditor . id ,
177+ dataTestidDictionary . encoder . secretKeyEditor . id
177178 ) ;
178179 const secretKeyEditorInput = secretKeyEditor . getByRole ( "textbox" ) ;
179180
@@ -191,7 +192,7 @@ test.describe("can interact with secret editor in JWT encoder", () => {
191192 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
192193
193194 const secretKeyEditor = encoderWidget . getByTestId (
194- dataTestidDictionary . encoder . secretKeyEditor . id ,
195+ dataTestidDictionary . encoder . secretKeyEditor . id
195196 ) ;
196197 const secretKeyEditorInput = secretKeyEditor . getByRole ( "textbox" ) ;
197198
@@ -209,7 +210,7 @@ test.describe("can interact with secret editor in JWT encoder", () => {
209210 const encoder = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
210211
211212 const secretKeyEditor = encoder . getByTestId (
212- dataTestidDictionary . encoder . secretKeyEditor . id ,
213+ dataTestidDictionary . encoder . secretKeyEditor . id
213214 ) ;
214215 const secretKeyEditorInput = secretKeyEditor . getByRole ( "textbox" ) ;
215216
@@ -229,51 +230,15 @@ test.describe("Generate JWT encoding examples", () => {
229230 await switchToEncoderTab ( page ) ;
230231 } ) ;
231232
232- test ( "Can open and close encoder example widget" , async ( { page } ) => {
233- const lang = await getLang ( page ) ;
234- expectToBeNonNull ( lang ) ;
235-
236- const pickersUiDictionary = getPickersUiDictionary ( lang ) ;
237-
238- const encoder = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
239-
240- const exampleButton = encoder . getByRole ( "button" , {
241- name : pickersUiDictionary . exampleAlgPicker . label ,
242- } ) ;
243-
244- await exampleButton . click ( ) ;
245-
246- await expect ( exampleButton ) . not . toBeVisible ( ) ;
247-
248- const closeButton = page . getByRole ( "button" , {
249- name : pickersUiDictionary . exampleAlgPicker . closeButton . label ,
250- } ) ;
251-
252- await closeButton . click ( ) ;
253-
254- await expect ( exampleButton ) . toBeVisible ( ) ;
255- await expect ( closeButton ) . not . toBeVisible ( ) ;
256- } ) ;
257-
258233 test . describe ( "Can generate a JWT example" , ( ) => {
259234 test . beforeEach ( async ( { page } ) => {
260235 const lang = await getLang ( page ) ;
261236 expectToBeNonNull ( lang ) ;
262237
263238 const pickersUiDictionary = getPickersUiDictionary ( lang ) ;
264239
265- const encoder = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
266-
267- const exampleButton = encoder . getByRole ( "button" , {
268- name : pickersUiDictionary . exampleAlgPicker . label ,
269- } ) ;
270-
271- await exampleButton . click ( ) ;
272-
273- await expect ( exampleButton ) . not . toBeVisible ( ) ;
274-
275- const pickerIndicator = encoder . getByText (
276- pickersUiDictionary . exampleAlgPicker . defaultValue ,
240+ const pickerIndicator = page . getByText (
241+ pickersUiDictionary . exampleAlgPicker . defaultValue
277242 ) ;
278243
279244 await pickerIndicator . click ( ) ;
@@ -311,7 +276,7 @@ test.describe("Generate JWT encoding examples", () => {
311276 }
312277
313278 await expect ( jwtOutput ) . toHaveValue (
314- / ^ [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * $ / ,
279+ / ^ [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * $ /
315280 ) ;
316281 } ) ;
317282 } ) ;
@@ -336,13 +301,13 @@ test.describe("encode JWTs", () => {
336301 const encoderWidget = page . getByTestId ( dataTestidDictionary . encoder . id ) ;
337302
338303 const headerEditor = encoderWidget . getByTestId (
339- dataTestidDictionary . encoder . headerEditor . id ,
304+ dataTestidDictionary . encoder . headerEditor . id
340305 ) ;
341306 const payloadEditor = encoderWidget . getByTestId (
342- dataTestidDictionary . encoder . payloadEditor . id ,
307+ dataTestidDictionary . encoder . payloadEditor . id
343308 ) ;
344309 const secretKeyEditor = encoderWidget . getByTestId (
345- dataTestidDictionary . encoder . secretKeyEditor . id ,
310+ dataTestidDictionary . encoder . secretKeyEditor . id
346311 ) ;
347312 const jwtOutput = encoderWidget
348313 . getByTestId ( dataTestidDictionary . encoder . jwt . id )
@@ -415,16 +380,13 @@ test.describe("encode JWTs", () => {
415380
416381 await expect ( jwtOutput ) . toHaveValue ( tokenWithUtf8Secret . jwt ) ;
417382
418- const formatPicker = secretKeyEditor . locator (
419- ".react-select__single-value" ,
420- ) ;
421- await formatPicker . click ( ) ;
422-
423- await page
424- . getByRole ( "option" , {
425- name : tokenWithBase64urlSecret . secretEncoding ,
426- } )
427- . click ( ) ;
383+ const encodingSwitch = await page . getByTestId ( dataTestidDictionary . encoder . switch )
384+ expect ( encodingSwitch ) . toBeVisible ( )
385+
386+ if (
387+ tokenWithBase64urlSecret . secretEncoding === EncodingValues . BASE64URL
388+ )
389+ await encodingSwitch . click ( ) ;
428390
429391 await checkSecretKeyEncoderEditorStatusBarMessage ( {
430392 page,
@@ -479,12 +441,12 @@ test.describe("encode JWTs", () => {
479441 await expect ( jwtOutput ) . toHaveValue ( tokenWithPemKey . jwt ) ;
480442 } else {
481443 await expect ( jwtOutput ) . toHaveValue (
482- / ^ [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * $ / ,
444+ / ^ [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * $ /
483445 ) ;
484446 }
485447
486- const formatPicker = secretKeyEditor . locator (
487- ".react-select__single-value" ,
448+ const formatPicker = page . locator (
449+ ".react-select__single-value"
488450 ) ;
489451 await formatPicker . click ( ) ;
490452
@@ -501,7 +463,7 @@ test.describe("encode JWTs", () => {
501463 } ) ;
502464
503465 await secretKeyEditorInput . fill (
504- JSON . stringify ( tokenWithJwkKey . privateKey , null , 2 ) ,
466+ JSON . stringify ( tokenWithJwkKey . privateKey , null , 2 )
505467 ) ;
506468
507469 await checkSecretKeyEncoderEditorStatusBarMessage ( {
@@ -514,7 +476,7 @@ test.describe("encode JWTs", () => {
514476 await expect ( jwtOutput ) . toHaveValue ( tokenWithJwkKey . jwt ) ;
515477 } else {
516478 await expect ( jwtOutput ) . toHaveValue (
517- / ^ [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * $ / ,
479+ / ^ [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * \. [ A - Z a - z 0 - 9 _ - ] * $ /
518480 ) ;
519481 }
520482
0 commit comments