Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Tests: prevent false positives when purchasing returns 5xx #3209

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented Sep 14, 2023

Good news: offline entitlements are amazing, and our SDK is very resilient to the backend being down.
Bad news: this is kind of a false positive, this behavior is already verified by OfflineStoreKitIntegrationTests.

I refactored BaseStoreKitIntegrationTests because it had grown a lot. I put this verification in the purchase methods so all tests benefit from this.

So that OfflineStoreKitIntegrationTests don't fail, I added a parameter to ignore that verification in those tests.

@NachoSoto NachoSoto added the test label Sep 14, 2023
@NachoSoto NachoSoto requested a review from a team September 14, 2023 17:43
Comment on lines +137 to +163
func verifyCustomerInfoWasComputedOffline(
logger: TestLogHandler? = nil,
file: FileString = #file,
line: UInt = #line
) {
let logger: TestLogHandler = logger ?? self.logger
logger.verifyMessageWasLogged(
Strings.offlineEntitlements.computing_offline_customer_info,
level: .info,
file: file,
line: line
)
}

func verifyCustomerInfoWasNotComputedOffline(
logger: TestLogHandler? = nil,
file: FileString = #file,
line: UInt = #line
) {
let logger: TestLogHandler = logger ?? self.logger

logger.verifyMessageWasNotLogged(
Strings.offlineEntitlements.computing_offline_customer_info,
file: file,
line: line
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are the new methods

self.verifyNoTransactionsWereFinished()
}

@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
func testPurchaseWhileServerIsDownPostsReceiptAfterServerComesBack() async throws {
self.logger.clearMessages()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Small improvement in this test. The verifyNoTransactionsWereFinished was being affected by leftover transaction before the test started.

@NachoSoto NachoSoto force-pushed the paywalls branch 2 times, most recently from 831bc21 to 66b5048 Compare September 14, 2023 20:37
@NachoSoto NachoSoto force-pushed the integration-tests-false-positive-5xx branch from e30660c to aa6582b Compare September 14, 2023 23:52
@NachoSoto NachoSoto changed the base branch from paywalls to integration-test-flaky-failures-3 September 14, 2023 23:52
Base automatically changed from integration-test-flaky-failures-3 to paywalls September 15, 2023 00:08
@NachoSoto NachoSoto changed the base branch from paywalls to main September 15, 2023 17:03
@NachoSoto NachoSoto force-pushed the integration-tests-false-positive-5xx branch from aa6582b to 967861c Compare September 15, 2023 17:03
@NachoSoto NachoSoto enabled auto-merge (squash) September 15, 2023 17:04
Good news: offline entitlements are amazing, and our SDK is very resilient to the backend being down.
Bad news: this is kind of a false positive, this behavior is already verified by `OfflineStoreKitIntegrationTests`.

I refactored `BaseStoreKitIntegrationTests` because it had grown a lot.
I put this verification in the `purchase` methods so all tests benefit from this.

So that `OfflineStoreKitIntegrationTests` doesn't fail, I added a parameter to ignore those there.
@NachoSoto NachoSoto force-pushed the integration-tests-false-positive-5xx branch from 967861c to 0850d71 Compare September 15, 2023 19:32
@NachoSoto NachoSoto merged commit 18ad735 into main Sep 18, 2023
19 checks passed
@NachoSoto NachoSoto deleted the integration-tests-false-positive-5xx branch September 18, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants