Skip to content

Commit 68c1066

Browse files
committed
fix: Flakey test testLoggingCommerceEventToUpload
1 parent bb4dd76 commit 68c1066

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

UnitTests/ObjCTests/MPBackendControllerTests.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,16 @@ - (void)testLoggingCommerceEvent {
641641
}
642642

643643
- (void)testLoggingCommerceEventToUpload {
644+
// Ensure upgrade date is set by simulating an app upgrade BEFORE session begins
645+
MPApplication_PRIVATE *application = [[MPApplication_PRIVATE alloc] init];
646+
application.storedVersion = @"1.0.0"; // Set a different version to trigger upgrade detection
647+
[MPApplication_PRIVATE updateLaunchCountsAndDates]; // This will set the upgrade date
648+
644649
dispatch_sync([MParticle messageQueue], ^{
645650
[self.backendController beginSession];
646651
});
647652
self.session = self.backendController.session;
653+
648654
MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] initWithAction:MPCommerceEventActionClick];
649655
commerceEvent.customAttributes = @{@"key":@"value"};
650656

0 commit comments

Comments
 (0)