Skip to content

Commit f1dc929

Browse files
fix: stabilize algorithm picker e2e. (#940)
* fix: stabilize algorithm picker visibility in JWT editor tests. * fix: refactor capabilities state management in algorithm picker cmp. * fix: clean up whitespace in workflow YAML files.
1 parent f2014e6 commit f1dc929

5 files changed

Lines changed: 49 additions & 25 deletions

File tree

‎.github/workflows/production.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ jobs:
2323

2424
- name: Run Vitest
2525
run: npx vitest run
26-
26+
2727
- name: Install Playwright Browsers
2828
run: npx playwright install --with-deps
2929

3030
- name: Run Playwright Tests
3131
run: NODE_OPTIONS="--no-experimental-strip-types" npx playwright test
32-
32+
3333
- name: Upload Playwright Traces
3434
if: failure()
3535
uses: actions/upload-artifact@v4
3636
with:
3737
name: playwright-traces
3838
path: playwright-report/**/trace.zip
39-
39+
4040
Deploy-Production:
4141
needs: test
4242
runs-on:

‎.github/workflows/tests.yaml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ jobs:
2222

2323
- name: Run Vitest
2424
run: npx vitest run
25-
25+
2626
- name: Install Playwright Browsers
2727
run: npx playwright install --with-deps
2828

2929
- name: Run Playwright Tests
3030
run: NODE_OPTIONS="--no-experimental-strip-types" npx playwright test
31-
31+
3232
- name: Upload Playwright Traces
3333
if: failure()
3434
uses: actions/upload-artifact@v4
3535
with:
3636
name: playwright-traces
37-
path: playwright-report/**/trace.zip
38-
39-
37+
path: test-results/**/trace.zip

‎e2e/decoder.spec.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,20 @@ test.describe("Can generate JWT examples", () => {
116116
const lang = await getLang(page);
117117
expectToBeNonNull(lang);
118118

119+
const algorithmPicker = page.getByRole("combobox", {
120+
name: "Debugger picker",
121+
});
122+
const algorithmPickerRegion = page
123+
.getByRole("region")
124+
.filter({ has: algorithmPicker });
119125
const pickersUiDictionary = getPickersUiDictionary(lang);
120126
const pickerIndicator = page.getByText(
121127
pickersUiDictionary.exampleAlgPicker.defaultValue
122128
);
123129

130+
await expect(algorithmPickerRegion).toHaveAttribute("aria-busy", "false");
124131
await pickerIndicator.click();
125-
await page.getByRole("listbox").waitFor({ state: "visible" });
132+
await expect(page.getByRole("listbox")).toBeVisible();
126133
});
127134

128135
const options = Object.keys(DefaultTokensValues);

‎e2e/encoder.spec.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,20 @@ test.describe("Generate JWT encoding examples", () => {
235235
const lang = await getLang(page);
236236
expectToBeNonNull(lang);
237237

238+
const algorithmPicker = page.getByRole("combobox", {
239+
name: "Debugger picker",
240+
});
241+
const algorithmPickerRegion = page
242+
.getByRole("region")
243+
.filter({ has: algorithmPicker });
238244
const pickersUiDictionary = getPickersUiDictionary(lang);
239-
240245
const pickerIndicator = page.getByText(
241246
pickersUiDictionary.exampleAlgPicker.defaultValue
242247
);
243248

249+
await expect(algorithmPickerRegion).toHaveAttribute("aria-busy", "false");
244250
await pickerIndicator.click();
245-
await page.getByRole("listbox").waitFor({ state: "visible" });
251+
await expect(page.getByRole("listbox")).toBeVisible();
246252
});
247253

248254
const options = Object.keys(DefaultTokensValues);

‎src/features/debugger/components/debugger-alg-picker/debugger-alg-picker.component.tsx‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,14 @@ export const WidgetAlgPickerComponent: React.FC<
6464
const [pickerState, setPickerState] = useState<PickerStates>(
6565
PickerStates.IDLE
6666
);
67-
const [canUseEs512, setCanUseEs512] = useState(false);
68-
const [canUseEd25519, setCanUseEd25519] = useState(false);
69-
const [canUseEd448, setCanUseEd448] = useState(false);
67+
const [capabilities, setCapabilities] = useState({
68+
canUseEs512: false,
69+
canUseEd25519: false,
70+
canUseEd448: false,
71+
isLoading: true,
72+
});
73+
74+
const { canUseEs512, canUseEd25519, canUseEd448, isLoading } = capabilities;
7075

7176
const dictionary = getPickersUiDictionary(languageCode);
7277

@@ -93,16 +98,19 @@ export const WidgetAlgPickerComponent: React.FC<
9398
};
9499

95100
useEffect(() => {
96-
(async function runEs512Check() {
97-
setCanUseEs512(await isP521Supported());
98-
})();
99-
100-
(async function runEd25519Check() {
101-
setCanUseEd25519(await isEd25519Supported());
102-
})();
103-
104-
(async function runEd448Check() {
105-
setCanUseEd448(await isEd448Supported());
101+
(async function checkCapabilities() {
102+
const [canUseEs512, canUseEd25519, canUseEd448] = await Promise.all([
103+
isP521Supported(),
104+
isEd25519Supported(),
105+
isEd448Supported(),
106+
]);
107+
108+
setCapabilities({
109+
canUseEs512,
110+
canUseEd25519,
111+
canUseEd448,
112+
isLoading: false,
113+
});
106114
})();
107115
}, []);
108116

@@ -188,7 +196,12 @@ export const WidgetAlgPickerComponent: React.FC<
188196
}, [noneAlgOptions, asymmetricAlgOptions, symmetricAlgOptions]);
189197

190198
return (
191-
<div role="region" aria-label={label} className={styles.alg_picker}>
199+
<div
200+
role="region"
201+
aria-label={label}
202+
aria-busy={isLoading}
203+
className={styles.alg_picker}
204+
>
192205
<div className={styles.container}>
193206
<div className={styles.picker}>
194207
<div className={styles.picker__label}>

0 commit comments

Comments
 (0)