suitest-js-api 3.4.3 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -40,6 +40,7 @@ import {CloseAppChain} from './typeDefinition/CloseAppChain';
40
40
  import {SuspendAppChain} from './typeDefinition/SuspendAppChain';
41
41
  import {RelativePosition} from './typeDefinition/RelativePositionChain';
42
42
  import {LaunchMode} from './typeDefinition/constants/LaunchMode';
43
+ import {OpenDeepLinkChain} from './typeDefinition/OpenDeepLink';
43
44
 
44
45
  // --------------- Suitest Interface ---------------------- //
45
46
 
@@ -90,18 +91,15 @@ declare namespace suitest {
90
91
  press(keys: string[], options?: { longPressMs?: string | number }): PressButtonChain;
91
92
  sleep(milliseconds: number): SleepChain;
92
93
  window(): WindowChain;
93
-
94
94
  /**
95
95
  * @description return PromiseLike object with Buffer as value
96
96
  */
97
97
  takeScreenshot(dataFormat?: 'raw'): TakeScreenshotChain<Buffer>;
98
98
  setScreenOrientation(orientation: ScreenOrientationValues): SetScreenOrientationChain;
99
-
100
99
  /**
101
100
  * @description return PromiseLike object with base64 string as value
102
101
  */
103
102
  takeScreenshot(dataFormat: 'base64'): TakeScreenshotChain<string>;
104
-
105
103
  /**
106
104
  * @description the complete path to the file name where the screenshot should be saved.
107
105
  * Can be defined as string with placeholders, for example default path
@@ -116,6 +114,7 @@ declare namespace suitest {
116
114
  * suitest.saveScreenshot('{screenshotDir}/{dateTime}-{currentFile}-l{currentLine}.png');
117
115
  */
118
116
  saveScreenshot(fileName?: string): TakeScreenshotChain<void>;
117
+ openDeepLink(deepLink?: string): OpenDeepLinkChain;
119
118
 
120
119
  getPairedDevice(): null | {
121
120
  deviceId: string,
@@ -198,6 +197,7 @@ declare namespace suitest {
198
197
  sleep(milliseconds: number): SleepChain;
199
198
  window(): WindowChain;
200
199
  setScreenOrientation(orientation: ScreenOrientationValues): SetScreenOrientationChain;
200
+ openDeepLink(deepLink?: string): OpenDeepLinkChain;
201
201
  }
202
202
 
203
203
  type NetworkLogEvent = {
@@ -0,0 +1,86 @@
1
+ const makeChain = require('../utils/makeChain');
2
+ const {
3
+ abandonComposer,
4
+ makeToStringComposer,
5
+ makeThenComposer,
6
+ assertComposer,
7
+ cloneComposer,
8
+ gettersComposer,
9
+ makeToJSONComposer,
10
+ } = require('../composers');
11
+ const {invalidInputMessage} = require('../texts');
12
+ const {getRequestType} = require('../utils/socketChainHelper');
13
+ const {validate, validators} = require('../validation');
14
+
15
+ /**
16
+ * @param {SUITEST_API} classInstance
17
+ */
18
+ const openDeepLinkFactory = (classInstance) => {
19
+ const toJSON = (data) => ({
20
+ type: getRequestType(data, false),
21
+ request: {
22
+ type: 'openDeepLink',
23
+ deepLink: data.deepLink,
24
+ },
25
+ });
26
+
27
+ // Build composers
28
+ const toStringComposer = makeToStringComposer(toJSON);
29
+ const thenComposer = makeThenComposer(toJSON);
30
+ const toJSONComposer = makeToJSONComposer(toJSON);
31
+
32
+ /**
33
+ * Function accepts data object of future chain as input
34
+ * and returns a list of composers that should build the chain
35
+ * @param data
36
+ * @returns {*[]}
37
+ */
38
+ const getComposers = (data) => {
39
+ const output = [
40
+ toStringComposer,
41
+ thenComposer,
42
+ cloneComposer,
43
+ gettersComposer,
44
+ toJSONComposer,
45
+ ];
46
+
47
+ if (!data.isAssert) {
48
+ output.push(assertComposer);
49
+ }
50
+
51
+ if (!data.isAbandoned) {
52
+ output.push(abandonComposer);
53
+ }
54
+
55
+ return output;
56
+ };
57
+
58
+ // Chain builder functions
59
+ const openDeepLinkChain = (deepLink) => {
60
+ deepLink = deepLink === undefined ? '' : validate(
61
+ validators.STRING,
62
+ deepLink,
63
+ invalidInputMessage('openDeepLink', 'Deep Link'),
64
+ );
65
+
66
+ return makeChain(
67
+ classInstance,
68
+ getComposers,
69
+ {
70
+ type: 'openDeepLink',
71
+ deepLink,
72
+ },
73
+ );
74
+ };
75
+
76
+ return {
77
+ openDeepLink: openDeepLinkChain,
78
+ openDeepLinkAssert: (deepLink) => openDeepLinkChain(deepLink).toAssert(),
79
+
80
+ // For Unit tests
81
+ getComposers,
82
+ toJSON,
83
+ };
84
+ };
85
+
86
+ module.exports = openDeepLinkFactory;
@@ -56,6 +56,8 @@ const KEY = {
56
56
  SUBTRACT: '[[Subtract]]',
57
57
  TAB: '[[Tab]]',
58
58
  UP_ARROW: '[[Up arrow]]',
59
+ SEARCH: '[[Search]]',
60
+ DONE: '[[Done]]',
59
61
  };
60
62
 
61
63
  Object.freeze(KEY);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suitest-js-api",
3
- "version": "3.4.3",
3
+ "version": "3.6.0",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:SuitestAutomation/suitest-js-api.git",
6
6
  "author": "Suitest <hello@suite.st>",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "dependencies": {
87
87
  "@suitest/smst-to-text": "^4.4.3",
88
- "@suitest/translate": "^4.5.1",
88
+ "@suitest/translate": "^4.6.0",
89
89
  "@types/node": "^14.0.10",
90
90
  "ajv": "^6.12.2",
91
91
  "ansi-regex": "^5.0.0",
package/suitest.js CHANGED
@@ -36,6 +36,7 @@ const networkRequestFactory = require('./lib/chains/networkRequestChain');
36
36
  const videoFactory = require('./lib/chains/videoChain');
37
37
  const playstationVideoFactory = require('./lib/chains/playstationVideoChain');
38
38
  const setScreenOrientationFactory = require('./lib/chains/setScreenOrientationChain');
39
+ const openDeepLinkFactory = require('./lib/chains/openDeepLinkChain');
39
40
 
40
41
  // Constants
41
42
  const {ELEMENT_PROP, VALUE} = require('./lib/constants/element');
@@ -126,6 +127,7 @@ class SUITEST_API extends EventEmitter {
126
127
  const {takeScreenshot} = takeScreenshotFactory(this);
127
128
  const {saveScreenshot} = saveScreenshotFactory(this);
128
129
  const {setScreenOrientation, setScreenOrientationAssert} = setScreenOrientationFactory(this);
130
+ const {openDeepLink, openDeepLinkAssert} = openDeepLinkFactory(this);
129
131
 
130
132
  this.openApp = openApp;
131
133
  this.closeApp = closeApp;
@@ -152,6 +154,7 @@ class SUITEST_API extends EventEmitter {
152
154
  this.takeScreenshot = takeScreenshot;
153
155
  this.saveScreenshot = saveScreenshot;
154
156
  this.setScreenOrientation = setScreenOrientation;
157
+ this.openDeepLink = openDeepLink;
155
158
 
156
159
  this.PROP = ELEMENT_PROP;
157
160
  this.COMP = PROP_COMPARATOR;
@@ -198,6 +201,7 @@ class SUITEST_API extends EventEmitter {
198
201
  video: videoAssert,
199
202
  psVideo: playstationVideoAssert,
200
203
  setScreenOrientation: setScreenOrientationAssert,
204
+ openDeepLink: openDeepLinkAssert,
201
205
  };
202
206
 
203
207
  // Listen to process events to trigger websocket termination and dump warnings, if any
@@ -0,0 +1,12 @@
1
+ import {
2
+ AbstractChain,
3
+ BaseChain
4
+ } from './modifiers';
5
+
6
+ export interface OpenDeepLinkChain extends
7
+ BaseChain<OpenDeepLinkChain, OpenDeepLinkEvalResult, OpenDeepLinkAbandonedChain>
8
+ {}
9
+
10
+ interface OpenDeepLinkAbandonedChain extends AbstractChain {}
11
+
12
+ type OpenDeepLinkEvalResult = void | boolean;
@@ -55,4 +55,6 @@ export type Keys = {
55
55
  SUBTRACT: '[[Subtract]]',
56
56
  TAB: '[[Tab]]',
57
57
  UP_ARROW: '[[Up arrow]]',
58
+ SEARCH: '[[Search]]',
59
+ DONE: '[[Done]]',
58
60
  }