Skip to content

Commit

Permalink
feat(multi-id): changeMerchantId should not clear predict only contac…
Browse files Browse the repository at this point in the history
…t when predict was not enabled

SUITEDEV-35599

Co-authored-by: megamegax <[email protected]>
  • Loading branch information
matusekma and megamegax committed May 3, 2024
1 parent 6a750ce commit 07c39ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,17 +584,31 @@ class DefaultConfigInternalTest : AnnotationSpec() {
configInternal.changeMerchantId(MERCHANT_ID, null)

FeatureRegistry.isFeatureEnabled(InnerFeature.PREDICT) shouldBe true
verify(mockPredictRequestContext).merchantId = MERCHANT_ID
}

@Test
fun testChangeMerchantId_whenMobileEngageDisabled_shouldClearContact() {
fun testChangeMerchantId_whenMobileEngageDisabled_andPredictEnabled_shouldEnablePredict_andShouldClearPredictOnlyContact() {
FeatureRegistry.enableFeature(InnerFeature.PREDICT)

configInternal.changeMerchantId(MERCHANT_ID, null)

FeatureRegistry.isFeatureEnabled(InnerFeature.PREDICT) shouldBe true
verify(mockPredictRequestContext).merchantId = MERCHANT_ID
verify(mockPredictInternal).clearPredictOnlyContact(null)
verifyNoInteractions(mockMobileEngageInternal)
}

@Test
fun testChangeMerchantId_whenMobileEngageDisabled_andPredictDisabled_shouldEnablePredict_andShouldNotClearContact() {
configInternal.changeMerchantId(MERCHANT_ID, null)

FeatureRegistry.isFeatureEnabled(InnerFeature.PREDICT) shouldBe true
verify(mockPredictRequestContext).merchantId = MERCHANT_ID
verifyNoInteractions(mockPredictInternal)
verifyNoInteractions(mockMobileEngageInternal)
}

@Test
fun testChangeMerchantId_whenMobileEngageEnabled_shouldClearContact() {
val latch = CountDownLatch(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ class DefaultConfigInternal(
}

override fun changeMerchantId(merchantId: String?, completionListener: CompletionListener?) {
predictRequestContext.merchantId = merchantId
if (FeatureRegistry.isFeatureEnabled(InnerFeature.MOBILE_ENGAGE)) {
mobileEngageInternal.clearContact(null)
predictInternal.clearVisitorId()
} else {
} else if (FeatureRegistry.isFeatureEnabled(InnerFeature.PREDICT)) {
predictInternal.clearPredictOnlyContact(null)
}
predictRequestContext.merchantId = merchantId
if (merchantId == null) {
FeatureRegistry.disableFeature(InnerFeature.PREDICT)
} else {
Expand Down

0 comments on commit 07c39ac

Please sign in to comment.