From 69e31682aaeffd510f9ef9ad0fba906e0f46b2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Tue, 5 Nov 2024 15:49:11 +0100 Subject: [PATCH] [JS] Fix getMemberships ignoring `uuid` parameter --- .../test/integration/MembershipsTest.kt | 19 +++++++++++++++++++ .../pubnub/test/integration/PublishTest.kt | 3 ++- .../kotlin/com/pubnub/api/PubNubImpl.kt | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt index f42fb4f2f..a87c331ba 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt @@ -41,6 +41,25 @@ class MembershipsTest : BaseIntegrationTest() { assertEquals(customData, pnChannelDetails.custom?.value) } + @Test + fun can_set_and_get_memberships_for_other_uuid() = runTest { + // when + val userId = "some-user-" + randomString() + pubnub.setMemberships( + channels = listOf(PNChannelMembership.Partial(channel, custom, status)), + uuid = userId, + includeCustom = includeCustom, + includeChannelDetails = PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + ).await() + + val result = pubnub.getMemberships(uuid = userId, filter = "channel.id == '$channel'", includeCustom = true).await() + + // then + val pnChannelDetails = result.data.single { it.channel.id == channel } + assertEquals(channel, pnChannelDetails.channel.id) + assertEquals(customData, pnChannelDetails.custom?.value) + } + @Test fun can_receive_set_membership_event() = runTest { pubnub.test(backgroundScope) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt index 495e90ebb..1b7a81b53 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt @@ -11,6 +11,7 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.kmp.PLATFORM import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await +import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest import kotlin.js.JsExport @@ -27,7 +28,7 @@ data class ABC( ) class PublishTest : BaseIntegrationTest() { - private val channel = "myChannel" + private val channel = "myChannel" + randomString() @Test fun can_publish_message_string() = diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 85d0fd844..c7a12d821 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -676,6 +676,7 @@ class PubNubImpl(val jsPubNub: PubNubJs) : PubNub { return GetMembershipsImpl( jsPubNub, createJsObject { + uuid?.let { this.uuid = it } this.sort = sort.toJsMap() this.filter = filter this.page = page.toMetadataPage()