From 3382a4c4955ac72c7985397a5ab1d70a34493b3e Mon Sep 17 00:00:00 2001 From: Chloe Han Date: Fri, 20 Sep 2024 17:19:25 -0400 Subject: [PATCH 1/5] revert async node flatten --- core/player/src/view/resolver/index.ts | 17 ++--------------- plugins/async-node/core/src/index.test.ts | 18 +++++++++--------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/core/player/src/view/resolver/index.ts b/core/player/src/view/resolver/index.ts index 72968f9a5..12e59977c 100644 --- a/core/player/src/view/resolver/index.ts +++ b/core/player/src/view/resolver/index.ts @@ -12,11 +12,7 @@ import { DependencyModel, withParser } from "../../data"; import type { Logger } from "../../logger"; import type { Node } from "../parser"; import { NodeType } from "../parser"; -import { - caresAboutDataChanges, - toNodeResolveOptions, - unpackAndPush, -} from "./utils"; +import { caresAboutDataChanges, toNodeResolveOptions } from "./utils"; import type { Resolve } from "./types"; import { getNodeID } from "../parser/utils"; @@ -412,16 +408,7 @@ export class Resolver { ); if (mTree.value !== undefined && mTree.value !== null) { - if ( - mTree.node.parent?.type === NodeType.MultiNode && - Array.isArray(mTree.value) - ) { - mTree.value.forEach((v: any) => { - unpackAndPush(v, childValue); - }); - } else { - childValue.push(mTree.value); - } + childValue.push(mTree.value); } mTree.dependencies.forEach((bindingDep) => diff --git a/plugins/async-node/core/src/index.test.ts b/plugins/async-node/core/src/index.test.ts index c60c4e050..65a9e7f10 100644 --- a/plugins/async-node/core/src/index.test.ts +++ b/plugins/async-node/core/src/index.test.ts @@ -335,8 +335,8 @@ describe("view", () => { ?.lastUpdate; expect(view?.actions[0].asset.type).toBe("action"); - expect(view?.actions[1].asset.type).toBe("text"); - expect(view?.actions[2].asset.type).toBe("text"); + expect(view?.actions[1][0].asset.type).toBe("text"); + expect(view?.actions[1][1].asset.type).toBe("text"); }); test("replaces async nodes with chained multiNodes", async () => { @@ -400,7 +400,7 @@ describe("view", () => { ?.lastUpdate; expect(view?.actions[0].asset.type).toBe("action"); - expect(view?.actions[1].asset.type).toBe("text"); + expect(view?.actions[1][0].asset.type).toBe("text"); expect(view?.actions[2]).toBeUndefined(); expect(updateNumber).toBe(2); @@ -431,9 +431,9 @@ describe("view", () => { ?.lastUpdate; expect(view?.actions[0].asset.type).toBe("action"); - expect(view?.actions[1].asset.type).toBe("text"); - expect(view?.actions[2].asset.type).toBe("text"); - expect(view?.actions[3].asset.type).toBe("text"); + expect(view?.actions[1][0].asset.type).toBe("text"); + expect(view?.actions[1][1][0].asset.type).toBe("text"); + expect(view?.actions[1][1][1].asset.type).toBe("text"); }); test("replaces async nodes with chained multiNodes singular", async () => { @@ -497,7 +497,7 @@ describe("view", () => { ?.lastUpdate; expect(view?.actions[0].asset.type).toBe("action"); - expect(view?.actions[1].asset.type).toBe("text"); + expect(view?.actions[1][0].asset.type).toBe("text"); expect(view?.actions[2]).toBeUndefined(); if (deferredResolve) { @@ -518,8 +518,8 @@ describe("view", () => { ?.lastUpdate; expect(view?.actions[0].asset.type).toBe("action"); - expect(view?.actions[1].asset.type).toBe("text"); - expect(view?.actions[2].asset.type).toBe("text"); + expect(view?.actions[1][0].asset.type).toBe("text"); + expect(view?.actions[1][1].asset.type).toBe("text"); }); test("should call onAsyncNode hook when async node is encountered", async () => { From c448eb560e0a1e94b3b4641e4cb5073712a0b547 Mon Sep 17 00:00:00 2001 From: Chloe Han Date: Mon, 23 Sep 2024 15:54:09 -0400 Subject: [PATCH 2/5] fix android test failure --- .../playerui/plugins/asyncnode/AsyncNodePluginTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 8b15416b3..b093850f1 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 @@ -144,7 +144,7 @@ internal class AsyncNodePluginTest : PlayerTest() { player.start(asyncNodeFlowSimple) } Assertions.assertTrue(count == 2) - Assertions.assertEquals(3, update?.getList("actions")?.size) + Assertions.assertEquals(2, update?.getList("actions")?.size) } @TestTemplate @@ -290,7 +290,7 @@ internal class AsyncNodePluginTest : PlayerTest() { Assertions.assertEquals(1, count) view = player.inProgressState?.lastViewUpdate - + Assertions.assertNotNull(view) Assertions.assertEquals( "action", @@ -298,7 +298,7 @@ internal class AsyncNodePluginTest : PlayerTest() { ) Assertions.assertEquals( "action", - view.getList("actions")?.filterIsInstance()?.get(1)?.getObject("asset")?.get("type"), + view.getList("actions")?.filterIsInstance>()?.get(0)?.get(0)?.getObject("asset")?.get("type"), ) Assertions.assertEquals(2, view.getList("actions")?.size) Assertions.assertEquals(2, count) From 5d172239ea12250c2745bc80091dffd11a7f0d24 Mon Sep 17 00:00:00 2001 From: Chloe Han Date: Tue, 24 Sep 2024 10:46:52 -0400 Subject: [PATCH 3/5] android lint fix --- .../com/intuit/playerui/plugins/asyncnode/AsyncNodePluginTest.kt | 1 - 1 file changed, 1 deletion(-) 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 b093850f1..5dbee8457 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 @@ -290,7 +290,6 @@ internal class AsyncNodePluginTest : PlayerTest() { Assertions.assertEquals(1, count) view = player.inProgressState?.lastViewUpdate - Assertions.assertNotNull(view) Assertions.assertEquals( "action", From ba726ce4f703a0290df6ab230ec6fcea6cad0959 Mon Sep 17 00:00:00 2001 From: Chloe Han Date: Tue, 24 Sep 2024 11:30:46 -0400 Subject: [PATCH 4/5] ios test trunk fix --- .../async-node/ios/Tests/AsynNodePluginTests.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/async-node/ios/Tests/AsynNodePluginTests.swift b/plugins/async-node/ios/Tests/AsynNodePluginTests.swift index 994995c9a..1f7163ef9 100644 --- a/plugins/async-node/ios/Tests/AsynNodePluginTests.swift +++ b/plugins/async-node/ios/Tests/AsynNodePluginTests.swift @@ -77,6 +77,7 @@ class AsyncNodePluginTests: XCTestCase { let newText1 = val .objectForKeyedSubscript("values") .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(0) .objectForKeyedSubscript("asset") .objectForKeyedSubscript("value") guard let textString1 = newText1?.toString() else { return XCTFail("newText1 was not a string") } @@ -152,6 +153,7 @@ class AsyncNodePluginTests: XCTestCase { let newText1 = val .objectForKeyedSubscript("values") .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(0) .objectForKeyedSubscript("asset") .objectForKeyedSubscript("value") guard let textString1 = newText1?.toString() else { return XCTFail("newText was not a string") } @@ -163,7 +165,9 @@ class AsyncNodePluginTests: XCTestCase { if count == 3 { let newText2 = val .objectForKeyedSubscript("values") - .objectAtIndexedSubscript(2) + .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(0) .objectForKeyedSubscript("asset") .objectForKeyedSubscript("value") guard let textString2 = newText2?.toString() else { return XCTFail("newText was not a string") } @@ -176,7 +180,9 @@ class AsyncNodePluginTests: XCTestCase { if count == 4 { let newText3 = val .objectForKeyedSubscript("values") - .objectAtIndexedSubscript(3) + .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(1) .objectForKeyedSubscript("asset") .objectForKeyedSubscript("value") guard let textString3 = newText3?.toString() else { return XCTFail("newText was not a string") } @@ -256,6 +262,7 @@ class AsyncNodePluginTests: XCTestCase { let newText1 = val .objectForKeyedSubscript("values") .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(0) .objectForKeyedSubscript("asset") .objectForKeyedSubscript("value") guard let textString1 = newText1?.toString() else { return XCTFail("newText was not a string") } @@ -267,7 +274,8 @@ class AsyncNodePluginTests: XCTestCase { if count == 3 { let newText2 = val .objectForKeyedSubscript("values") - .objectAtIndexedSubscript(2) + .objectAtIndexedSubscript(1) + .objectAtIndexedSubscript(1) .objectForKeyedSubscript("asset") .objectForKeyedSubscript("value") guard let textString2 = newText2?.toString() else { return XCTFail("newText was not a string") } From 870606d3e6dd211561c44d1896c44cc597388ede Mon Sep 17 00:00:00 2001 From: Chloe Han Date: Tue, 24 Sep 2024 13:30:07 -0400 Subject: [PATCH 5/5] add test for nested node --- .../intuit/playerui/plugins/asyncnode/AsyncNodePluginTest.kt | 3 +++ 1 file changed, 3 insertions(+) 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 5dbee8457..e7826ea95 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 @@ -103,6 +103,7 @@ internal class AsyncNodePluginTest : PlayerTest() { if (count == 2) cont.resume(true) {} } } + player.start(asyncNodeFlowSimple) } Assertions.assertTrue(count == 2) @@ -144,7 +145,9 @@ internal class AsyncNodePluginTest : PlayerTest() { player.start(asyncNodeFlowSimple) } Assertions.assertTrue(count == 2) + print(update?.get("actions")) Assertions.assertEquals(2, update?.getList("actions")?.size) + Assertions.assertEquals(2, update?.getList("actions")?.filterIsInstance>()?.get(0)?.size) } @TestTemplate