diff --git a/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeAsyncParallelBailHook1.kt b/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeAsyncParallelBailHook1.kt index a5baf3196..ea8a74fc3 100644 --- a/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeAsyncParallelBailHook1.kt +++ b/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeAsyncParallelBailHook1.kt @@ -4,10 +4,8 @@ import com.intuit.hooks.AsyncParallelBailHook import com.intuit.hooks.BailResult import com.intuit.hooks.HookContext import com.intuit.playerui.core.bridge.Node -import com.intuit.playerui.core.bridge.NodeWrapper import com.intuit.playerui.core.bridge.serialization.serializers.NodeWrapperSerializer import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.runBlocking import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable @@ -32,4 +30,4 @@ public class NodeAsyncParallelBailHook1(override val node: Node, se internal class Serializer(private val serializer1: KSerializer, `_`: KSerializer) : NodeWrapperSerializer>({ NodeAsyncParallelBailHook1(it, serializer1) }) -} \ No newline at end of file +} diff --git a/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeHook.kt b/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeHook.kt index 1cfe02341..0d344e04c 100644 --- a/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeHook.kt +++ b/jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeHook.kt @@ -4,19 +4,18 @@ import com.intuit.hooks.HookContext import com.intuit.playerui.core.bridge.Invokable import com.intuit.playerui.core.bridge.Node import com.intuit.playerui.core.bridge.NodeWrapper +import com.intuit.playerui.core.bridge.Promise import com.intuit.playerui.core.bridge.getInvokable import com.intuit.playerui.core.utils.InternalPlayerApi import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.KSerializer import kotlinx.serialization.descriptors.capturedKClass -import com.intuit.playerui.core.bridge.Promise /** Contains common logic for configuring a [NodeHook] to tap any JS hook */ internal interface NodeHook : NodeWrapper { @OptIn(ExperimentalSerializationApi::class) fun init(vararg serializers: KSerializer<*>) { - println("NodeHook initialized with node: $node") node.getInvokable("tap")?.invoke( mapOf("name" to "name", "context" to true), Invokable { args -> diff --git a/jvm/core/src/test/kotlin/com/intuit/playerui/core/bridge/PromiseTest.kt b/jvm/core/src/test/kotlin/com/intuit/playerui/core/bridge/PromiseTest.kt index 99b0c6e8e..c164b7d1e 100644 --- a/jvm/core/src/test/kotlin/com/intuit/playerui/core/bridge/PromiseTest.kt +++ b/jvm/core/src/test/kotlin/com/intuit/playerui/core/bridge/PromiseTest.kt @@ -8,8 +8,10 @@ import com.intuit.playerui.core.player.state.PlayerFlowState import com.intuit.playerui.utils.normalizeStackTraceElements import com.intuit.playerui.utils.test.PromiseUtils import com.intuit.playerui.utils.test.RuntimeTest +import com.intuit.player.jvm.utils.test.runBlockingTest import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking +import kotlinx.serialization.builtins.serializer import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put @@ -219,4 +221,27 @@ internal class PromiseTest : RuntimeTest(), PromiseUtils { assertEquals(exception.message, caught.message) assertEquals(exception.stackTrace.normalizeStackTraceElements(), caught.stackTrace.normalizeStackTraceElements()) } + + @TestTemplate + fun testPromiseConstructor() = runBlockingTest { + runtime.execute( + """ + class TestClass { + name = 'foo'; + constructor(promise) { + promise.then((value) => { + this.name = value; + }); + }; + }""", + ) + val promise = runtime.Promise { jsRes, _ -> + val result = "bar" + jsRes(result) + } + runtime.add("myPromise", promise) + val value = runtime.execute("new TestClass(myPromise)") as Node + promise.toCompletable(String.serializer()).await() + assertEquals("bar", value["name"]) + } } diff --git a/plugins/async-node/jvm/deps.bzl b/plugins/async-node/jvm/deps.bzl index 2a433e136..e461ebca2 100644 --- a/plugins/async-node/jvm/deps.bzl +++ b/plugins/async-node/jvm/deps.bzl @@ -1,14 +1,9 @@ -maven = [ - "com.intuit.player:core-bridge:1.0.0", -] - main_exports = [ "//jvm/core", ] main_deps = main_exports + [ "//jvm:kotlin_serialization", - "//plugins/set-time-out/jvm:set-time-out", ] main_resources = [ diff --git a/plugins/async-node/jvm/src/test/kotlin/com/intuit/playerui/plugins/asyncnode/AsyncNodePluginTest.kt b/plugins/async-node/jvm/src/test/kotlin/com/intuit/playerui/plugins/asyncnode/AsyncNodePluginTest.kt index 5477b7d4f..fb30efa76 100644 --- a/plugins/async-node/jvm/src/test/kotlin/com/intuit/playerui/plugins/asyncnode/AsyncNodePluginTest.kt +++ b/plugins/async-node/jvm/src/test/kotlin/com/intuit/playerui/plugins/asyncnode/AsyncNodePluginTest.kt @@ -138,7 +138,7 @@ internal class AsyncNodePluginTest : PlayerTest() { player.start(asyncNodeFlowSimple) } Assertions.assertTrue(count == 2) - Assertions.assertTrue((update?.get("actions") as List<*>).size == 3) + Assertions.assertEquals(3, update?.getList("actions")?.size) } @TestTemplate @@ -153,9 +153,11 @@ internal class AsyncNodePluginTest : PlayerTest() { 2 -> { Assertions.assertEquals(1, (asset?.get("actions") as List<*>).size) } + 3 -> { Assertions.assertEquals(2, (asset?.get("actions") as List<*>).size) } + 4 -> { Assertions.assertEquals(4, (asset?.get("actions") as List<*>).size) } @@ -180,6 +182,7 @@ internal class AsyncNodePluginTest : PlayerTest() { ), ), ) + 2 -> BailResult.Bail( listOf( mapOf( @@ -195,6 +198,7 @@ internal class AsyncNodePluginTest : PlayerTest() { ), ), ) + else -> BailResult.Bail( listOf( mapOf(