-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Problem
The current testing API can produce false positive test results because it allows tests to bypass browser focus management and perform actions that real users cannot.
Examples of False Positives:
1. Auto-focus is bypassed:
-- My app auto-focuses an input on init
-- But tests can type into ANY field regardless of focus:
client.keyDown sd (Dom.id "other-input") "a" []
-- This passes even though "other-input" has no focus\!2. Direct message updates bypass UI flow:
-- This bypasses all UI validation/interaction:
client.update sd (SubmitRegistrationForm)
-- What users actually must do:
client.click sd (Dom.id "submit-button")3. Games with global keyboard subscriptions:
-- Current workaround is verbose:
client.update sd (GameMsg (KeyDown (keyEventFromString "Space")))
-- Would be clearer and more accurate:
client.keyDownGlobal sd "Space"Proposed Solution
Add global keyboard event methods that respect browser focus state:
type alias FrontendActions =
{ -- existing methods...
, keyDownGlobal : DelayInMs -> KeyEvent -> List KeyOptions -> Action
, keyUpGlobal : DelayInMs -> KeyEvent -> List KeyOptions -> Action
}These would:
- Trigger global keyboard subscriptions when no element has focus
- Trigger on the focused element when one exists
- Fail if trying to type when no valid target exists
This ensures tests can only perform actions that real users can perform, catching focus-related bugs that currently slip through.
Benefits
- Eliminates false positives from focus-related bugs
- Makes game testing more intuitive
- Ensures tests match real user capabilities
- Maintains backward compatibility
Would you be open to this enhancement? I'm happy to contribute to the implementation if this aligns with your vision for the library.
michi-zuri
Metadata
Metadata
Assignees
Labels
No labels