detox 21.0.0-rc.2 → 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.2/detox-21.0.0-rc.2-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.2/detox-21.0.0-rc.2-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.2/detox-21.0.0-rc.2.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.2/detox-21.0.0-rc.2-javadoc.jar.md5 +0 -1
  56. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-javadoc.jar.sha1 +0 -1
  57. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-javadoc.jar.sha256 +0 -1
  58. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-javadoc.jar.sha512 +0 -1
  59. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-sources.jar.md5 +0 -1
  60. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-sources.jar.sha1 +0 -1
  61. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-sources.jar.sha256 +0 -1
  62. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2-sources.jar.sha512 +0 -1
  63. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.aar +0 -0
  64. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.aar.md5 +0 -1
  65. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.aar.sha1 +0 -1
  66. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.aar.sha256 +0 -1
  67. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.aar.sha512 +0 -1
  68. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.pom.md5 +0 -1
  69. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.pom.sha1 +0 -1
  70. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.pom.sha256 +0 -1
  71. package/Detox-android/com/wix/detox/21.0.0-rc.2/detox-21.0.0-rc.2.pom.sha512 +0 -1
  72. package/src/invoke/EarlGrey.js +0 -8
package/src/ios/web.js ADDED
@@ -0,0 +1,280 @@
1
+ const assert = require('assert');
2
+
3
+ const _ = require('lodash');
4
+
5
+ const { DetoxRuntimeError } = require('../errors');
6
+ const { webViewActionDescription, expectDescription } = require('../utils/invocationTraceDescriptions');
7
+ const log = require('../utils/logger').child({ cat: 'ws-client, ws' });
8
+ const traceInvocationCall = require('../utils/traceInvocationCall').bind(null, log);
9
+
10
+
11
+ class WebExpect {
12
+ constructor(invocationManager, element) {
13
+ this._invocationManager = invocationManager;
14
+ this.element = element;
15
+ this.modifiers = [];
16
+ }
17
+
18
+ toHaveText(text) {
19
+ const traceDescription = expectDescription.toHaveText(text);
20
+ return this.expect('toHaveText', traceDescription, text);
21
+ }
22
+
23
+ toExist() {
24
+ const traceDescription = expectDescription.toExist();
25
+ return this.expect('toExist', traceDescription);
26
+ }
27
+
28
+ get not() {
29
+ this.modifiers.push('not');
30
+ return this;
31
+ }
32
+ getText;
33
+ createInvocation(webExpectation, ...params) {
34
+ const definedParams = _.without(params, undefined);
35
+ return {
36
+ type: 'webExpectation',
37
+ ...(this.element.webViewElement !== undefined) && {
38
+ predicate: this.element.webViewElement.matcher.predicate,
39
+ ...(this.element.webViewElement.index !== undefined && { atIndex: this.element.webViewElement.index }),
40
+ },
41
+ webPredicate: this.element.matcher.predicate,
42
+ ...(this.element.index !== undefined && { webAtIndex: this.element.index }),
43
+ ...(this.modifiers.length !== 0 && { webModifiers: this.modifiers }),
44
+ webExpectation,
45
+ ...(definedParams.length !== 0 && { params: definedParams })
46
+ };
47
+ }
48
+
49
+ expect(expectation, traceDescription, ...params) {
50
+ assert(traceDescription, `must provide trace description for expectation: \n ${JSON.stringify(expectation)}`);
51
+
52
+ const invocation = this.createInvocation(expectation, ...params);
53
+ traceDescription = expectDescription.full(traceDescription, this.modifiers.includes('not'));
54
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
55
+ }
56
+ }
57
+
58
+ class WebElement {
59
+ constructor(invocationManager, emitter, webViewElement, matcher, index) {
60
+ this._invocationManager = invocationManager;
61
+ this._emitter = emitter;
62
+ this.webViewElement = webViewElement;
63
+ this.matcher = matcher;
64
+ this.index = index;
65
+ }
66
+
67
+ atIndex(index) {
68
+ if (typeof index !== 'number') throw new DetoxRuntimeError(`atIndex argument must be a number, got ${typeof index}`);
69
+ this.index = index;
70
+ return this;
71
+ }
72
+
73
+ tap() {
74
+ const traceDescription = webViewActionDescription.tap();
75
+ return this.withAction('tap', traceDescription);
76
+ }
77
+
78
+ typeText(text, isContentEditable = false) {
79
+ const traceDescription = webViewActionDescription.typeText(text, isContentEditable);
80
+ return this.withAction('typeText', traceDescription, text, isContentEditable);
81
+ }
82
+
83
+ replaceText(text) {
84
+ const traceDescription = webViewActionDescription.replaceText(text);
85
+ return this.withAction('replaceText', traceDescription, text);
86
+ }
87
+
88
+ clearText() {
89
+ const traceDescription = webViewActionDescription.clearText();
90
+ return this.withAction('clearText', traceDescription);
91
+ }
92
+
93
+ selectAllText() {
94
+ const traceDescription = webViewActionDescription.selectAllText();
95
+ return this.withAction('selectAllText', traceDescription);
96
+ }
97
+
98
+ async getText() {
99
+ const traceDescription = webViewActionDescription.getText();
100
+ let result = await this.withAction('getText', traceDescription);
101
+
102
+ if (result['text']) {
103
+ return result['text'];
104
+ } else {
105
+ throw new DetoxRuntimeError(`Failed to extract text from result: ${JSON.stringify(result)}`);
106
+ }
107
+ }
108
+
109
+ scrollToView() {
110
+ const traceDescription = webViewActionDescription.scrollToView();
111
+ return this.withAction('scrollToView', traceDescription);
112
+ }
113
+
114
+ focus() {
115
+ const traceDescription = webViewActionDescription.focus();
116
+ return this.withAction('focus', traceDescription);
117
+ }
118
+
119
+ moveCursorToEnd() {
120
+ const traceDescription = webViewActionDescription.moveCursorToEnd();
121
+ return this.withAction('moveCursorToEnd', traceDescription);
122
+ }
123
+
124
+ runScript(script) {
125
+ const traceDescription = webViewActionDescription.runScript(script);
126
+ return this.withAction('runScript', traceDescription, script);
127
+ }
128
+
129
+ runScriptWithArgs(script, ...args) {
130
+ const traceDescription = webViewActionDescription.runScriptWithArgs(script, ...args);
131
+ return this.withAction('runScriptWithArgs', traceDescription, script, ...args);
132
+ }
133
+
134
+ async getCurrentUrl() {
135
+ const traceDescription = webViewActionDescription.getCurrentUrl();
136
+ let result = await this.withAction('getCurrentUrl', traceDescription);
137
+
138
+ if (result['url']) {
139
+ return result['url'];
140
+ } else {
141
+ throw new DetoxRuntimeError(`Failed to extract url from result: ${JSON.stringify(result)}`);
142
+ }
143
+ }
144
+
145
+ async getTitle() {
146
+ const traceDescription = webViewActionDescription.getTitle();
147
+ let result = await this.withAction('getTitle', traceDescription);
148
+
149
+ if (result['title']) {
150
+ return result['title'];
151
+ } else {
152
+ throw new DetoxRuntimeError(`Failed to extract title from result: ${JSON.stringify(result)}`);
153
+ }
154
+ }
155
+
156
+ withAction(action, traceDescription, ...params) {
157
+ assert(traceDescription, `must provide trace description for action: \n ${JSON.stringify(action)}`);
158
+
159
+ const invocation = {
160
+ type: 'webAction',
161
+ ...(this.webViewElement !== undefined) && {
162
+ predicate: this.webViewElement.matcher.predicate,
163
+ ...(this.webViewElement.index !== undefined && { atIndex: this.webViewElement.index }),
164
+ },
165
+ webPredicate: this.matcher.predicate,
166
+ ...(this.index !== undefined && { webAtIndex: this.index }),
167
+ webAction: action,
168
+ ...(params.length !== 0 && { params }),
169
+ };
170
+ traceDescription = webViewActionDescription.full(traceDescription);
171
+ return _executeInvocation(this._invocationManager, invocation, traceDescription);
172
+ }
173
+ }
174
+
175
+ class WebElementMatcher {
176
+ id(id) {
177
+ if (typeof id !== 'string') throw new DetoxRuntimeError('id should be a string, but got ' + (id + (' (' + (typeof id + ')'))));
178
+ this.predicate = { type: 'id', value: id.toString() };
179
+ return this;
180
+ }
181
+
182
+ className(className) {
183
+ if (typeof className !== 'string') throw new DetoxRuntimeError('className should be a string, but got ' + (className + (' (' + (typeof className + ')'))));
184
+ this.predicate = { type: 'class', value: className.toString() };
185
+ return this;
186
+ }
187
+
188
+ cssSelector(cssSelector) {
189
+ if (typeof cssSelector !== 'string') throw new DetoxRuntimeError('cssSelector should be a string, but got ' + (cssSelector + (' (' + (typeof cssSelector + ')'))));
190
+ this.predicate = { type: 'css', value: cssSelector.toString() };
191
+ return this;
192
+ }
193
+
194
+ name(name) {
195
+ if (typeof name !== 'string') throw new DetoxRuntimeError('name should be a string, but got ' + (name + (' (' + (typeof name + ')'))));
196
+ this.predicate = { type: 'name', value: name.toString() };
197
+ return this;
198
+ }
199
+
200
+ xpath(xpath) {
201
+ if (typeof xpath !== 'string') throw new DetoxRuntimeError('xpath should be a string, but got ' + (xpath + (' (' + (typeof xpath + ')'))));
202
+ this.predicate = { type: 'xpath', value: xpath.toString() };
203
+ return this;
204
+ }
205
+
206
+ href(href) {
207
+ if (typeof href !== 'string') throw new DetoxRuntimeError('href should be a string, but got ' + (href + (' (' + (typeof href + ')'))));
208
+ this.predicate = { type: 'href', value: href.toString() };
209
+ return this;
210
+ }
211
+
212
+ hrefContains(href) {
213
+ if (typeof href !== 'string') throw new DetoxRuntimeError('href should be a string, but got ' + (href + (' (' + (typeof href + ')'))));
214
+ this.predicate = { type: 'hrefContains', value: href.toString() };
215
+ return this;
216
+ }
217
+
218
+ tag(tag) {
219
+ if (typeof tag !== 'string') throw new DetoxRuntimeError('tag should be a string, but got ' + (tag + (' (' + (typeof tag + ')'))));
220
+ this.predicate = { type: 'tag', value: tag.toString() };
221
+ return this;
222
+ }
223
+
224
+ label(label) {
225
+ if (typeof label !== 'string') throw new DetoxRuntimeError('label should be a string, but got ' + (label + (' (' + (typeof label + ')'))));
226
+ this.predicate = { type: 'label', value: label.toString() };
227
+ return this;
228
+ }
229
+
230
+ value(value) {
231
+ if (typeof value !== 'string') throw new DetoxRuntimeError('value should be a string, but got ' + (value + (' (' + (typeof value + ')'))));
232
+ this.predicate = { type: 'value', value: value.toString() };
233
+ return this;
234
+ }
235
+ }
236
+
237
+ function webMatcher() {
238
+ return new WebElementMatcher();
239
+ }
240
+
241
+ function webElement(invocationManager, emitter, webViewElement, matcher) {
242
+ if (!(matcher instanceof WebElementMatcher)) {
243
+ throwWebViewMatcherError(matcher);
244
+ }
245
+
246
+ return new WebElement(invocationManager, emitter, webViewElement, matcher);
247
+ }
248
+
249
+ function throwWebViewMatcherError(param) {
250
+ const paramDescription = JSON.stringify(param);
251
+ throw new DetoxRuntimeError(`${paramDescription} is not a Detox web-view matcher. More about web-view matchers here: https://wix.github.io/Detox/docs/api/webviews`);
252
+ }
253
+
254
+ function webExpect(invocationManager, element) {
255
+ if (!(element instanceof WebElement)) {
256
+ throwWebElementError(element);
257
+ }
258
+
259
+ return new WebExpect(invocationManager, element);
260
+ }
261
+
262
+ function throwWebElementError(param) {
263
+ const paramDescription = JSON.stringify(param);
264
+ throw new DetoxRuntimeError(`${paramDescription} is not a web element. More about web elements here: https://wix.github.io/Detox/docs/api/webviews`);
265
+ }
266
+
267
+ function _executeInvocation(invocationManager, invocation, traceDescription) {
268
+ return traceInvocationCall(traceDescription, invocation, invocationManager.execute(invocation));
269
+ }
270
+
271
+ function isWebElement(element) {
272
+ return element instanceof WebElement;
273
+ }
274
+
275
+ module.exports = {
276
+ webMatcher,
277
+ webElement,
278
+ webExpect,
279
+ isWebElement
280
+ };
@@ -51,8 +51,7 @@ class DetoxPrimaryContext extends DetoxContext {
51
51
  }
52
52
  }
53
53
 
54
- async [symbols.resolveConfig](opts = { argv: { configuration: process.env.DETOX_DBG_SELECTED_CFG } })
55
- {
54
+ async [symbols.resolveConfig](opts = {}) {
56
55
  const session = this[$sessionState];
57
56
  if (!session.detoxConfig) {
58
57
  const configuration = require('../configuration');
@@ -26,6 +26,22 @@ module.exports = {
26
26
  tapReturnKey: () => 'tap on return key',
27
27
  typeText: (value) => `type input text: "${value}"`,
28
28
  },
29
+ webViewActionDescription: {
30
+ tap: (value) => `tap${value !== undefined ? ` at ${JSON.stringify(value)}` : ''}`,
31
+ typeText: (value, isContentEditable) => `type input text: "${value}"${isContentEditable ? ' in content editable' : ''}`,
32
+ replaceText: (value) => `replace input text: "${value}"`,
33
+ clearText: () => 'clear input text',
34
+ selectAllText: () => 'select all input text',
35
+ getText: () => 'get input text',
36
+ scrollToView: () => 'scroll to view',
37
+ focus: () => 'focus',
38
+ moveCursorToEnd: () => 'move cursor to end',
39
+ runScript: (script) => `run script: "${script}"`,
40
+ runScriptWithArgs: (script, ...args) => `run script: "${script}" with args: "${args}"`,
41
+ getCurrentUrl: () => 'get current url',
42
+ getTitle: () => 'get title',
43
+ full: (actionDescription) => `perform web view action: ${actionDescription}`
44
+ },
29
45
  expectDescription: {
30
46
  waitFor: (actionDescription) => `wait for expectation while ${actionDescription}`,
31
47
  waitForWithTimeout: (expectDescription, timeout) => `${expectDescription} with timeout (${timeout} ms)`,
@@ -0,0 +1,7 @@
1
+ function isRegExp(obj) {
2
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
3
+ }
4
+
5
+ module.exports = {
6
+ isRegExp,
7
+ };
@@ -1 +0,0 @@
1
- df916bfc455f017d41e9b23a6a432ec1
@@ -1 +0,0 @@
1
- 82904cc30c902887e9090ed04190ba6867fd8075
@@ -1 +0,0 @@
1
- d345d977d07f6e1e53b245a85fdff173dfdce0d2a5c5f6e0ca24cc1468488d13
@@ -1 +0,0 @@
1
- c647905b1356442716067ce1b6d9bc251214faabb763152db80b4ffd746a847b7482fa315fb77205ed1995b6bb015fd0089f64644d42eeb152393e1e676c8882
@@ -1 +0,0 @@
1
- 0f6d42884d0ca5c4d41fd17756eea327
@@ -1 +0,0 @@
1
- 0c956525e709e751ea06adadf2badd47b92c2698
@@ -1 +0,0 @@
1
- efdef3b850657cb7515e92d59ac0b5e6cd988dbbf486176583968fee3afd731b
@@ -1 +0,0 @@
1
- 2b4e483991f415a3d3a16d53aab5990ebb518754180745602404c841d82a36c77c2e7f943b7c553cf5e8e70e7deee5f0f389694155329e2c734cf5b6f359d4d9
@@ -1 +0,0 @@
1
- e89d3204dcda439e4deb0df61603394a
@@ -1 +0,0 @@
1
- eda5c226e954731b3dbd16becbab72f66888d5ce
@@ -1 +0,0 @@
1
- 4da9ab41881efc27c7268bff2bfbb7092d9dbdf6de8f43787b4df649f0291bff
@@ -1 +0,0 @@
1
- c63bf901eb0327ca3791b419f99dd67060a9b48a816da5c71e7e660e60fed607347ef8f76710969e9497054cc4f99add8db19f47b7e780ee3e6413df6d75e195
@@ -1 +0,0 @@
1
- a26e8e63d6adac9bb7b97700d2302fd8
@@ -1 +0,0 @@
1
- 81dbf8383da754db010bbeef48eec0d501a1ce43
@@ -1 +0,0 @@
1
- 03f5f00de811d509f2d28983bf259b2a87ee69096b832f452b6ea47157a76909
@@ -1 +0,0 @@
1
- dad16f5ddbfa5f193cf2d5441e67bb7a6780526feddbbb692ff6f44afb4b2d8729ad3923fe510131f9da55340579d7b4fb5a1c129ea151184b3eb369076d6755
@@ -1,8 +0,0 @@
1
- const instance = {
2
- type: 'EarlGrey',
3
- value: 'instance'
4
- };
5
-
6
- module.exports = {
7
- instance
8
- };