Skip to content

TrialOrIntroPriceEligibilityChecker: fixed integration test to ensure receipt is always loaded#1726

Merged
NachoSoto merged 1 commit into
mainfrom
sk1-trial-eligibility-checker-fix
Jun 23, 2022
Merged

TrialOrIntroPriceEligibilityChecker: fixed integration test to ensure receipt is always loaded#1726
NachoSoto merged 1 commit into
mainfrom
sk1-trial-eligibility-checker-fix

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Jun 21, 2022

Copy link
Copy Markdown
Contributor

The reason the receipt data is required, is because if it's nil, it ends up becoming empty because of data ?? Data(), but GetIntroEligibilityOperation never actually runs because that's empty.

To make sure the test doesn't fail, we begin by ensuring the receipt data is loaded first.

Also documented the reason for ReceiptRefreshPolicy.never.

@NachoSoto NachoSoto added the bug label Jun 21, 2022
@NachoSoto NachoSoto requested a review from a team June 21, 2022 22:18
@NachoSoto NachoSoto force-pushed the sk1-trial-eligibility-checker-fix branch from 057936a to c90c1cc Compare June 21, 2022 22:25

@taquitos taquitos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯 🐐

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @aboedo any reason why this should be .never?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sadly.
refreshing here will likely prompt the user for their credentials, and intro eligibility should be triggered programmatically.

In theory, this should only be a problem in sandbox, but I have a vague recollection of having moved to never after this caused a lot of customer confusion and headaches

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh that's right.
This test failure exposed a real issue, but considering this is for pre-iOS 15 only, and that downside, maybe we should leave it as .never, but I'll change the test to force a receipt refresh.

How does that sound?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes total sense.

Also, would you mind adding what I explained as a comment? Your question about why this should be .never is very valid and there's no reason maintainers should know the explanation before seeing this code, I should have added a comment myself when adding the .never 🤦

@NachoSoto NachoSoto force-pushed the sk1-trial-eligibility-checker-fix branch from c90c1cc to 3795091 Compare June 22, 2022 17:31
@NachoSoto NachoSoto changed the title TrialOrIntroPriceEligibilityChecker: fixed SK1 logic TrialOrIntroPriceEligibilityChecker: refresh receipts in sandbox Jun 22, 2022
@NachoSoto NachoSoto requested a review from aboedo June 22, 2022 17:31
@NachoSoto

Copy link
Copy Markdown
Contributor Author

@aboedo I've updated this:

  • Change implementation to only sandbox
  • Added docs
  • Added a unit test to cover this

Because Integration Tests aren't detecting "sandbox" I still need those tests separately.

NachoSoto added a commit that referenced this pull request Jun 22, 2022
For some reason the url is `[app_bundle]/StoreKit/receipt` in integration tests.
This is not correct, so I've added a couple of tests: one for entitlements, and another one to check the raw output value of that property.

This is necessary to make sure that receipts are loaded correctly after #1726.
NachoSoto added a commit that referenced this pull request Jun 22, 2022
For some reason the url is `[app_bundle]/StoreKit/receipt` in integration tests.
This is not correct, so I've added a couple of tests: one for entitlements, and another one to check the raw output value of that property.

This is necessary to make sure that receipts are loaded correctly after #1726.
@NachoSoto NachoSoto force-pushed the sk1-trial-eligibility-checker-fix branch from 3795091 to ac26c62 Compare June 22, 2022 18:39

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just rebased. Integration tests will use this now :)

@NachoSoto

Copy link
Copy Markdown
Contributor Author

All tests passing 🎉

@NachoSoto NachoSoto force-pushed the sk1-trial-eligibility-checker-fix branch from ac26c62 to b1c2790 Compare June 23, 2022 20:52
@NachoSoto NachoSoto changed the title TrialOrIntroPriceEligibilityChecker: refresh receipts in sandbox TrialOrIntroPriceEligibilityChecker: fixed integration test to ensure receipt is always loaded Jun 23, 2022
@NachoSoto NachoSoto requested a review from taquitos June 23, 2022 20:53
@NachoSoto NachoSoto force-pushed the sk1-trial-eligibility-checker-fix branch from b1c2790 to bdec362 Compare June 23, 2022 20:53
The reason the receipt data is required, is because if it's `nil`, it ends up becoming empty because of `data ?? Data()`, but `GetIntroEligibilityOperation` never actually runs because that's empty.
@NachoSoto NachoSoto force-pushed the sk1-trial-eligibility-checker-fix branch from bdec362 to 711da9e Compare June 23, 2022 20:54
@NachoSoto NachoSoto merged commit e1d1a2b into main Jun 23, 2022
@NachoSoto NachoSoto deleted the sk1-trial-eligibility-checker-fix branch June 23, 2022 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants