mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
test(mental-health): press an answer once the step's question holds the focus
The keys followed each other without waiting for the step to move the focus, so on a slow run Tab started from the previous answer and the number chose nothing.
This commit is contained in:
1 parent
4853e9cee6
commit
b597627a39
1 file changed
+7
-1
@@ -57,9 +57,15 @@ async function wizard(
|
||||
/**
|
||||
* Answer the current step by its position, as a keyboard user does: each new
|
||||
* step focuses its question, so Tab first reaches the answers, then the
|
||||
* number key chooses.
|
||||
* number key chooses. The step moves the focus in an effect after it renders,
|
||||
* so the keys wait for the question to hold it, as a person reading it would;
|
||||
* pressed earlier, Tab started from the previous step's answer and the number
|
||||
* chose nothing.
|
||||
*/
|
||||
async function pressAnswer(position: number) {
|
||||
await expect
|
||||
.poll(() => document.activeElement?.getAttribute("data-slot"))
|
||||
.toBe("check-in-question");
|
||||
await userEvent.tab();
|
||||
await userEvent.keyboard(String(position));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user