also looking at this
fix(native): retain keyed controls and correct map and tab chrome
#368
32 files
+449
-100
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -822,6 +822,28 @@ final class NativeRenderUnitTests: XCTestCase { | ||
| 822 | 822 | XCTAssertTrue(scroll === find(UIScrollView.self, key: "scroll", below: controller.view)) |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | func testMutationPreservesAuthoredKeysAcrossImportCreationUpdatesAndMoves() throws { | |
| 826 | let document = CraftNativeMutationDocument() | |
| 827 | document.replace(with: [ | |
| 828 | "id": "root", "type": "View", "key": "root-key", "children": [ | |
| 829 | ["id": "existing", "type": "TextInput", "key": "draft-key", "props": ["value": "draft"]], | |
| 830 | ], | |
| 831 | ]) | |
| 832 | XCTAssertEqual(document.node("existing")?["key"] as? String, "draft-key") | |
| 833 | let result = try document.apply(batch(1, [ | |
| 834 | ["op": "createNode", "id": "created", "node": ["type": "View", "key": "created-key"]], | |
| 835 | ["op": "insertChild", "parentId": "root", "childId": "created", "index": 1], | |
| 836 | ["op": "updateNode", "id": "existing", "patch": ["props": ["value": "edited"]]], | |
| 837 | ["op": "moveChild", "parentId": "root", "childId": "created", "index": 0], | |
| 838 | ])) | |
| 839 | let rendered = try XCTUnwrap(result.document) | |
| 840 | let children = try XCTUnwrap(rendered["children"] as? [[String: Any]]) | |
| 841 | XCTAssertEqual(rendered["key"] as? String, "root-key") | |
| 842 | XCTAssertEqual(children[0]["key"] as? String, "created-key") | |
| 843 | XCTAssertEqual(children[1]["key"] as? String, "draft-key") | |
| 844 | XCTAssertEqual((document.node("existing")?["props"] as? [String: Any])?["value"] as? String, "edited") | |
| 845 | } | |
| 846 | ||
| 825 | 847 | func testEveryContainerTheRendererDrawsTakesChildrenAndALeafDoesNot() throws { |
| 826 | 848 | for type in CraftNativeMutationDocument.containerTypes.sorted() + ["svg", "pressable"] { |
| 827 | 849 | let document = CraftNativeMutationDocument() |