-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Paywalls
: automatically flush events
This uses the new `Delay.long` (#3168) to flush events on app foreground. Also added more tests.
- Loading branch information
Showing
9 changed files
with
121 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,6 @@ actor PaywallEventsManager: PaywallEventsManagerType { | |
} | ||
} | ||
|
||
static let defaultEventFlushCount = 50 | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
41 changes: 41 additions & 0 deletions
41
Tests/UnitTests/Paywalls/Events/PurchasesPaywallEventsTests.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Copyright RevenueCat Inc. All Rights Reserved. | ||
// | ||
// Licensed under the MIT License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://opensource.org/licenses/MIT | ||
// | ||
// PurchasesPaywallEventsTests.swift | ||
// | ||
// Created by Nacho Soto on 9/8/23. | ||
|
||
import Nimble | ||
import StoreKit | ||
import XCTest | ||
|
||
@testable import RevenueCat | ||
|
||
@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *) | ||
class PurchasesPaywallEventsTests: BasePurchasesTests { | ||
|
||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
|
||
try AvailabilityChecks.iOS15APIAvailableOrSkipTest() | ||
|
||
self.setupPurchases() | ||
} | ||
|
||
func testApplicationWillEnterForegroundSendsEvents() async throws { | ||
self.notificationCenter.fireNotifications() | ||
|
||
let manager = try self.mockPaywallEventsManager | ||
|
||
try await asyncWait { await manager.invokedFlushEvents == true } | ||
|
||
expect(self.mockOperationDispatcher.invokedDispatchAsyncOnWorkerThreadDelayParam) == .long | ||
} | ||
|
||
} |