Commit 1aabb0b
PIR: Add unit tests for JS event handlers (#7334)
Task/Issue URL:
https://app.asana.com/1/137249556945/project/1203581873609357/task/1212381653445208?focus=true
### Description
Adds missing unit tests for the JS event handlers.
### Steps to test this PR
Ensure the unit tests pass
### UI changes
No UI changes
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds extensive unit tests covering PIR JS event handlers (state
transitions, side effects, pixels, retries) and fixes a handler class
name; also simplifies retry decision logic.
>
> - **Tests (new, extensive)**:
> - `BrokerActionFailedEventHandlerTest`: verifies retry limits,
expectation-only retries for scans, failure pixel emission.
> - `BrokerStepCompletedEventHandlerTest`: validates success/failure
outcomes, email confirmation flow, stage timing, and state resets.
> - `CaptchaInfoReceivedEventHandlerTest`: asserts transaction ID
handling, next-action progression, and pixel emission for opt-out.
> - `EmailReceivedEventHandlerTest`: ensures email propagation to
`ExtractedProfile`, generated email state, pixel emission, and next
action.
> - `ErrorReceivedHandlerTest`: maps various errors to
`BrokerActionFailed` with no retry; state remains unchanged.
> - `ExecuteBrokerStepActionEventHandlerTest`: covers side effects
(`PushJsAction`, `LoadUrl`, captcha/email flows), delays, pixels, and
data sourcing.
> - `ExecuteNextBrokerStepEventHandlerTest`: starts next broker step,
emits start pixels, resets indices, completes execution when done.
> - `LoadUrlCompleteEventHandlerTest` / `LoadUrlFailedEventHandlerTest`:
handle initial/recovery URLs, advance/abort flows, and retries.
> - `RetryAwaitCaptchaSolutionEventHandlerTest` /
`RetryGetCaptchaSolutionEventHandlerTest`: increment attempts and
re-dispatch side effects.
> - `StartedEventHandlerTest`: initializes attempt ID and kicks off
initial URL load.
> - **Minor fixes**:
> - Rename `CaptchaInforReceivedEventHandler` to
`CaptchaInfoReceivedEventHandler`.
> - Simplify `shouldRetryFailedAction` with an expression `return` while
preserving behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
55bc3fd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 64d8c5b commit 1aabb0b
File tree
14 files changed
+4138
-4
lines changed- pir/pir-impl/src
- main/java/com/duckduckgo/pir/impl/common/actions
- test/kotlin/com/duckduckgo/pir/impl/common/actions
14 files changed
+4138
-4
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
0 commit comments