suitest-js-api 3.0.0 → 3.1.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 +9 -0
- package/lib/api/wsContentTypes.js +1 -0
- package/lib/commands/getAppConfig.js +23 -0
- package/lib/constants/timestamp.js +1 -1
- package/lib/constants/vrc.js +2 -0
- package/lib/testLauncher/processArgs.js +1 -1
- package/lib/texts.js +6 -0
- package/lib/utils/AuthContext.js +1 -1
- package/lib/utils/socketErrorMessages.js +21 -1
- package/package.json +1 -1
- package/suitest.js +2 -0
- package/typeDefinition/constants/Vrc.d.ts +2 -0
package/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ declare namespace suitest {
|
|
|
53
53
|
pairDevice(deviceId: string): Promise<DeviceData|SuitestError>;
|
|
54
54
|
releaseDevice(): Promise<void|SuitestError>;
|
|
55
55
|
startREPL(options?: ReplOptions): Promise<void>;
|
|
56
|
+
getAppConfig(): Promise<AppConfiguration|SuitestError>;
|
|
56
57
|
|
|
57
58
|
// config
|
|
58
59
|
getConfig(): ConfigureOptions;
|
|
@@ -268,6 +269,14 @@ declare namespace suitest {
|
|
|
268
269
|
accessToken: string;
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
interface AppConfiguration {
|
|
273
|
+
name: string;
|
|
274
|
+
url: string;
|
|
275
|
+
suitestify: boolean;
|
|
276
|
+
domainList: string[];
|
|
277
|
+
variables: Record<string, string>;
|
|
278
|
+
}
|
|
279
|
+
|
|
271
280
|
interface ConfigureOptions {
|
|
272
281
|
logLevel: 'silent'|'normal'|'verbose'|'debug'|'silly';
|
|
273
282
|
disallowCrashReports: boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const wsContentTypes = require('../api/wsContentTypes');
|
|
2
|
+
const chainPromise = require('../utils/chainPromise');
|
|
3
|
+
const {getAppConfigError} = require('../texts');
|
|
4
|
+
const SuitestError = require('../utils/SuitestError');
|
|
5
|
+
|
|
6
|
+
async function getAppConfig({appContext, authContext, webSockets}) {
|
|
7
|
+
const authedContent = await authContext.authorizeWs({
|
|
8
|
+
type: wsContentTypes.getConfiguration,
|
|
9
|
+
configId: appContext._context.configId,
|
|
10
|
+
}, getAppConfig.name);
|
|
11
|
+
|
|
12
|
+
const response = await webSockets.send(authedContent);
|
|
13
|
+
|
|
14
|
+
if (response.result === 'error') {
|
|
15
|
+
throw new SuitestError(getAppConfigError());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return response.configuration;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
getAppConfig: chainPromise(getAppConfig),
|
|
23
|
+
};
|
package/lib/constants/vrc.js
CHANGED
|
@@ -3,7 +3,7 @@ const parser = require('yargs-parser');
|
|
|
3
3
|
// Specify which options should be treated as boolen.
|
|
4
4
|
// This will enable setting boolean option value to true if not defined explicitly,
|
|
5
5
|
// eg: '--disallow-crash-reports' will be parsed as '--disallow-crash-reports=true'
|
|
6
|
-
const booleanOpts = ['disallow-crash-reports'];
|
|
6
|
+
const booleanOpts = ['disallow-crash-reports', 'include-changelist'];
|
|
7
7
|
const inspectOpts = ['inspect', 'inspect-brk'];
|
|
8
8
|
|
|
9
9
|
const parseOptions = argv => {
|
package/lib/texts.js
CHANGED
|
@@ -144,6 +144,11 @@ ${leaves}`,
|
|
|
144
144
|
'errorType.specifyRunningDevices': () => 'Please specify Configuration id and device id, or presets',
|
|
145
145
|
'errorType.notFoundPresets': (notFoundPresets) => `Presets ${notFoundPresets.join(', ')} were not found in your configuration`,
|
|
146
146
|
|
|
147
|
+
'commandError.notSupportedPlatform': () => 'Screenshots are not supported on this device.',
|
|
148
|
+
'commandError.timeout': () => 'Failed to take a screenshot due to timeout.',
|
|
149
|
+
'commandError.generalError': () => 'Failed to take a screenshot.',
|
|
150
|
+
'commandError.notSupportedDriver': () => 'Screenshots are not supported on this driver.',
|
|
151
|
+
|
|
147
152
|
executorStopped: () => 'Test execution was stopped. See our documentation for possible reasons: https://suite.st/docs/error-messages/results-errors/#test-execution-was-stopped',
|
|
148
153
|
|
|
149
154
|
executionAborted: () => 'Test execution was aborted.',
|
|
@@ -166,6 +171,7 @@ ${leaves}`,
|
|
|
166
171
|
usingAppConfig: (id) => `Setting app configuration id: ${id}`,
|
|
167
172
|
usedAppConfig: (id) => `Will use app configuration id: ${id}`,
|
|
168
173
|
useAppConfigOverrides: () => 'Will apply configuration overrides',
|
|
174
|
+
getAppConfigError: () => 'getAppConfig was called before configId initialization',
|
|
169
175
|
|
|
170
176
|
disconnectedFromDevice: () => 'Disconnected from device',
|
|
171
177
|
disconnectingFromDevice: () => 'Disconnecting from device',
|
package/lib/utils/AuthContext.js
CHANGED
|
@@ -37,7 +37,7 @@ const tokenAllowed = {
|
|
|
37
37
|
wsContentTypes.pairDevice, wsContentTypes.releaseDevice,
|
|
38
38
|
wsContentTypes.selectConfiguration, wsContentTypes.query,
|
|
39
39
|
wsContentTypes.eval, wsContentTypes.testLine,
|
|
40
|
-
wsContentTypes.takeScreenshot,
|
|
40
|
+
wsContentTypes.takeScreenshot, wsContentTypes.getConfiguration,
|
|
41
41
|
],
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
const {EOL} = require('os');
|
|
3
|
-
const {path} = require('ramda');
|
|
3
|
+
const {path, has} = require('ramda');
|
|
4
4
|
|
|
5
5
|
const t = require('../texts');
|
|
6
6
|
const chainUtils = require('./chainUtils');
|
|
@@ -94,6 +94,22 @@ const getSnippetLogs = ({testId, definitions, results, level, verbosity}, transl
|
|
|
94
94
|
}, []).filter(Boolean).join('\n');
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
const commandErrors = {
|
|
98
|
+
'notSupportedPlatform': () => t['commandError.notSupportedPlatform'](),
|
|
99
|
+
'timeout': () => t['commandError.timeout'](),
|
|
100
|
+
'generalError': () => t['commandError.generalError'](),
|
|
101
|
+
'notSupportedDriver': () => t['commandError.notSupportedDriver'](),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @description check that response error is related to "command" (not "line") execution.
|
|
106
|
+
* For now it is related only for taking screenshots
|
|
107
|
+
* @param response
|
|
108
|
+
*/
|
|
109
|
+
function isCommandError(response) {
|
|
110
|
+
return response.result === 'error' && has(response.errorType, commandErrors);
|
|
111
|
+
}
|
|
112
|
+
|
|
97
113
|
/**
|
|
98
114
|
* @description Create human readable error message from suitest error response
|
|
99
115
|
* @param verbosity
|
|
@@ -109,6 +125,10 @@ function getErrorMessage({response, jsonMessage, verbosity, snippets}) {
|
|
|
109
125
|
);
|
|
110
126
|
}
|
|
111
127
|
|
|
128
|
+
if (isCommandError(response)) {
|
|
129
|
+
return commandErrors[response.errorType]();
|
|
130
|
+
}
|
|
131
|
+
|
|
112
132
|
return chainUtils.translateLineResult(jsonMessage, verbosity, response);
|
|
113
133
|
}
|
|
114
134
|
|
package/package.json
CHANGED
package/suitest.js
CHANGED
|
@@ -7,6 +7,7 @@ const {closeSession} = require('./lib/commands/closeSession');
|
|
|
7
7
|
const {pairDevice} = require('./lib/commands/pairDevice');
|
|
8
8
|
const releaseDevice = require('./lib/commands/releaseDevice');
|
|
9
9
|
const {setAppConfig} = require('./lib/commands/setAppConfig');
|
|
10
|
+
const {getAppConfig} = require('./lib/commands/getAppConfig');
|
|
10
11
|
|
|
11
12
|
// Chains
|
|
12
13
|
const openAppFactory = require('./lib/chains/openAppChain');
|
|
@@ -98,6 +99,7 @@ class SUITEST_API extends EventEmitter {
|
|
|
98
99
|
this.setAppConfig = (...args) => setAppConfig(this, ...args);
|
|
99
100
|
this.closeSession = (...args) => closeSession(this, ...args);
|
|
100
101
|
this.releaseDevice = (...args) => releaseDevice(this, ...args);
|
|
102
|
+
this.getAppConfig = (...args) => getAppConfig(this, ...args);
|
|
101
103
|
|
|
102
104
|
const {openApp, openAppAssert} = openAppFactory(this);
|
|
103
105
|
const {closeApp, closeAppAssert} = closeAppFactory(this);
|