Skip to content

Commit c9d37e4

Browse files
authored
Merge pull request #1102 from OneSignal/tests/fix_flaky_outcome_integration_test
[Tests] Fix flaky testUnattributedSession_afterAllNotificationsPastAttributionWindow
2 parents 2c1cda2 + ed9541d commit c9d37e4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

iOS_SDK/OneSignalSDK/UnitTests/OutcomeIntegrationTests.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,18 @@ - (void)testUnattributedSession_afterAllNotificationsPastAttributionWindow {
347347

348348
// 2. Close the app for 31 seconds
349349
[UnitTestCommonMethods backgroundApp];
350+
[UnitTestCommonMethods runBackgroundThreads];
350351
[NSDateOverrider advanceSystemTimeBy:31];
351352

352353
// 3. Receive 1 notification in background
353354
[UnitTestCommonMethods receiveNotification:@"test_notification_1" wasOpened:NO];
355+
[UnitTestCommonMethods runBackgroundThreads];
354356

355357
// 4. Open app
356-
[UnitTestCommonMethods initOneSignal_andThreadWaitWithForeground];
358+
[UnitTestCommonMethods foregroundApp];
359+
[UnitTestCommonMethods runBackgroundThreads];
357360

358-
// 5. Make sure NOTIFICATION influence is DIRECT and has 1 notification
361+
// 5. Make sure NOTIFICATION influence is INDIRECT and has 1 notification
359362
NSArray<OSInfluence *> *sessionInfluences = [[OSSessionManager sharedSessionManager] getInfluences];
360363
for (OSInfluence *influence in sessionInfluences) {
361364
switch (influence.influenceChannel) {
@@ -375,6 +378,7 @@ - (void)testUnattributedSession_afterAllNotificationsPastAttributionWindow {
375378

376379
// 7. Open app
377380
[UnitTestCommonMethods foregroundApp];
381+
[UnitTestCommonMethods runBackgroundThreads];
378382

379383
// 8. Make sure all influences are UNATTRIBUTED and has 0 notifications
380384
sessionInfluences = [[OSSessionManager sharedSessionManager] getInfluences];

0 commit comments

Comments
 (0)