detox 21.0.0-rc.3 → 21.0.0-rc.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +1 -40
  3. package/Detox-android/com/wix/detox/{21.0.0-rc.3/detox-21.0.0-rc.3-javadoc.jar → 21.0.0-rc.4/detox-21.0.0-rc.4-javadoc.jar} +0 -0
  4. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-javadoc.jar.md5 +1 -0
  5. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-javadoc.jar.sha1 +1 -0
  6. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-javadoc.jar.sha256 +1 -0
  7. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-javadoc.jar.sha512 +1 -0
  8. package/Detox-android/com/wix/detox/{21.0.0-rc.3/detox-21.0.0-rc.3-sources.jar → 21.0.0-rc.4/detox-21.0.0-rc.4-sources.jar} +0 -0
  9. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-sources.jar.md5 +1 -0
  10. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-sources.jar.sha1 +1 -0
  11. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-sources.jar.sha256 +1 -0
  12. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4-sources.jar.sha512 +1 -0
  13. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.aar +0 -0
  14. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.aar.md5 +1 -0
  15. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.aar.sha1 +1 -0
  16. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.aar.sha256 +1 -0
  17. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.aar.sha512 +1 -0
  18. package/Detox-android/com/wix/detox/{21.0.0-rc.3/detox-21.0.0-rc.3.pom → 21.0.0-rc.4/detox-21.0.0-rc.4.pom} +1 -1
  19. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.pom.md5 +1 -0
  20. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.pom.sha1 +1 -0
  21. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.pom.sha256 +1 -0
  22. package/Detox-android/com/wix/detox/21.0.0-rc.4/detox-21.0.0-rc.4.pom.sha512 +1 -0
  23. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  26. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  27. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  28. package/Detox-ios-framework.tbz +0 -0
  29. package/Detox-ios-src.tbz +0 -0
  30. package/Detox-ios-xcuitest.tbz +0 -0
  31. package/android/build.gradle +20 -10
  32. package/android/detox/build.gradle +11 -4
  33. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +12 -12
  34. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +2 -2
  35. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/RegexMatcher.kt +56 -0
  36. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +16 -4
  37. package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/RegexMatcherTest.kt +52 -0
  38. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  39. package/android/rninfo.gradle +25 -0
  40. package/android/settings.gradle +2 -1
  41. package/index.d.ts +40 -6
  42. package/local-cli/startCommand/AppStartCommand.js +4 -1
  43. package/package.json +14 -10
  44. package/src/android/espressoapi/DetoxMatcher.js +24 -8
  45. package/src/android/matchers/index.js +3 -0
  46. package/src/android/matchers/native.js +9 -4
  47. package/src/android/matchers/web.js +18 -1
  48. package/src/devices/runtime/drivers/ios/XCUITestUtils.js +3 -4
  49. package/src/invoke.js +0 -2
  50. package/src/ios/expectTwo.js +28 -11
  51. package/src/ios/web.js +280 -0
  52. package/src/realms/DetoxPrimaryContext.js +1 -2
  53. package/src/utils/invocationTraceDescriptions.js +16 -0
  54. package/src/utils/isRegExp.js +7 -0
  55. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-javadoc.jar.md5 +0 -1
  56. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-javadoc.jar.sha1 +0 -1
  57. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-javadoc.jar.sha256 +0 -1
  58. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-javadoc.jar.sha512 +0 -1
  59. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-sources.jar.md5 +0 -1
  60. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-sources.jar.sha1 +0 -1
  61. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-sources.jar.sha256 +0 -1
  62. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3-sources.jar.sha512 +0 -1
  63. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.aar +0 -0
  64. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.aar.md5 +0 -1
  65. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.aar.sha1 +0 -1
  66. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.aar.sha256 +0 -1
  67. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.aar.sha512 +0 -1
  68. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.pom.md5 +0 -1
  69. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.pom.sha1 +0 -1
  70. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.pom.sha256 +0 -1
  71. package/Detox-android/com/wix/detox/21.0.0-rc.3/detox-21.0.0-rc.3.pom.sha512 +0 -1
  72. package/src/invoke/EarlGrey.js +0 -8
package/.eslintignore CHANGED
@@ -3,3 +3,5 @@
3
3
  /ios
4
4
  /android
5
5
  /test
6
+ /allure-*
7
+ /artifacts
package/.eslintrc.js CHANGED
@@ -4,7 +4,7 @@ module.exports = {
4
4
  'eslint:recommended',
5
5
  'plugin:import/recommended',
6
6
  'plugin:node/recommended',
7
- 'plugin:unicorn/recommended'
7
+ 'plugin:ecmascript-compat/recommended'
8
8
  ],
9
9
  parser: '@typescript-eslint/parser',
10
10
  plugins: [
@@ -73,45 +73,6 @@ module.exports = {
73
73
  allowWarningComments: false,
74
74
  }
75
75
  ],
76
- // TODO: enable some of unicorn rules
77
- 'unicorn/better-regex': 'off',
78
- 'unicorn/catch-error-name': 'off',
79
- 'unicorn/consistent-destructuring': 'off',
80
- 'unicorn/consistent-function-scoping': 'off',
81
- 'unicorn/empty-brace-spaces': 'off',
82
- 'unicorn/error-message': 'off',
83
- 'unicorn/explicit-length-check': 'off',
84
- 'unicorn/filename-case': 'off',
85
- 'unicorn/import-style': 'off',
86
- 'unicorn/new-for-builtins': 'off',
87
- 'unicorn/no-abusive-eslint-disable': 'off',
88
- 'unicorn/no-array-callback-reference': 'off',
89
- 'unicorn/no-array-for-each': 'off',
90
- 'unicorn/no-array-reduce': 'off',
91
- 'unicorn/no-await-expression-member': 'off',
92
- 'unicorn/no-lonely-if': 'off',
93
- 'unicorn/no-nested-ternary': 'off',
94
- 'unicorn/no-new-array': 'off',
95
- 'unicorn/no-null': 'off',
96
- 'unicorn/no-object-as-default-parameter': 'off',
97
- 'unicorn/no-useless-undefined': 'off',
98
- 'unicorn/number-literal-case': 'off',
99
- 'unicorn/numeric-separators-style': 'off',
100
- 'unicorn/prefer-add-event-listener': 'off',
101
- 'unicorn/prefer-array-some': 'off',
102
- 'unicorn/prefer-array-flat': 'off',
103
- 'unicorn/prefer-includes': 'off',
104
- 'unicorn/prefer-module': 'off',
105
- 'unicorn/prefer-number-properties': 'off',
106
- 'unicorn/prefer-object-from-entries': 'off',
107
- 'unicorn/prefer-optional-catch-binding': 'off',
108
- 'unicorn/prefer-regexp-test': 'off',
109
- 'unicorn/prefer-spread': 'off',
110
- 'unicorn/prefer-string-slice': 'off',
111
- 'unicorn/prefer-string-starts-ends-with': 'off',
112
- 'unicorn/prefer-string-trim-start-end': 'off',
113
- 'unicorn/prefer-ternary': 'off',
114
- 'unicorn/prevent-abbreviations': 'off',
115
76
  },
116
77
 
117
78
  overrides: [
@@ -0,0 +1 @@
1
+ 51389ac07b1874b6a3a5f2b37f3b801b
@@ -0,0 +1 @@
1
+ 76e27c6a70da2f70344303c4867926a9f6501b8f
@@ -0,0 +1 @@
1
+ 6742a6e0906341ce077d88fd57eeac4aa3e0ef8faea165094573f3858be7fe6f
@@ -0,0 +1 @@
1
+ 60608ba2e948e8ac6b29b3c6ff2d6634a61cb830a3569b8cd7677caeb07c7189cc489c1722128e2dd4a8b06027e5c4ada2ac72ee63252701efecd7b0caa96489
@@ -0,0 +1 @@
1
+ f9b5798c6f565065d6c4f46ff4c35a5d
@@ -0,0 +1 @@
1
+ 3b037d66415ea628b05b72a84333fc86b291a16d
@@ -0,0 +1 @@
1
+ 20cdca46856afd98f615824ac56c65ed6af995b67511c1233b2b2d40eb97eacb
@@ -0,0 +1 @@
1
+ 30af35e2f01368817c5eff8e8217e342bbd7c4727fd3841fee2f221058711705fd90b936eaa6de593728c13edb4a8231a34bb179422a76cbbdf712ac23ba5efe
@@ -0,0 +1 @@
1
+ 518f621bfc037203c5ddd30c3f62c8ad
@@ -0,0 +1 @@
1
+ 65065fce4ddace8e95d235b60cf5a27f93e1162b
@@ -0,0 +1 @@
1
+ cd516e30305ad672e7ed0e8b4f77e992482c9a2979ce92d88a074dc45524cbe9
@@ -0,0 +1 @@
1
+ 00ff273c46cb32923f574fd00189459e9dff6d4782ac561f30583c9610427e270450783485aece4e9ebeb52c12bd3eec1560521d5a0535965dd278c7b44f3848
@@ -3,7 +3,7 @@
3
3
  <modelVersion>4.0.0</modelVersion>
4
4
  <groupId>com.wix</groupId>
5
5
  <artifactId>detox</artifactId>
6
- <version>21.0.0-rc.3</version>
6
+ <version>21.0.0-rc.4</version>
7
7
  <packaging>aar</packaging>
8
8
  <name>Detox</name>
9
9
  <description>Gray box end-to-end testing and automation library for mobile apps</description>
@@ -0,0 +1 @@
1
+ bec6e86b5fe9cac29880ae93505c0ddf
@@ -0,0 +1 @@
1
+ c210d565b6fa1dce343807334bff2bb75c12ed12
@@ -0,0 +1 @@
1
+ 59df9e2d471d3616713ed94b421de6f966e368e49d6d8ded732201e2ac1930be
@@ -0,0 +1 @@
1
+ 1e9296ffe4f38446fa0af45fb900a5a7aef3064e945cd547175c3868e4e5ac5993ec09338a6fb8851f9850999d957c9c7ad3b507add81050aac99608b0f2a195
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>21.0.0-rc.3</latest>
7
- <release>21.0.0-rc.3</release>
6
+ <latest>21.0.0-rc.4</latest>
7
+ <release>21.0.0-rc.4</release>
8
8
  <versions>
9
- <version>21.0.0-rc.3</version>
9
+ <version>21.0.0-rc.4</version>
10
10
  </versions>
11
- <lastUpdated>20230516071413</lastUpdated>
11
+ <lastUpdated>20230810093542</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 66fe5e703071c9f640169ef27912338a
1
+ 0732d5ee6f4b3495e2d10cd42794cf27
@@ -1 +1 @@
1
- 4af316ad0c94b25c53699ebaf5681c155bfb53e1
1
+ ff4243f10217fe52edb738f6ea4d98bed65c843c
@@ -1 +1 @@
1
- 3c4ea37b2e7f651b4e88002f0f219406b8d8c5139d81e59e3783ee1d70346c83
1
+ aeefb21e8358f98751c7243a7f90b0c45639bda9e0a0f5b4f622e674e70b5f42
@@ -1 +1 @@
1
- 97382ce904390550e24cfd86df0f0c07135c2979b0738acc23b63ef0fdb475d7ac025d70695dda51b30fc3ab4a2e2ef05b1973e92f118ad49035e63022611b99
1
+ dcb74aa8487cdf7fc5822ba5fd5b622fb4006d2943be283fb5e910cb79051aa7d6b615054d748468dd3a611d824caea9df34fb8b59a41325f1c660ff5007ca8e
Binary file
package/Detox-ios-src.tbz CHANGED
Binary file
Binary file
@@ -1,11 +1,13 @@
1
1
  buildscript {
2
+ apply from: './rninfo.gradle'
3
+
2
4
  ext {
3
5
  isOfficialDetoxLib = true
4
- kotlinVersion = '1.6.10' // Aligned with RN .69's version bump
6
+ kotlinVersion = '1.8.22'
5
7
  dokkaVersion = '1.6.0'
6
- buildToolsVersion = '31.0.0'
7
- compileSdkVersion = 31
8
- targetSdkVersion = 31
8
+ buildToolsVersion = '33.0.0'
9
+ compileSdkVersion = 33
10
+ targetSdkVersion = 33
9
11
  minSdkVersion = 21
10
12
 
11
13
  if (System.properties['os.arch'] == "aarch64") {
@@ -19,11 +21,14 @@ buildscript {
19
21
  ext.detoxKotlinVersion = ext.kotlinVersion
20
22
 
21
23
  repositories {
22
- mavenCentral()
23
24
  google()
25
+ mavenCentral()
24
26
  }
25
27
  dependencies {
26
- classpath 'com.android.tools.build:gradle:7.2.1'
28
+ if (!rnInfo.isRN71OrNewer) {
29
+ classpath "com.facebook.react:react-native-gradle-plugin"
30
+ }
31
+ classpath 'com.android.tools.build:gradle:7.3.1'
27
32
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
28
33
  classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"
29
34
 
@@ -34,11 +39,16 @@ buildscript {
34
39
 
35
40
  allprojects {
36
41
  repositories {
37
- mavenLocal()
38
- mavenCentral()
39
42
  google()
40
- maven {
41
- url "$projectDir/../../node_modules/react-native/android"
43
+ mavenCentral()
44
+ mavenLocal()
45
+
46
+ // In RN's below 71, the native code comes from within node_modules/ rather
47
+ // than from maven-central.
48
+ if (!rnInfo.isRN71OrNewer) {
49
+ maven {
50
+ url "$projectDir/../../node_modules/react-native/android"
51
+ }
42
52
  }
43
53
  }
44
54
  }
@@ -1,5 +1,6 @@
1
1
  apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-android'
3
+ apply from: '../rninfo.gradle'
3
4
 
4
5
  def _kotlinMinVersion = '1.2.0'
5
6
  def _materialMinVersion = '1.2.1'
@@ -12,6 +13,13 @@ def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 21
12
13
  def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion : _kotlinMinVersion
13
14
  def _kotlinStdlib = _ext.has('detoxKotlinStdlib') ? _ext.detoxKotlinStdlib : 'kotlin-stdlib-jdk8'
14
15
 
16
+ // RN native code comes from either maven-central (in which case, need the *exact* version),
17
+ // or otherwise from node_modules/, where the version is already aligned, by definition.
18
+ // noinspection GradleDynamicVersion
19
+ def _rnNativeArtifact = rnInfo.isRN71OrHigher
20
+ ? "com.facebook.react:react-android:${rnInfo.version}"
21
+ : 'com.facebook.react:react-native:+'
22
+
15
23
  android {
16
24
  compileSdkVersion _compileSdkVersion
17
25
  buildToolsVersion _buildToolsVersion
@@ -78,8 +86,8 @@ android {
78
86
  // Fundamental deps.
79
87
  dependencies {
80
88
  implementation "org.jetbrains.kotlin:$_kotlinStdlib:$_kotlinMinVersion"
81
- //noinspection GradleDynamicVersion
82
- compileOnly 'com.facebook.react:react-native:+'
89
+
90
+ compileOnly "${_rnNativeArtifact}"
83
91
  }
84
92
 
85
93
  // androidx.test deps.
@@ -131,8 +139,7 @@ dependencies {
131
139
 
132
140
  // Unit-testing deps.
133
141
  dependencies {
134
- //noinspection GradleDynamicVersion
135
- testImplementation 'com.facebook.react:react-native:+'
142
+ testImplementation "${_rnNativeArtifact}"
136
143
  testImplementation 'org.json:json:20140107'
137
144
 
138
145
  // https://github.com/spekframework/spek/issues/232#issuecomment-610732158
@@ -14,10 +14,10 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
14
14
  import static androidx.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast;
15
15
  import static androidx.test.espresso.matcher.ViewMatchers.isFocused;
16
16
  import static androidx.test.espresso.matcher.ViewMatchers.isNotChecked;
17
- import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
18
17
  import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
19
- import static androidx.test.espresso.matcher.ViewMatchers.withTagValue;
20
- import static androidx.test.espresso.matcher.ViewMatchers.withText;
18
+ import static com.wix.detox.espresso.matcher.ViewMatchers.withTagValue;
19
+ import static com.wix.detox.espresso.matcher.ViewMatchers.withContentDescription;
20
+ import static com.wix.detox.espresso.matcher.ViewMatchers.withText;
21
21
  import static com.wix.detox.espresso.matcher.ViewMatchers.isMatchingAtIndex;
22
22
  import static com.wix.detox.espresso.matcher.ViewMatchers.isOfClassName;
23
23
  import static com.wix.detox.espresso.matcher.ViewMatchers.toHaveSliderPosition;
@@ -40,25 +40,25 @@ public class DetoxMatcher {
40
40
  // static class
41
41
  }
42
42
 
43
- public static Matcher<View> matcherForText(String text) {
43
+ public static Matcher<View> matcherForText(String text, boolean isRegex) {
44
44
  // return anyOf(withText(text), withContentDescription(text));
45
- return allOf(withText(text), withEffectiveVisibility(Visibility.VISIBLE));
45
+ return allOf(withText(text, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
46
46
  }
47
47
 
48
- public static Matcher<View> matcherForAccessibilityLabel(String label) {
49
- return allOf(withAccessibilityLabel(label), withEffectiveVisibility(Visibility.VISIBLE));
48
+ public static Matcher<View> matcherForAccessibilityLabel(String label, boolean isRegex) {
49
+ return allOf(withAccessibilityLabel(label, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
50
50
  }
51
51
 
52
- public static Matcher<View> matcherForShallowAccessibilityLabel(String label) {
53
- return allOf(withShallowAccessibilityLabel(label), withEffectiveVisibility(Visibility.VISIBLE));
52
+ public static Matcher<View> matcherForShallowAccessibilityLabel(String label, boolean isRegex) {
53
+ return allOf(withShallowAccessibilityLabel(label, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
54
54
  }
55
55
 
56
56
  public static Matcher<View> matcherForContentDescription(String contentDescription) {
57
- return allOf(withContentDescription(contentDescription), withEffectiveVisibility(Visibility.VISIBLE));
57
+ return allOf(withContentDescription(contentDescription, false), withEffectiveVisibility(Visibility.VISIBLE));
58
58
  }
59
59
 
60
- public static Matcher<View> matcherForTestId(String testId) {
61
- return allOf(withTagValue(is((Object) testId)), withEffectiveVisibility(Visibility.VISIBLE));
60
+ public static Matcher<View> matcherForTestId(String testId, boolean isRegex) {
61
+ return allOf(withTagValue(testId, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
62
62
  }
63
63
 
64
64
  public static Matcher<View> matcherForToggleable(boolean value) {
@@ -4,9 +4,9 @@ import android.view.View
4
4
  import androidx.appcompat.widget.AppCompatSeekBar
5
5
  import com.facebook.react.bridge.JavaOnlyMap
6
6
  import com.facebook.react.uimanager.ReactStylesDiffMap
7
- import com.facebook.react.views.slider.ReactSlider
8
7
  import com.wix.detox.common.DetoxErrors.DetoxIllegalStateException
9
8
  import com.wix.detox.espresso.action.common.ReflectUtils
9
+ import com.facebook.react.views.slider.ReactSlider
10
10
  import org.joor.Reflect
11
11
 
12
12
  private const val CLASS_REACT_SLIDER_LEGACY = "com.facebook.react.views.slider.ReactSlider"
@@ -58,7 +58,7 @@ abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
58
58
  }
59
59
  }
60
60
 
61
- private class LegacySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
61
+ private class LegacySliderHelper(slider: ReactSlider): SliderHelper(slider) {
62
62
  override fun setProgressJS(valueJS: Double) {
63
63
  val reactSliderManager = com.facebook.react.views.slider.ReactSliderManager()
64
64
  reactSliderManager.updateProperties(slider as ReactSlider, buildStyles("value", valueJS))
@@ -0,0 +1,56 @@
1
+ package com.wix.detox.espresso.matcher
2
+
3
+ import org.hamcrest.Description
4
+ import org.hamcrest.TypeSafeMatcher
5
+
6
+ class RegexMatcher<T>(private val jsRegex: String) : TypeSafeMatcher<T>() {
7
+ override fun matchesSafely(item: T): Boolean {
8
+ val stringItem = item.toString()
9
+ return stringItem.matchesJSRegex(jsRegex)
10
+ }
11
+
12
+ override fun describeTo(description: Description) {
13
+ description.appendText("should match the pattern: $jsRegex")
14
+ }
15
+ }
16
+
17
+ // Returns whether the whole string matches the given `jsRegex`.
18
+ // JS flags has the format of `/<pattern>/<flags>`.
19
+ // Flags can be either:
20
+ // - i: With this flag the search is case-insensitive: no difference between A and a (see the example below).
21
+ // - s: Enables “dotall” mode, that allows a dot . to match newline character \n (covered in the chapter Character classes).
22
+ // - m: Multiline mode (covered in the chapter Multiline mode of anchors ^ $, flag "m").
23
+ // Other flags (e.g. g,u,s) are not supported as they do not have equivalents in Kotlin.
24
+ //
25
+ // - See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
26
+ fun String.matchesJSRegex(jsRegex: String): Boolean {
27
+ val flagsChars = getRegexFlags(jsRegex)
28
+ val options = getRegexOptions(flagsChars)
29
+ val pattern = getRegexPattern(jsRegex)
30
+ return Regex(pattern, options).matches(this)
31
+ }
32
+
33
+ private fun getRegexFlags(jsRegex: String): CharSequence {
34
+ return jsRegex.substringAfterLast("/")
35
+ }
36
+
37
+ private fun getRegexPattern(jsRegex: String): String {
38
+ val pattern = jsRegex.substringAfter("/")
39
+ return pattern.substringBeforeLast("/")
40
+ }
41
+
42
+ private fun getRegexOptions(flagsChars: CharSequence): MutableSet<RegexOption> {
43
+ val options = mutableSetOf<RegexOption>()
44
+
45
+ if (flagsChars.contains('i', ignoreCase = true)) {
46
+ options.add(RegexOption.IGNORE_CASE)
47
+ }
48
+ if (flagsChars.contains('s', ignoreCase = true)) {
49
+ options.add(RegexOption.DOT_MATCHES_ALL)
50
+ }
51
+ if (flagsChars.contains('m', ignoreCase = true)) {
52
+ options.add(RegexOption.MULTILINE)
53
+ }
54
+
55
+ return options
56
+ }
@@ -11,16 +11,28 @@ import com.wix.detox.espresso.common.SliderHelper
11
11
  import org.hamcrest.*
12
12
  import org.hamcrest.Matchers.*
13
13
  import kotlin.math.abs
14
+ import org.hamcrest.CoreMatchers.`is`
14
15
 
15
16
  /*
16
17
  * An extension of [androidx.test.espresso.matcher.ViewMatchers].
17
18
  */
19
+ fun <T> getRelevantMatcher(value: T, isRegex: Boolean): Matcher<T> =
20
+ if (isRegex) RegexMatcher(value.toString()) else `is`(value)
18
21
 
19
- fun withAccessibilityLabel(text: String) =
20
- WithAccessibilityLabelMatcher(`is`(text))
22
+ fun withAccessibilityLabel(text: String, isRegex: Boolean): Matcher<View> =
23
+ WithAccessibilityLabelMatcher(getRelevantMatcher(text, isRegex))
21
24
 
22
- fun withShallowAccessibilityLabel(label: String): Matcher<View>
23
- = anyOf(ViewMatchers.withContentDescription(label), ViewMatchers.withText(label))
25
+ fun withShallowAccessibilityLabel(label: String, isRegex: Boolean): Matcher<View> =
26
+ anyOf(withContentDescription(label, isRegex), withText(label, isRegex))
27
+
28
+ fun withText(text: String, isRegex: Boolean): Matcher<View> =
29
+ ViewMatchers.withText(getRelevantMatcher(text, isRegex))
30
+
31
+ fun withContentDescription(label: String, isRegex: Boolean): Matcher<View> =
32
+ ViewMatchers.withContentDescription(getRelevantMatcher(label, isRegex))
33
+
34
+ fun withTagValue(testId: String, isRegex: Boolean): Matcher<View> =
35
+ ViewMatchers.withTagValue(getRelevantMatcher<Any>(testId, isRegex))
24
36
 
25
37
  fun isOfClassName(className: String): Matcher<View> {
26
38
  try {
@@ -0,0 +1,52 @@
1
+ package com.wix.detox.espresso.matcher
2
+
3
+ import org.junit.Test
4
+ import kotlin.test.assertFalse
5
+ import kotlin.test.assertTrue
6
+ import org.junit.runner.RunWith
7
+ import org.robolectric.RobolectricTestRunner
8
+
9
+ @RunWith(RobolectricTestRunner::class)
10
+ class RegexMatcherTest {
11
+ @Test
12
+ fun `should work with string matching regex`() {
13
+ val input = "Hello, world!"
14
+ val regex = "/[A-Z][a-z]+, world!/"
15
+ assertTrue(input.matchesJSRegex(regex))
16
+ }
17
+
18
+ @Test
19
+ fun `should work with string not matching regex`() {
20
+ val input = "Hello, world!"
21
+ val regex = "/[A-Z]+, world!/"
22
+ assertFalse(input.matchesJSRegex(regex))
23
+ }
24
+
25
+ @Test
26
+ fun `should work with the 'i' flag`() {
27
+ val input = "Hello, world!"
28
+ val regex = "/[A-Z]+, woRlD!/i"
29
+ assertTrue(input.matchesJSRegex(regex))
30
+ }
31
+
32
+ @Test
33
+ fun `should work with the 's' flag`() {
34
+ val input = "Hello,\nworld!"
35
+ val regex = "/Hello,\\sworld!/s"
36
+ assertTrue(input.matchesJSRegex(regex))
37
+ }
38
+
39
+ @Test
40
+ fun `should work with the 'm' flag`() {
41
+ val input = "Hello,\nworld!"
42
+ val regex = "/^Hello,\\s.*!$/m"
43
+ assertTrue(input.matchesJSRegex(regex))
44
+ }
45
+
46
+ @Test
47
+ fun `should work with multiple flags, ignore casing`() {
48
+ val input = "Hello,\nworld!"
49
+ val regex = "/^heLLo,\\swOrld!/ISM"
50
+ assertTrue(input.matchesJSRegex(regex))
51
+ }
52
+ }
@@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
7
7
 
@@ -0,0 +1,25 @@
1
+ import groovy.json.JsonSlurper
2
+
3
+ def rnVersion = getRNVersion()
4
+ def rnMajorVer = getMajorVersion(rnVersion)
5
+ println "[$project] RNInfo: detected React Native version: $rnVersion (major=$rnMajorVer)"
6
+
7
+ project.ext.rnInfo = [
8
+ version: rnVersion,
9
+ majorVersion: rnMajorVer,
10
+ isRN69OrHigher: rnMajorVer >= 69,
11
+ isRN70OrHigher: rnMajorVer >= 70,
12
+ isRN71OrHigher: rnMajorVer >= 71,
13
+ ]
14
+
15
+ private static def getRNVersion() {
16
+ def jsonSlurper = new JsonSlurper()
17
+ Map<String, Object> packageJSON = jsonSlurper.parse(new File('../node_modules/react-native/package.json'))
18
+ String rnVersion = packageJSON.get('version')
19
+ return rnVersion
20
+ }
21
+
22
+ private static def getMajorVersion(semanticVersion) {
23
+ Integer rnVersionMajor = semanticVersion.split('\\.')[1].toInteger()
24
+ return rnVersionMajor
25
+ }
@@ -1 +1,2 @@
1
- include ':detox'
1
+ include ':detox'
2
+ includeBuild('../node_modules/react-native-gradle-plugin')