also looking at this
fix(native): preserve workspace sources and native overlay lifecycle
#384
20 files
+500
-227
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.
| @@ -39,14 +39,20 @@ final class NativeRenderUITests: XCTestCase { | ||
| 39 | 39 | notes.tap() |
| 40 | 40 | XCTAssertTrue(keyboardIsVisible(app)) |
| 41 | 41 | notes.typeText("Easy run") |
| 42 | // Read the original acknowledgement first: inspecting other UIKit | |
| 43 | // elements must not hide a delayed bridge update from this assertion. | |
| 44 | let acknowledgement = app.staticTexts["notes"].label | |
| 42 | // The native value and the script acknowledgement cross different threads. | |
| 43 | let firstAcknowledgement = app.staticTexts["notes"].label | |
| 45 | 44 | let typedValue = notes.value as? String |
| 46 | 45 | let keyboardVisible = app.keyboards.firstMatch.exists |
| 47 | 46 | XCTAssertEqual(typedValue, "Easy run", "the native text view lost typed characters") |
| 48 | 47 | XCTAssertTrue(keyboardVisible, "typing dismissed the native keyboard") |
| 49 | XCTAssertEqual(acknowledgement, "Notes: Easy run", "native value: \(typedValue ?? "nil"), keyboard visible: \(keyboardVisible)") | |
| 48 | let acknowledgement = XCTNSPredicateExpectation( | |
| 49 | predicate: NSPredicate(format: "label == %@", "Notes: Easy run"), | |
| 50 | object: app.staticTexts["notes"] | |
| 51 | ) | |
| 52 | XCTAssertEqual(XCTWaiter.wait(for: [acknowledgement], timeout: 5), .completed, "first acknowledgement: \(firstAcknowledgement)") | |
| 53 | XCTAssertEqual(app.staticTexts["notes"].label, "Notes: Easy run") | |
| 54 | XCTAssertEqual(notes.value as? String, "Easy run", "the script acknowledgement overwrote native typing") | |
| 55 | XCTAssertTrue(app.keyboards.firstMatch.exists, "the script acknowledgement dismissed the keyboard") | |
| 50 | 56 | } |
| 51 | 57 | |
| 52 | 58 | func testSwitchTapChangesUIKitStateAndDeliversValueChange() throws { |
| @@ -2612,13 +2612,20 @@ final class NativeRenderUnitTests: XCTestCase { | ||
| 2612 | 2612 | |
| 2613 | 2613 | func testSwitchReceivesNativeTouchesWhenMountedInAFlowView() throws { |
| 2614 | 2614 | let controller = CraftNativeScreenController(config: CraftConfig()) |
| 2615 | let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 390, height: 844)) | |
| 2616 | window.rootViewController = controller | |
| 2615 | 2617 | controller.loadViewIfNeeded() |
| 2616 | 2618 | controller.render(document([[ |
| 2617 | 2619 | "type": "View", |
| 2618 | 2620 | "props": ["key": "root"], |
| 2619 | 2621 | "children": [["type": "Switch", "props": ["testID": "native-switch"]]], |
| 2620 | 2622 | ]])) |
| 2623 | window.isHidden = false | |
| 2624 | defer { window.isHidden = true } | |
| 2625 | controller.view.layoutIfNeeded() | |
| 2621 | 2626 | let toggle = try XCTUnwrap(find(UISwitch.self, key: "native-switch", below: controller.view)) |
| 2627 | XCTAssertGreaterThan(toggle.bounds.width, 0) | |
| 2628 | XCTAssertGreaterThan(toggle.bounds.height, 0) | |
| 2622 | 2629 | XCTAssertTrue(toggle.isUserInteractionEnabled) |
| 2623 | 2630 | XCTAssertTrue(toggle.isEnabled) |
| 2624 | 2631 | let point = toggle.convert(CGPoint(x: toggle.bounds.midX, y: toggle.bounds.midY), to: controller.view) |