PIR: Add unit tests for JS event handlers #7334
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.
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 toExtractedProfile, generated email state, pixel emission, and next action.ErrorReceivedHandlerTest: maps various errors toBrokerActionFailedwith 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.CaptchaInforReceivedEventHandlertoCaptchaInfoReceivedEventHandler.shouldRetryFailedActionwith an expressionreturnwhile preserving behavior.Written by Cursor Bugbot for commit 55bc3fd. This will update automatically on new commits. Configure here.