Skip to content

Commit 7cc962b

Browse files
committed
test: stabilize key format picker interactions
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
1 parent 4c01593 commit 7cc962b

2 files changed

Lines changed: 56 additions & 26 deletions

File tree

e2e/decoder.spec.ts

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,22 @@ test.describe("decode JWTs", () => {
504504
status: MessageStatusValue.VISIBLE,
505505
});
506506

507-
const formatPicker = page.locator(
508-
".react-select__single-value"
509-
);
510-
511-
await formatPicker.click();
512-
507+
const pemFormatPickerControl = page
508+
.locator(".react-select__single-value")
509+
.filter({ hasText: entry.publicKeyFormat })
510+
.locator(
511+
'xpath=ancestor::div[contains(@class, "react-select__control")]'
512+
);
513+
await pemFormatPickerControl.dispatchEvent("mousedown", {
514+
button: 0,
515+
});
513516
await page
517+
.getByRole("listbox")
514518
.getByRole("option", {
515519
name: entrywithJwkKey.publicKeyFormat,
520+
exact: true,
516521
})
517-
.click();
522+
.dispatchEvent("click");
518523

519524
await expect
520525
.poll(async () => {
@@ -569,13 +574,22 @@ test.describe("decode JWTs", () => {
569574
expect(decodedHeader).toBe(entrywithJwkKey.header);
570575
expect(decodedPayload).toBe(entrywithJwkKey.payload);
571576

572-
await formatPicker.click();
573-
577+
const jwkFormatPickerControl = page
578+
.locator(".react-select__single-value")
579+
.filter({ hasText: entrywithJwkKey.publicKeyFormat })
580+
.locator(
581+
'xpath=ancestor::div[contains(@class, "react-select__control")]'
582+
);
583+
await jwkFormatPickerControl.dispatchEvent("mousedown", {
584+
button: 0,
585+
});
574586
await page
587+
.getByRole("listbox")
575588
.getByRole("option", {
576589
name: entry.publicKeyFormat,
590+
exact: true,
577591
})
578-
.click();
592+
.dispatchEvent("click");
579593

580594
await expect(secretKeyEditorInput).toHaveValue(entry.publicKey);
581595

@@ -609,17 +623,22 @@ test.describe("decode JWTs", () => {
609623
status: MessageStatusValue.VISIBLE,
610624
});
611625

612-
const formatPicker = page.locator(
613-
".react-select__single-value"
614-
);
615-
616-
await formatPicker.click();
617-
626+
const pemFormatPickerControl = page
627+
.locator(".react-select__single-value")
628+
.filter({ hasText: entry.publicKeyFormat })
629+
.locator(
630+
'xpath=ancestor::div[contains(@class, "react-select__control")]'
631+
);
632+
await pemFormatPickerControl.dispatchEvent("mousedown", {
633+
button: 0,
634+
});
618635
await page
636+
.getByRole("listbox")
619637
.getByRole("option", {
620638
name: entrywithJwkKey.publicKeyFormat,
639+
exact: true,
621640
})
622-
.click();
641+
.dispatchEvent("click");
623642

624643
await secretKeyEditorInput.fill(
625644
JSON.stringify(entrywithJwkKey.publicKey),

e2e/encoder.spec.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,20 @@ test.describe("encode JWTs", () => {
463463
);
464464
}
465465

466-
const formatPicker = page.locator(
467-
".react-select__single-value"
468-
);
469-
await formatPicker.click();
470-
466+
const pemFormatPickerControl = page
467+
.locator(".react-select__single-value")
468+
.filter({ hasText: tokenWithPemKey.privateKeyFormat })
469+
.locator(
470+
'xpath=ancestor::div[contains(@class, "react-select__control")]'
471+
);
472+
await pemFormatPickerControl.dispatchEvent("mousedown", { button: 0 });
471473
await page
474+
.getByRole("listbox")
472475
.getByRole("option", {
473476
name: tokenWithJwkKey.privateKeyFormat,
477+
exact: true,
474478
})
475-
.click();
479+
.dispatchEvent("click");
476480

477481
await expect
478482
.poll(async () => {
@@ -498,13 +502,20 @@ test.describe("encode JWTs", () => {
498502
);
499503
}
500504

501-
await formatPicker.click();
502-
505+
const jwkFormatPickerControl = page
506+
.locator(".react-select__single-value")
507+
.filter({ hasText: tokenWithJwkKey.privateKeyFormat })
508+
.locator(
509+
'xpath=ancestor::div[contains(@class, "react-select__control")]'
510+
);
511+
await jwkFormatPickerControl.dispatchEvent("mousedown", { button: 0 });
503512
await page
513+
.getByRole("listbox")
504514
.getByRole("option", {
505515
name: tokenWithPemKey.privateKeyFormat,
516+
exact: true,
506517
})
507-
.click();
518+
.dispatchEvent("click");
508519

509520
await expect(secretKeyEditorInput).toHaveValue(
510521
tokenWithPemKey.privateKey

0 commit comments

Comments
 (0)