test(caching): cover workflow metadata disk round-trip#3640
Merged
vegaro merged 1 commit intoJun 23, 2026
Merged
Conversation
Adds a serialization round-trip test for LocalTransactionMetadata.workflowMetadata, mirroring the existing `handles paywall data` test: the JSON written to SharedPreferences is captured and fed back to getLocalTransactionMetadata, so the real encode/decode runs (only SharedPreferences I/O is mocked). This guards the fix in b2bfd86, where workflowId/stepId were @transient and lost on the disk round-trip. Verified RED->GREEN: with the field marked @transient the test fails at the assertion; with @SerialName("workflow_metadata") it passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YT7tYKySCS7wAHEmXjQEaf
9dd8610
into
cesar/receipt-presented-paywall-workflow-ids
33 of 34 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Follow-up test coverage for #3603. That PR's refactor commit (
b2bfd86) fixed a bug whereworkflowId/stepIdwere@Transienton the cached transaction metadata and were lost on the disk round-trip, sopresented_workflow_id/presented_step_idwould be sent asnullon retry or unsynced replay. The field was promoted to a first-classworkflowMetadataonLocalTransactionMetadatawith@SerialName("workflow_metadata"), but there was no regression test asserting it actually survives serialization.What this adds
One test in
LocalTransactionMetadataStoreTest,cacheLocalTransactionMetadata round-trips workflow metadata, mirroring the existinghandles paywall datatest. The JSON written toSharedPreferencesis captured and fed back togetLocalTransactionMetadata, so the realJsonTools.jsonencode/decode runs (only SharedPreferences I/O is mocked).Verification (RED → GREEN)
workflowMetadatamarked@Transient, the test fails at the assertion (retrieved?.workflowMetadataisnull).@SerialName("workflow_metadata")(current state), it passes.Ran
:purchases:testDefaultsBc8DebugUnitTest --tests "...LocalTransactionMetadataStoreTest"locally (JDK 21).Companion to #3636 (which covers the
PostReceiptHelperthreading and replay paths). Together they close the two test gaps identified in review of #3603.AI session context
Task: Review #3603 ("is anything missing?"), then close the identified test gaps.
Findings from review of #3603:
workflowMetadatauntested, the exact bugb2bfd86fixed.LocalTransactionMetadataStoreTesthad the analogoushandles paywall dataround-trip test but nothing forworkflowMetadata.PostReceiptHelperthreading untested (only anany()count bumped). → covered by test(receipts): cover PostReceiptHelper workflow metadata resolution #3636.This PR addresses finding #1.
Decisions:
@Transientregression.cesar/receipt-presented-paywall-workflow-idsbecause theworkflowMetadatafield only exists there, not onmain.Verified: RED→GREEN as described above. Production code (
LocalTransactionMetadata.kt) left unchanged; only the test file is added.Not done: The remaining review items on #3603 were questions, not test gaps (all-or-nothing
WorkflowMetadata.from, impression/purchase step-id divergence under dedup,pr:othervspr:fixlabel). Not addressed here.🤖 Generated with Claude Code
Note
Low Risk
Test-only change with no runtime behavior modifications.
Overview
Adds a regression test in
LocalTransactionMetadataStoreTestsoworkflowMetadataon cached local transaction metadata survives the same SharedPreferences JSON encode/decode path used in production.The test mirrors the existing paywall round-trip pattern: capture the JSON written on cache, feed it back on read, and assert
workflowId/stepIdare unchanged. It is meant to catch a prior failure mode where workflow fields were not persisted (e.g.@Transient), which would droppresented_workflow_id/presented_step_idon retry or replay.No production code changes in this PR—test coverage only.
Reviewed by Cursor Bugbot for commit 87b6234. Bugbot is set up for automated code reviews on this repo. Configure here.