Skip to content

Commit ab998e5

Browse files
committed
Fix testInAppMessageDisplayMultipleTimes_sessionDurationTrigger flakyness
* Fixed flakyness by adding Awaitility to size check and increasing wait up to time on another size assert.
1 parent 471d433 commit ab998e5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

OneSignalSDK/unittest/src/test/java/com/test/onesignal/InAppMessageIntegrationTests.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,15 @@ public void testInAppMessageDisplayMultipleTimes_sessionDurationTrigger() throws
13401340
threadAndTaskWait();
13411341

13421342
// No schedule should happen, IAM should evaluate to true
1343-
assertEquals(1, OneSignalPackagePrivateHelper.getInAppMessageDisplayQueue().size());
1343+
Awaitility.await()
1344+
.atMost(new Duration(1_000, TimeUnit.MILLISECONDS))
1345+
.pollInterval(new Duration(10, TimeUnit.MILLISECONDS))
1346+
.untilAsserted(new ThrowingRunnable() {
1347+
@Override
1348+
public void run() throws Exception {
1349+
assertEquals(1, OneSignalPackagePrivateHelper.getInAppMessageDisplayQueue().size());
1350+
}
1351+
});
13441352

13451353
// After IAM is added to display queue we now need to wait until it is shown
13461354
Awaitility.await()
@@ -1378,7 +1386,7 @@ public void run() throws Exception {
13781386
// No schedule should happen since session time period is very small, should evaluate to true on first run
13791387
// Wait for redisplay logic
13801388
Awaitility.await()
1381-
.atMost(new Duration(150, TimeUnit.MILLISECONDS))
1389+
.atMost(new Duration(1_000, TimeUnit.MILLISECONDS))
13821390
.pollInterval(new Duration(10, TimeUnit.MILLISECONDS))
13831391
.untilAsserted(new ThrowingRunnable() {
13841392
@Override

0 commit comments

Comments
 (0)