diff --git a/QonversionTests/QonversionMapperTests.m b/QonversionTests/QonversionMapperTests.m index 0b23fd2e..085f1c67 100644 --- a/QonversionTests/QonversionMapperTests.m +++ b/QonversionTests/QonversionMapperTests.m @@ -9,6 +9,9 @@ #import "QONEntitlement.h" #import "QONLaunchResult.h" #import "QONProduct.h" +#import "QONRemoteConfig.h" +#import "QONRemoteConfigMapper.h" +#import "QONRemoteConfigurationSource.h" @interface QNMapperTests : XCTestCase @property (nonatomic, strong) NSDictionary *userInitSuccess; @@ -17,6 +20,30 @@ @interface QNMapperTests : XCTestCase @implementation QNMapperTests +- (void)testRemoteConfigMapperPreservesFrozenAssignmentProvenance { + NSDictionary *data = @{ + @"payload": @{}, + @"source": @{ + @"uid": @"rc-frozen", + @"name": @"Frozen config", + @"type": @"remote_configuration", + @"assignment_type": @"frozen", + @"context_key": @"" + } + }; + + QONRemoteConfig *config = [[[QONRemoteConfigMapper alloc] init] mapRemoteConfig:data]; + + XCTAssertNotNil(config.source); + XCTAssertEqual(config.source.assignmentType, QONRemoteConfigurationAssignmentTypeFrozen); +} + +- (void)testRemoteConfigAssignmentTypeKeepsExistingNumericValues { + XCTAssertEqual(QONRemoteConfigurationAssignmentTypeUnknown, -1); + XCTAssertEqual(QONRemoteConfigurationAssignmentTypeAuto, 0); + XCTAssertEqual(QONRemoteConfigurationAssignmentTypeManual, 1); +} + - (void)setUp { [super setUp]; diff --git a/Sources/Qonversion/Public/QONRemoteConfigurationSource.h b/Sources/Qonversion/Public/QONRemoteConfigurationSource.h index 070129a6..4209403d 100644 --- a/Sources/Qonversion/Public/QONRemoteConfigurationSource.h +++ b/Sources/Qonversion/Public/QONRemoteConfigurationSource.h @@ -13,7 +13,8 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, QONRemoteConfigurationAssignmentType) { QONRemoteConfigurationAssignmentTypeUnknown = -1, QONRemoteConfigurationAssignmentTypeAuto = 0, - QONRemoteConfigurationAssignmentTypeManual = 1 + QONRemoteConfigurationAssignmentTypeManual = 1, + QONRemoteConfigurationAssignmentTypeFrozen = 2 } NS_SWIFT_NAME(Qonversion.RemoteConfigurationAssignmentType); typedef NS_ENUM(NSInteger, QONRemoteConfigurationSourceType) { diff --git a/Sources/Qonversion/Public/QONRemoteConfigurationSource.m b/Sources/Qonversion/Public/QONRemoteConfigurationSource.m index 9eafe03a..8fbd21db 100644 --- a/Sources/Qonversion/Public/QONRemoteConfigurationSource.m +++ b/Sources/Qonversion/Public/QONRemoteConfigurationSource.m @@ -49,6 +49,9 @@ - (NSString *)prettyAssignmentType { case QONRemoteConfigurationAssignmentTypeManual: result = @"manual"; break; + + case QONRemoteConfigurationAssignmentTypeFrozen: + result = @"frozen"; break; default: result = @"unknown"; break; diff --git a/Sources/Qonversion/Qonversion/Mappers/QONRemoteConfigMapper/QONRemoteConfigMapper.m b/Sources/Qonversion/Qonversion/Mappers/QONRemoteConfigMapper/QONRemoteConfigMapper.m index 417cd607..6af4acc1 100644 --- a/Sources/Qonversion/Qonversion/Mappers/QONRemoteConfigMapper/QONRemoteConfigMapper.m +++ b/Sources/Qonversion/Qonversion/Mappers/QONRemoteConfigMapper/QONRemoteConfigMapper.m @@ -19,6 +19,7 @@ NSString *const kRemoteConfigurationAssignmentTypeAuto = @"auto"; NSString *const kRemoteConfigurationAssignmentTypeManual = @"manual"; +NSString *const kRemoteConfigurationAssignmentTypeFrozen = @"frozen"; NSString *const kRemoteConfigurationSourceTypeControlGroup = @"experiment_control_group"; NSString *const kRemoteConfigurationSourceTypeTreatmentGroup = @"experiment_treatment_group"; @@ -46,7 +47,8 @@ - (instancetype)init { _remoteConfigurationAssignmentTypes = @{ kRemoteConfigurationAssignmentTypeAuto: @(QONRemoteConfigurationAssignmentTypeAuto), - kRemoteConfigurationAssignmentTypeManual: @(QONRemoteConfigurationAssignmentTypeManual) + kRemoteConfigurationAssignmentTypeManual: @(QONRemoteConfigurationAssignmentTypeManual), + kRemoteConfigurationAssignmentTypeFrozen: @(QONRemoteConfigurationAssignmentTypeFrozen) }; _remoteConfigurationSourceTypes = @{