test(workflows): verify purchase/restore callbacks fire from any workflow step#6855
Conversation
vegaro
left a comment
There was a problem hiding this comment.
Tests look good but I am not sure we are covering the real world where navigating back and forth could actually break the listeners?
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 63c3d9a. Configure here.
588245c to
5eef730
Compare
…flow step Cover the purchase/restore callbacks (onPurchaseStarted/Completed/Cancelled/Failure, onRestoreStarted/Completed/Failure) on the initial step and on a non-initial step (seeded via initial_step_id). WorkflowPaywallView holds a single purchaseHandler above the per-step PaywallsV2View subtrees that navigation swaps, so callback forwarding is step-independent by construction. The non-initial-step tests cover that without any production test seam, so this drops the earlier #if DEBUG WorkflowNavigationTestDriver / onReceive hook and the testing-only initializer. Live in-flight transition coverage belongs in UI automation, noted inline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5eef730 to
4b3f47f
Compare
|
Reworked, and dropped the DEBUG navigation seam entirely. On the "are we covering the real-world navigation case" question: |
|
@vegaro simplified this one. it does not cover navigation, but still worth the test |

What Changed
onPurchaseStarted/Completed/Cancelled/Failure+ the restore variants) fire on the initial step and on a non-initial step.Notes
WorkflowPaywallViewkeeps a singlepurchaseHandlerabove the per-stepPaywallsV2Viewsubtrees that navigation swaps, so the listeners are step-independent by construction. Seeding the view at a non-initial step (viainitial_step_id) covers that without any test hook in production.#if DEBUGWorkflowNavigationTestDriver+.onReceiveseam I had. It drove a real transition but only asserted on the settled state, which the non-initial-step tests already cover, so it wasn't worth a permanent production hook.AI session context
AI Context
Metadata
Goal
Decide whether the original PR (DEBUG-only navigation test seam to verify purchase/restore callbacks survive workflow step transitions) was worth keeping, then make the PR mergeable.
Initial Prompt
"Let's check PR #6855. What do you think? Is it worth it? Or should we rethink this?" Followed by "How would that look" and "let's go, this is mergeable" — i.e. evaluate the approach, propose a stripped-down alternative, then implement and push it.
Important Follow-up Prompts
Agent Contribution
WorkflowPaywallView.swift:purchaseHandleris a single sharedletabove the swapped per-step subtrees, so callback wiring is step-independent.#if DEBUGproduction seam.origin/main, brought the PR's final test file in, trimmed it, and reverted all production changes.Human Decisions
Key Implementation Decisions
#if DEBUGWorkflowNavigationTestDriver,.onReceiveseam, and testing-only initializer; revertWorkflowPaywallView.swiftto matchmain(zero production diff).PurchaseHandlerfrom any rendered step without production test hooks.Files / Symbols Touched
Tests/RevenueCatUITests/PaywallsV2/WorkflowPaywallViewTests.swiftWorkflowPurchaseObserver(trimmed to public init),makeContextStartingAt(stepId:)(kept); removedWorkflowNavigationTestDriverusage,makeNavigableContext(), and...FiredAfterNavigating*tests.WorkflowPaywallViewinit and the sharedPurchaseHandler.RevenueCatUI/Templates/V2/WorkflowPaywallView.swiftmain(no production change in this PR).mainis empty.Dependencies / Config / Migrations
Validation
xcodebuild test -workspace RevenueCat-Tuist.xcworkspace -scheme RevenueCatUITests -destination 'platform=iOS Simulator,id=<iPhone 17 Pro, iOS 26>' -only-testing:RevenueCatUITests/WorkflowPaywallViewTests: Executed 46 tests, 0 failures. TEST SUCCEEDED.swiftlint(pre-commit hook on the test file): no violations.git diff origin/main -- RevenueCatUI/Templates/V2/WorkflowPaywallView.swift: empty (production untouched).Validation Gaps
WorkflowPaywallViewTestswas executed.Review Focus
WorkflowNavigationTestDriver/ testing-only init anywhere in the codebase.Risks / Reviewer Notes
letabove the swapped subtree.Non-goals / Out of Scope
Omitted Context