Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iOS): support bridgeless mode. #4681

Draft
wants to merge 52 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
667f7a2
test(iOS): enable bridgeless mode on test app.
asafkorem Jan 8, 2025
0b37365
test(ios): fix swift bridge.
asafkorem Jan 8, 2025
b06b68c
demo(iOS): support bridgeless mode with new-arch.
asafkorem Jan 10, 2025
2e4d9d7
ci: ensure RN .73 without new arch works.
asafkorem Jan 10, 2025
ae22233
ci: update pipeline step title.
asafkorem Jan 10, 2025
03a8397
test(fix,ios): support background search.
asafkorem Jan 10, 2025
e75c276
test(ios): extend timer of visible message if needed.
asafkorem Jan 10, 2025
304afe0
fix(iOS): ignore `RCTAccessibilityElement` from view hierarchy.
asafkorem Jan 10, 2025
d13085e
test(ios): update `type` variants based on new-arch.
asafkorem Jan 10, 2025
924437c
test(iOS): make elements accessible for descendant/ancestor matchers.
asafkorem Jan 10, 2025
8881334
test(iOS): update view-hierarchy artifact for new arch view.
asafkorem Jan 10, 2025
6f325bf
feat(ios): support `RCTEnhancedScrollView` for scrolling.
asafkorem Jan 10, 2025
a60faac
fix(iOS): replace invalid return value.
asafkorem Jan 11, 2025
7bbace4
chore: bump `DetoxSync` submodule head.
asafkorem Jan 11, 2025
86343ff
fix(iOS): support `RNCSliderComponentView` slider.
asafkorem Jan 11, 2025
5f46e01
test: remove react-native .71 old test.
asafkorem Jan 11, 2025
9f40644
test(iOS): ensure wrapping element is accessible.
asafkorem Jan 11, 2025
c58cac8
test(ios): fix matcher class name.
asafkorem Jan 11, 2025
743390e
fix(ios): extract slider property only if exists.
asafkorem Jan 11, 2025
57a7d38
test(ios): undo skip tests due to new-arch.
asafkorem Jan 11, 2025
72c93fd
test(ios): change element accessibility for fabric tests.
asafkorem Jan 11, 2025
95388b5
feat(iOS): support `ToggleValueExpectation` for new arch.
asafkorem Jan 11, 2025
3d145bb
fix(iOS): migrate to RCT_EXPORT_METHOD.
asafkorem Jan 13, 2025
87c9ea2
test(ios): skip bridge stress test.
asafkorem Jan 13, 2025
44f3095
test: add @new-arch and @legacy test markers (for specifying test-env).
asafkorem Jan 14, 2025
f735c2b
test: skip tests on new arch.
asafkorem Jan 14, 2025
ec91497
test(ios): fix overlay messages layout
asafkorem Jan 14, 2025
b3db439
test(ios): fix test expectation
asafkorem Jan 15, 2025
6c88053
test(ios): fix accessibility.
asafkorem Jan 15, 2025
0e4fc22
feat: bump DetoxSync dependency.
asafkorem Jan 15, 2025
310bfe7
feat: bump DetoxSync dependency.
asafkorem Jan 15, 2025
958628d
test(ios): remove @legacy flag.
asafkorem Jan 15, 2025
694eb1a
chore: bump DetoxSync.
asafkorem Jan 16, 2025
3ff5526
test(unit): fix unit test.
asafkorem Jan 16, 2025
6bbfd8d
mark failing tests
asafkorem Jan 16, 2025
7d0b97f
Merge remote-tracking branch 'origin/master' into feat/bridgeless-mode
asafkorem Jan 16, 2025
a57dd5e
test: fix expectation.
asafkorem Jan 16, 2025
ac76f69
test(ios): fix toHaveToggleValue value.
asafkorem Jan 16, 2025
c685ea3
chore: update DetoxSync.
asafkorem Jan 18, 2025
4bd5010
test: reduce flakiness in stress screen test
asafkorem Jan 18, 2025
b1baeeb
test(StressScreen): use min value on JS timer stress test.
asafkorem Jan 19, 2025
caaf943
chore: bump detox-sync.
asafkorem Jan 19, 2025
569b65a
test: avoid missing key warnings.
asafkorem Jan 19, 2025
b7a44bd
test(e2e): remove test duplication.
asafkorem Jan 19, 2025
a09ee29
test: remove todos.
asafkorem Jan 19, 2025
2cacc25
chore: bump detox-sync.
asafkorem Jan 19, 2025
2cc6a62
ci: temp disable android tests.
asafkorem Jan 19, 2025
f8db9e7
ci: rename jobs.
asafkorem Jan 19, 2025
35b9d13
test(app): avoid missing key warning.
asafkorem Jan 19, 2025
3c989f2
test: mark legacy test failing.
asafkorem Jan 19, 2025
1073d38
fix: getAttributes for new-arch elements.
asafkorem Jan 19, 2025
ad4fcac
chore: update detox-sync.
asafkorem Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/jobs/pipeline.android_rn_73.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- label: ":android::detox: (Old Arch) - RN .73 + Android: Tests app"
- label: ":android::detox: (Old Arch) RN .73 + Android: Tests app"
command:
- "nvm install"
- "./scripts/ci.android.sh"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/jobs/pipeline.android_rn_76_old_arch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- label: ":android::detox: (Old Arch) - RN .76 + Android: Tests app"
- label: ":android::detox: (Old Arch) RN .76 + Android: Tests app"
command:
- "nvm install"
- "./scripts/ci.android.sh"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/jobs/pipeline.ios_demo_app_rn_76_new_arch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- label: ":new::ios::react: RN .76 + iOS: Demo app"
- label: ":ios::react: RN .76 + iOS: Demo app"
command:
- "nvm install"
- "./scripts/demo-projects.ios.sh"
Expand Down
3 changes: 2 additions & 1 deletion .buildkite/jobs/pipeline.ios_rn_73.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
- label: ":ios::detox: RN .73 + iOS: Tests app"
- label: ":ios::detox: (Old Arch) RN .73 + iOS: Tests app"
command:
- "nvm install"
- "./scripts/ci.ios.sh"
env:
REACT_NATIVE_VERSION: 0.73.2
RCT_NEW_ARCH_ENABLED: 0
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/jobs/pipeline.ios_rn_76.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- label: ":ios::detox: RN .76 + iOS: Tests app"
- label: ":ios::detox: (Old Arch) RN .76 + iOS: Tests app"
command:
- "nvm install"
- "./scripts/ci.ios.sh"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/jobs/pipeline.ios_rn_76_new_arch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- label: ":new::ios::detox: RN .76 + New Arch + iOS: Tests app"
- label: ":ios::detox: RN .76 + iOS: Tests app"
command:
- "nvm install"
- "./scripts/ci.ios.sh"
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/pipeline_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cat .buildkite/jobs/pipeline.ios_rn_76_new_arch.yml
cat .buildkite/jobs/pipeline.ios_rn_76.yml
cat .buildkite/jobs/pipeline.ios_rn_73.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_76_new_arch.yml
cat .buildkite/jobs/pipeline.android_rn_76.yml
cat .buildkite/jobs/pipeline.android_rn_76_old_arch.yml
cat .buildkite/jobs/pipeline.android_rn_73.yml
cat .buildkite/jobs/pipeline.android_demo_app_rn_76.yml
#cat .buildkite/jobs/pipeline.android_rn_76.yml
#cat .buildkite/jobs/pipeline.android_rn_76_old_arch.yml
#cat .buildkite/jobs/pipeline.android_rn_73.yml
#cat .buildkite/jobs/pipeline.android_demo_app_rn_76.yml
cat .buildkite/pipeline.post_processing.yml
4 changes: 2 additions & 2 deletions detox/ios/Detox/Actions/NSObject+DetoxActions.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ - (void)dtx_tapAtAccessibilityActivationPointWithNumberOfTaps:(NSUInteger)number

- (void)dtx_tapAtPoint:(CGPoint)point numberOfTaps:(NSUInteger)numberOfTaps
{
if([self isKindOfClass:UISwitch.class] && numberOfTaps == 1)
if(self.dtx_switchView != nil && numberOfTaps == 1)
{
//Attempt a long press on the switch, rather than tap.
[self dtx_longPressAtPoint:point duration:0.7];
[self.dtx_switchView dtx_longPressAtPoint:point duration:0.7];
return;
}

Expand Down
8 changes: 4 additions & 4 deletions detox/ios/Detox/Actions/UIScrollView+DetoxActions.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (void)_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1;

@interface UIScrollView (DetoxScrolling)

- (BOOL)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1;
- (void)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1;
@property (nonatomic, assign, setter=dtx_setDisableDecelerationForScroll:) BOOL dtx_disableDecelerationForScroll;

@end
Expand All @@ -47,7 +47,7 @@ - (BOOL)dtx_disableDecelerationForScroll
return [objc_getAssociatedObject(self, "dtx_disableDecelerationForScroll") boolValue];
}

- (BOOL)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1
- (void)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1
{
BOOL deceleration = arg1;
if(self.dtx_disableDecelerationForScroll == YES &&
Expand All @@ -60,8 +60,8 @@ - (BOOL)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1
{
deceleration = NO;
}
return [self _dtx_scrollViewWillEndDraggingWithDeceleration:deceleration];

[self _dtx_scrollViewWillEndDraggingWithDeceleration:deceleration];
}

@end
Expand Down
43 changes: 30 additions & 13 deletions detox/ios/Detox/Invocation/Element.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Element : NSObject {
if ReactNativeSupport.isReactNativeApp {
let className = NSStringFromClass(type(of: view))
switch className {
case "RCTScrollView", "RCTScrollViewComponentView":
case "RCTScrollView", "RCTScrollViewComponentView", "RCTEnhancedScrollView":
return (view.value(forKey: "scrollView") as! UIScrollView)
default:
break
Expand Down Expand Up @@ -205,7 +205,7 @@ class Element : NSObject {
}

func adjust(toNormalizedSliderPosition normalizedSliderPosition: Double) {
guard let slider = view as? UISlider else {
guard let slider = view.dtx_sliderView else {
dtx_fatalError("View \(view.dtx_shortDescription) is not instance of “UISlider”", viewDescription: debugAttributes)
}

Expand Down Expand Up @@ -267,17 +267,34 @@ class Element : NSObject {
return view.accessibilityValue
}

@objc
var normalizedSliderPosition: Double {
get {
guard let slider = view as? UISlider else {
dtx_fatalError("View \(view.dtx_shortDescription) is not instance of “UISlider”", viewDescription: debugAttributes)
}

return slider.dtx_normalizedSliderPosition
}
}

@objc
var normalizedSliderPosition: Double {
get {
if let slider = view.dtx_sliderView {
return slider.dtx_normalizedSliderPosition
}

dtx_fatalError(
"View \(view.dtx_shortDescription) is not instance or wrapper of “UISlider”",
viewDescription: debugAttributes
)
}
}

@objc
var toggleValue: Double {
get {
if let toggle = view.dtx_switchView {
return toggle.isOn ? 1.0 : 0.0
}

dtx_fatalError(
"View \(view.dtx_shortDescription) is not instance or wrapper of “UISwitch”",
viewDescription: debugAttributes
)
}
}

@objc
var attributes: [String : Any] {
let views = self.views
Expand Down
21 changes: 19 additions & 2 deletions detox/ios/Detox/Invocation/Expectation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Expectation : CustomStringConvertible {
static let toHaveValue = "toHaveValue"
static let toHavePlaceholder = "toHavePlaceholder"
static let toHaveSliderPosition = "toHaveSliderPosition"
static let toHaveToggleValue = "toHaveToggleValue"
}

let element : Element
Expand All @@ -81,7 +82,8 @@ class Expectation : CustomStringConvertible {
Kind.toHaveId: ValueExpectation.self,
Kind.toHaveValue: ValueExpectation.self,
Kind.toHavePlaceholder: ValueExpectation.self,
Kind.toHaveSliderPosition: SliderPositionExpectation.self
Kind.toHaveSliderPosition: SliderPositionExpectation.self,
Kind.toHaveToggleValue: ToggleValueExpectation.self
]

static let keyMapping : [String: String] = [
Expand All @@ -106,7 +108,10 @@ class Expectation : CustomStringConvertible {

let element = try Element.with(dictionaryRepresentation: dictionaryRepresentation)
let expectationClass = mapping[kind]!
if expectationClass == SliderPositionExpectation.self {
if expectationClass == ToggleValueExpectation.self {
return ToggleValueExpectation(kind: kind, modifiers: modifiers, element: element, timeout: timeout, value: params!.first! as! Double, tolerance: params!.count > 1 ? (params![1] as! Double) : nil)

} else if expectationClass == SliderPositionExpectation.self {
return SliderPositionExpectation(kind: kind, modifiers: modifiers, element: element, timeout: timeout, value: params!.first! as! Double, tolerance: params!.count > 1 ? (params![1] as! Double) : nil)
} else if expectationClass == ValueExpectation.self {
return ValueExpectation(kind: kind, modifiers: modifiers, element: element, timeout: timeout, key: keyMapping[kind]!, value: params!.first!)
Expand Down Expand Up @@ -312,3 +317,15 @@ class SliderPositionExpectation : DoubleExpectation {
}
}
}

class ToggleValueExpectation : DoubleExpectation {
override func valueToTest(from element: Element) -> Double {
return element.toggleValue
}

override var additionalDescription: String {
get {
return "(toggleValue \(tolerance != nil ? "(~\(tolerance!))" : "")== \(value == 1.0 ? "ON" : "OFF"))"
}
}
}
7 changes: 7 additions & 0 deletions detox/ios/Detox/Invocation/Predicate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ class Predicate : CustomStringConvertible, CustomDebugStringConvertible {
func predicateForQuery() -> NSPredicate {
var rv = innerPredicateForQuery()

// Filter out `RCTAccessibilityElement` instances -
// React Native injects these internal accessibility bridges into the view hierarchy to handle accessibility
// mappings between JS and native layers
rv = NSCompoundPredicate(
andPredicateWithSubpredicates:
[rv, NSPredicate(format: "NOT (class.description = %@)", "RCTAccessibilityElement")])

if modifiers.contains(Modifier.not) {
rv = NSCompoundPredicate(notPredicateWithSubpredicate: rv)
}
Expand Down
2 changes: 2 additions & 0 deletions detox/ios/Detox/Utilities/NSObject+DetoxUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static double LNLinearInterpolate(CGFloat from, CGFloat to, CGFloat p)
@property (nonatomic, readonly, nullable) id accessibilityContainer;

@property (nonatomic, readonly) UIView* dtx_view;
@property (nonatomic, readonly, nullable) UISlider* dtx_sliderView;
@property (nonatomic, readonly, nullable) UISwitch* dtx_switchView;

- (CGPoint)dtx_convertRelativePointToViewCoordinateSpace:(CGPoint)relativePoint;

Expand Down
Loading
Loading