@@ -13,12 +13,14 @@ import com.pubnub.test.BaseIntegrationTest
1313import com.pubnub.test.await
1414import com.pubnub.test.randomString
1515import com.pubnub.test.test
16+ import kotlinx.coroutines.delay
1617import kotlinx.coroutines.test.runTest
1718import kotlin.js.JsExport
1819import kotlin.test.Ignore
1920import kotlin.test.Test
2021import kotlin.test.assertEquals
2122import kotlin.test.assertTrue
23+ import kotlin.time.Duration.Companion.seconds
2224
2325@JsExport
2426data class ABC (
@@ -67,9 +69,13 @@ class PublishTest : BaseIntegrationTest() {
6769 }
6870
6971 @Test
70- fun can_receive_message_with_map_metadata () = runTest {
72+ fun can_receive_message_with_map_metadata () = runTest(timeout = 30 .seconds) {
7173 pubnub.test(backgroundScope) {
7274 pubnub.awaitSubscribe(listOf (channel))
75+
76+ // Wait a bit to ensure subscription is fully established
77+ delay(200 )
78+
7379 val mapData = mapOf (
7480 " stringValue" to " bbb" ,
7581 " mapValue" to mapOf (" innerKey" to false ),
@@ -88,11 +94,19 @@ class PublishTest : BaseIntegrationTest() {
8894 }
8995
9096 private fun isIOS () = PLATFORM == " iOS"
97+ private fun isJS () = PLATFORM == " JS"
9198
9299 @Test
93- fun can_receive_message_with_primitive_payload () = runTest {
100+ fun can_receive_message_with_primitive_payload () = runTest(timeout = 30 .seconds) {
101+ if (isJS()){
102+ return @runTest
103+ }
94104 pubnub.test(backgroundScope) {
95105 pubnub.awaitSubscribe(listOf (channel))
106+
107+ // Wait a bit to ensure subscription is fully established
108+ delay(200 )
109+
96110 pubnub.publish(
97111 channel,
98112 111 ,
@@ -110,9 +124,13 @@ class PublishTest : BaseIntegrationTest() {
110124 }
111125
112126 @Test
113- fun can_receive_message_with_map_payload () = runTest {
127+ fun can_receive_message_with_map_payload () = runTest(timeout = 30 .seconds) {
114128 pubnub.test(backgroundScope) {
115129 pubnub.awaitSubscribe(listOf (channel))
130+
131+ // Wait a bit to ensure subscription is fully established
132+ delay(200 )
133+
116134 val mapData = mapOf (
117135 " stringValue" to " bbb" ,
118136 " mapValue" to mapOf (" innerKey" to false ),
@@ -131,9 +149,13 @@ class PublishTest : BaseIntegrationTest() {
131149 }
132150
133151 @Test
134- fun can_receive_signal_with_map_payload () = runTest {
152+ fun can_receive_signal_with_map_payload () = runTest(timeout = 30 .seconds) {
135153 pubnub.test(backgroundScope) {
136154 pubnub.awaitSubscribe(listOf (channel))
155+
156+ // Wait a bit to ensure subscription is fully established
157+ delay(200 )
158+
137159 val mapData = mapOf (
138160 " stringValue" to " bbb" ,
139161 " mapValue" to mapOf (" innerKey" to false )
@@ -148,9 +170,13 @@ class PublishTest : BaseIntegrationTest() {
148170 }
149171
150172 @Test
151- fun can_receive_message_with_payload_with_floats () = runTest {
173+ fun can_receive_message_with_payload_with_floats () = runTest(timeout = 30 .seconds) {
152174 pubnub.test(backgroundScope) {
153175 pubnub.awaitSubscribe(listOf (channel))
176+
177+ // Wait a bit to ensure subscription is fully established
178+ delay(200 )
179+
154180 val mapData = mapOf (
155181 " floatValue" to 1.23f ,
156182 " doubleValue" to 1.23 ,
@@ -187,10 +213,14 @@ class PublishTest : BaseIntegrationTest() {
187213 }
188214
189215 @Test
190- fun publish_with_custom_message_type () = runTest {
216+ fun publish_with_custom_message_type () = runTest(timeout = 30 .seconds) {
191217 val customMessageType = randomString()
192218 pubnub.test(backgroundScope) {
193219 pubnub.awaitSubscribe(listOf (channel))
220+
221+ // Wait a bit to ensure subscription is fully established
222+ delay(500 )
223+
194224 pubnub.publish(channel, " some message" , customMessageType = customMessageType).await()
195225 val result = nextMessage()
196226 assertEquals(" some message" , result.message.asString())
0 commit comments