Skip to content

Commit

Permalink
Detox Next (iOS, Phase 1) (#2098)
Browse files Browse the repository at this point in the history
* initial ExpectTwo

* Added API checks and error throwing

* Proofing ExpectTwo

* Changed test name

* fix paths

* Detox Next impl WIP

* Update dependencies

* Project reorg

* WIP

* Scroll, pinch, swipe

* Better first responder management and logging

* Control flow WIP

* Implement control flow, while, get attributes

Still need to implement: dtx_assertCanScrollWithOffset, use normal scroll actions for scroll to edge

* Add support for text in RN “text” “views”

* Assert ability to scroll

If initial scroll started, stop once an edge is reached
Modify assertion handler methods to receive an optional view, so that hierarchy can be extracted from it

* User normal scroll for edge scrolling

* Swift fixes for previous API changes

* Update DTXLoggingInfra

Support getAttributes action

* Support timeouts in expectations

Properly take into account modifiers in expectations

* Enable asserts in release

* Fix wrong conflict resolve

* Invoke internals exporting.

* Support attributed titles in picker views

* Send invokeResult or testFailed when appropriate

* Add DTXObjectiveCHelpers submodule

* Support labels with RN hacks, use correct `atIndex`, fix predicate description

* added by.type

* ancestor/descendant inner type should be predicate, not value

* Added not() modifier to protocol, closes #2056

* Added  pinch(scale, speed, angle). closes #2053

* Fixes for actions and predicates

* fixed pinch defaults and checks

* Update expectTwo.js

* Update expectTwo.js

* fixed pinch defaults and checks

* fixed pinch defaults and checks - again!

* waitForWithTimeout now has a type `expectation` instead of `waitFor`. closes #2054

* Fixed test coverage

* set default swipe percentage to 0.5

* Change default to 0.75

* Improvements to scrolling

* Modify error stack so it displays the location in user’s test.

* Further fixes to scrolling

* Mark as Android

* complete coverage

* Even more scroll shenanigans

* Improve visibility test to take into account a view’s alpha==0

* Support “ISO8601” as special case date format, and assert the date is parsed correctly

* Support .not() for Android expectations in invoke1

* Support by.traits()

* Update docs

* modifier => modifiers array

* Makes sure expectation termination works correctly in waitFor as well, closes #2063

* Change tap() to receive a point as optional input, closes #2066

* Update APIRef.ActionsOnElement.md

* Update APIRef.ActionsOnElement.md

* Update APIRef.ActionsOnElement.md

* Remove code

* Correctly use runloop spinner to allow runloop draining and use internal timeout

* 🤦‍♂️

* Sort views when searching in specific hierarchy too

* fixed merge issue(?)

* Fixed waitFor.whileElement

* Fix Swift nonsense

* Remove legacy modifier and tapAtPoint support

* Better handling of getAttributes

* Fix predicate printing

* Fix ancestor predicate logic

* Add asynchronous versions of InvocationManager, Action and Expectation

Remove usage of runloop spinner in expectations

* Fix TraitsPredicate

* Enable problematic test on iOS

* Better wording on time out error

* rename params in matchers

* fixed element(by.x())).atIndex(). closes #2076

* Move setOrientation into its own action in iOS invoke2, closes #2055

* Expose methods for obtaining the assertion error directly

* Convert DetoxManager, WebSocket into Swift

Add nullability to shared ObjC code

* Remove some unneeded @objc declarations

Rename some classes to be more consistent with the project

* Remove synchronous versions of actions, expectations and invocation manager

Make scroll+while asynchronous
Add Swift fatal error support in crash handler

* Improve crash handler

* Change some text in crash details

* added getAttributes() action to iOS. closes #2075

* Improve attributes returned by getAttributes()

Add documentation

* Improvements to getAttributes() and docs

* Docs & migration

* Implement setOrientation in DetoxManager

* Seconds/ms

* Naming and linking

* Use modern EG

* Make crash handler functions C functions for readibility

Ensure crash handler is initialized either by attribute constructor system or by Detox initializer itself.

* Add some args for future testing

* Fix picker view row selection logic

Change test to reflect that setColumnToValue() no longer supports date pickers

* Remove absolutely useless status bar test from suite

toBeVisible() should be supported now in background

* Enable locale and language test for iOS only

* Build framework and test suite quietly

* Add support for setting and expecting slider positions (#2089)

* Support multiple matched elements with getAttributes() action

* fixed setOrientation

* Use ApproximateEquality from Swift Numerics to expect slider value

Better predicate and expectation descriptions

* Use custom symbolication for stack traces with Swift and C++ demangling support

* Fix shake

* add not() to Android matchers

* Switched from .not() to .not (#2069)

* Android tapAtPoint(point) is now tap(point)  #2069

* .not instead of .not()

* Use modern .not API

* Remove only

* Fix traits test + suite screen + logic

* Fix existence checking logic

* Remove unnecessary dtx_try nesting

* Add missing dtx_try

* Fixed iOS waitFor

* Implement setSyncSettings for iOS

* Fix Android .not support

* Added setSyncSettings + removing all EarlGrey and iOS generated and generation code

* MOAR Android .not fixes

* Decrypt the DetoxSync framework in Profiler as well

* Move example project label higher in hierarchy so it is visible

* Set test suite as iOS 12.0+

* ...

* Sync before attempting actions or expectations

* Special case for UISegmentLabel tapping

* Cleanup + fix unit tests

* WTF

* update generation snapshot

* record videos for iOS (will it work on CI?)

* Provide the date and date components if a view is UIDatePicker

* New logic for visibility testing

An image is taken for visible view around the hit point, and that image is tested for transparency. If a view is not transparent around the hit point, that is the visible view candidate.
Visibility and hit testing also take into account stacked windows in the working scene.

* Added adjustSliderToPosition() and toHaveSliderPosition() to iOS DetoxNext. closes #2089

* Finish slider position expectation implementation

* Remove unused variable

* Fix visTest

* Add signposts for performance profiling

* Abstract view actions from element actions

Element now exposes all the API needed

* Use modern tap(point) API

disable tap(point) test on iOS

* Add slider test

* Send view hierarchy and other debug information to JS

* Remove only

* test: fix mock-server close

* Fixed ActionScreen

* Fix a few tests

* fix uiDevice unit test

* Disable view caching in element

* Throw an error instead of crashing when trait is unknown

* Only check in asl_error if level is ASL_LEVEL_ERR

* Update docs

* Docs

* Use modern syntax for not.toBeVisible()

* Latest DTXLoggingInfra [skip ci]

* separate response.params.details from response.params.viewHierarchy in error log

* Fixed Android waitFor

* Fix unit test coverage

* iOS: detox test --loglevel verbose

* Use detox accessibility frame

* Add more debug information for visible and hittable testing

* Apply a small delay for UISwitch

* Attempt to long press on switch rather than tap

Add more description to errors

* Remove videos

* Android: split viewHierarchy from error log (but also switched "error" and "testFailed" events in DetoxActionHandler)

* Xcode 12 nonsense

* Fixed Android unit tests

* Fixed faulty merge

Co-authored-by: Rotem Mizrachi-Meidan <rotemm@wix.com>
Co-authored-by: Leo Natan <lnatan@wix.com>
  • Loading branch information
3 people committed Jun 25, 2020
1 parent 3f9b5e5 commit 35d7f49
Show file tree
Hide file tree
Showing 160 changed files with 9,330 additions and 5,657 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
@@ -1,6 +1,6 @@
[submodule "detox/ios/SocketRocket"]
path = detox/ios/SocketRocket
url = https://github.com/facebook/SocketRocket.git
url = https://github.com/wix-playground/SocketRocket.git
ignore = dirty
[submodule "detox/ios/EarlGrey"]
path = detox/ios/EarlGrey
Expand All @@ -12,3 +12,6 @@
[submodule "detox/ios/DTXLoggingInfra"]
path = detox/ios/DTXLoggingInfra
url = https://github.com/wix/DTXLoggingInfra.git
[submodule "detox/ios/DTXObjectiveCHelpers"]
path = detox/ios/DTXObjectiveCHelpers
url = https://github.com/wix/DTXObjectiveCHelpers.git
Expand Up @@ -52,11 +52,15 @@ class InvokeActionHandler(
val invocationResult = methodInvocation.invoke(params)
wsClient.sendAction("invokeResult", mapOf<String, Any?>("result" to invocationResult), messageId)
} catch (e: InvocationTargetException) {
Log.e(LOG_TAG, "Exception", e)
wsClient.sendAction("error", mapOf<String, Any?>("error" to "${errorParse(e.targetException)}\nCheck device logs for full details!\n"), messageId)
} catch (e: Exception) {
Log.i(LOG_TAG, "Test exception", e)
wsClient.sendAction("testFailed", mapOf<String, Any?>("details" to "${errorParse(e)}\nCheck device logs for full details!\n"), messageId)
val message = e.targetException.message
val error = message?.substringBefore("View Hierarchy:")?.trim()
val viewHierarchy = message?.substringAfter("View Hierarchy:")
wsClient.sendAction("testFailed", mapOf<String, Any?>("details" to "${error}\n",
"viewHierarchy" to viewHierarchy), messageId)
} catch (e: Exception) {
Log.e(LOG_TAG, "Exception", e)
wsClient.sendAction("error", mapOf<String, Any?>("error" to "${errorParse(e)}\nCheck device logs for full details!\n"), messageId)
}
}
}
Expand Down
Expand Up @@ -133,8 +133,8 @@ object DetoxActionHandlersSpec : Spek({
uut().handle(params, messageId)

verify(wsClient).sendAction(
eq("testFailed"),
argThat { size == 1 && this["details"] == "mockErrorParser($exception)\nCheck device logs for full details!\n" },
eq("error"),
argThat { size == 1 && this["error"] == "mockErrorParser(${exception})\nCheck device logs for full details!\n" },
eq(messageId))
}

Expand All @@ -146,8 +146,9 @@ object DetoxActionHandlersSpec : Spek({
uut().handle(params, messageId)

verify(wsClient).sendAction(
eq("error"),
argThat { size == 1 && this["error"] == "mockErrorParser(${targetException})\nCheck device logs for full details!\n" },
eq("testFailed"),
argThat { size == 2 && this["details"] is String &&
this["viewHierarchy"] is String },
eq(messageId))
}
}
Expand Down
2 changes: 1 addition & 1 deletion detox/ios/DTXLoggingInfra
1 change: 1 addition & 0 deletions detox/ios/DTXObjectiveCHelpers
Submodule DTXObjectiveCHelpers added at 2c775d
393 changes: 336 additions & 57 deletions detox/ios/Detox.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
16 changes: 0 additions & 16 deletions detox/ios/Detox/DTXMethodInvocation.h

This file was deleted.

250 changes: 0 additions & 250 deletions detox/ios/Detox/DTXMethodInvocation.m

This file was deleted.

25 changes: 25 additions & 0 deletions detox/ios/Detox/Detox.modulemap
@@ -0,0 +1,25 @@
framework module Detox {
umbrella header "Detox.h"
export *

explicit module Private {
header "UIView+DetoxMatchers.h"
header "UIView+DetoxActions.h"
header "UIPickerView+DetoxActions.h"
header "UIDatePicker+DetoxActions.h"
header "UIScrollView+DetoxActions.h"
header "DTXAssertionHandler.h"
header "UIView+DetoxUtils.h"
header "ReactNativeSupport.h"
header "DetoxInstrumentsManager.h"
header "DetoxAppDelegateProxy.h"
header "EarlGrey+Detox.h"
header "UIDevice+DetoxActions.h"
header "EarlGreyStatistics.h"
header "UISlider+DetoxUtils.h"
header "___DTXAddressInfo.h"
header "DTXDurationFormatter.h"
header "UIWindow+DetoxUtils.h"
header "DTXAppleInternals.h"
}
}
14 changes: 5 additions & 9 deletions detox/ios/Detox/Detox.pch
Expand Up @@ -11,14 +11,10 @@

#import "DTXLogging.h"

#define dtx_defer_block_name_with_prefix(prefix, suffix) prefix ## suffix
#define dtx_defer_block_name(suffix) dtx_defer_block_name_with_prefix(defer_, suffix)
#define dtx_defer __strong void(^dtx_defer_block_name(__LINE__))(void) __attribute__((cleanup(defer_cleanup_block), unused)) = ^
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
static void defer_cleanup_block(__strong void(^*block)(void)) {
(*block)();
}
#pragma clang diagnostic pop
#import "Swiftier.h"

#ifdef __OBJC__
#import "DTXAssertionHandler.h"
#endif

#endif /* Detox_pch */

0 comments on commit 35d7f49

Please sign in to comment.