Skip to content

Commit

Permalink
StoreKitObserverModeIntegrationTests: fixed and disabled SK2 `testP…
Browse files Browse the repository at this point in the history
…urchaseInDevicePostsReceipt` (#2589)

Turns out this test was only passing because it was waiting for the
receipt to be posted during a renewal, not the initial purchase!
This updates the test to reflect the correct expectation (disabling
renewals), and added the `XCTExpectFailure` so we can detect if it
starts passing in a future iOS version.

Also changed the test to not use `customerInfo()` because of #2563.
  • Loading branch information
NachoSoto authored Jun 6, 2023
1 parent 18c10b4 commit 4b14260
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@ class StoreKit2ObserverModeIntegrationTests: StoreKit1ObserverModeIntegrationTes

@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
func testPurchaseInDevicePostsReceipt() async throws {
try await self.purchaseProductFromStoreKit()
let result = try await self.purchaseProductFromStoreKit()
let transaction = try XCTUnwrap(result.verificationResult?.underlyingTransaction)

try self.testSession.disableAutoRenewForTransaction(identifier: UInt(transaction.id))

XCTExpectFailure("This test currently does not pass (see FB12231111)")

try await asyncWait(
until: {
let entitlement = try? await Purchases.shared
.customerInfo(fetchPolicy: .fetchCurrent)
let entitlement = await self.purchasesDelegate
.customerInfo?
.entitlements[Self.entitlementIdentifier]

return entitlement?.isActive == true
},
timeout: .seconds(60),
pollInterval: .seconds(2),
timeout: .seconds(5),
pollInterval: .milliseconds(500),
description: "Entitlement didn't become active"
)
}
Expand Down

0 comments on commit 4b14260

Please sign in to comment.