Skip to content

Commit b0d5bed

Browse files
committed
additional tests
1 parent fcce2d2 commit b0d5bed

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

WooCommerce/WooCommerceTests/POS/POSNotificationSchedulerTests.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,46 @@ struct POSNotificationSchedulerTests {
260260
#expect(mockPushNotesManager.requestedLocalNotifications.isEmpty)
261261
}
262262

263+
@Test func scheduleLocalNotificationIfEligible_when_currentMerchant_already_scheduled_then_potentialMerchant_cannot_be_scheduled() async throws {
264+
// Given
265+
let siteSettings = sampleSiteSettings(countryCode: "US")
266+
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleSurveys] = true
267+
setupMockStores(isCurrentMerchantScheduled: true)
268+
269+
let scheduler = POSNotificationScheduler(
270+
stores: mockStores,
271+
siteSettings: siteSettings,
272+
featureFlagService: mockFeatureFlagService,
273+
pushNotificationsManager: mockPushNotesManager
274+
)
275+
276+
// When
277+
await scheduler.scheduleLocalNotificationIfEligible(for: .potentialMerchant)
278+
279+
// Then - No notification should be scheduled. Prevents backwards conversion from 'current' to 'potential' merchant.
280+
#expect(mockPushNotesManager.requestedLocalNotifications.isEmpty)
281+
}
282+
283+
@Test func scheduleLocalNotificationIfEligible_when_potentialMerchant_already_scheduled_then_does_not_duplicate_notification() async throws {
284+
// Given
285+
let siteSettings = sampleSiteSettings(countryCode: "US")
286+
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleSurveys] = true
287+
setupMockStores(isPotentialMerchantScheduled: true)
288+
289+
let scheduler = POSNotificationScheduler(
290+
stores: mockStores,
291+
siteSettings: siteSettings,
292+
featureFlagService: mockFeatureFlagService,
293+
pushNotificationsManager: mockPushNotesManager
294+
)
295+
296+
// When
297+
await scheduler.scheduleLocalNotificationIfEligible(for: .potentialMerchant)
298+
299+
// Then - No duplicate notification should be scheduled
300+
#expect(mockPushNotesManager.requestedLocalNotifications.isEmpty)
301+
}
302+
263303
private func sampleSiteSettings(countryCode: String) -> [SiteSetting] {
264304
[
265305
SiteSetting.fake().copy(

0 commit comments

Comments
 (0)