fix(storeapi): Expiration date never found on a subscribed product #327
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.
We observed during the attempt to integration testing with the WSL SAAS backend that we could never find the current subscription expiration date, even though we could clearly see that the user was subscribed to the product under test.
It turns out that, when iterating over the product
SKU
s, we had the broken assumptionIsSubscription() && IsInUserCollection()
.In this particular example the only SKU under user's possession doesn't show
IsSubscription
as true.Pre iteration loop (product is in user collection)
First SKU ( is subscription but not owned by the current user)
Second SKU (is owned by this user, but it's not a subscription 🙃 )
So with this PR I'm relaxing on checking whether the SKU
IsSubscription
when querying the expiration date.Also, this test raised the concern that it might be possible that a user may hold several SKUs of the same product (most likely one SKU will still be valid while others will be expired). Thus, I also changed the iteration to go over all SKUs found and return the greatest expiration date (the one most towards the future) instead of stopping the iteration on the first item found in user's collection.