@testim/testim-cli 3.289.0 → 3.290.0-beta

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.
Files changed (217) hide show
  1. package/cli.js +22390 -122
  2. package/cli.js.map +1 -0
  3. package/npm-shrinkwrap.json +8 -29129
  4. package/package.json +16 -10
  5. package/OverrideTestDataBuilder.js +0 -117
  6. package/agent/routers/cliJsCode/index.js +0 -13
  7. package/agent/routers/cliJsCode/router.js +0 -63
  8. package/agent/routers/cliJsCode/service.js +0 -705
  9. package/agent/routers/codim/router.js +0 -69
  10. package/agent/routers/codim/router.test.js +0 -60
  11. package/agent/routers/codim/service.js +0 -193
  12. package/agent/routers/general/index.js +0 -36
  13. package/agent/routers/hybrid/registerRoutes.js +0 -81
  14. package/agent/routers/index.js +0 -56
  15. package/agent/routers/playground/router.js +0 -77
  16. package/agent/routers/playground/service.js +0 -96
  17. package/agent/routers/standalone-browser/registerRoutes.js +0 -47
  18. package/agent/server.js +0 -150
  19. package/cdpTestRunner.js +0 -86
  20. package/chromiumInstaller.js +0 -91
  21. package/cli/isCiRun.js +0 -10
  22. package/cli/onExit.js +0 -65
  23. package/cli/writeStackTrace.js +0 -27
  24. package/cliAgentMode.js +0 -384
  25. package/codim/codim-cli.js +0 -91
  26. package/codim/codim-npm-package/index.ts +0 -427
  27. package/codim/codim-npm-package/package-lock.json +0 -14
  28. package/codim/codim-npm-package/package.json +0 -14
  29. package/codim/hybrid-utils.js +0 -28
  30. package/codim/measure-perf.js +0 -41
  31. package/codim/template.js/.idea/workspace.xml +0 -57
  32. package/codim/template.js/.vscode/launch.json +0 -53
  33. package/codim/template.ts/.idea/workspace.xml +0 -57
  34. package/codim/template.ts/.vscode/launch.json +0 -55
  35. package/commons/AbortError.js +0 -12
  36. package/commons/SeleniumPerfStats.js +0 -58
  37. package/commons/chrome-launcher.js +0 -15
  38. package/commons/chromedriverWrapper.js +0 -70
  39. package/commons/config.js +0 -39
  40. package/commons/constants.js +0 -67
  41. package/commons/detectDebugger.js +0 -19
  42. package/commons/featureAvailabilityService.js +0 -26
  43. package/commons/featureFlags.js +0 -132
  44. package/commons/getSessionPlayerRequire.js +0 -28
  45. package/commons/httpRequest.js +0 -261
  46. package/commons/httpRequestCounters.js +0 -98
  47. package/commons/httpRequestCounters.test.js +0 -38
  48. package/commons/initializeUserWithAuth.js +0 -55
  49. package/commons/lazyRequire.js +0 -105
  50. package/commons/logUtils.js +0 -15
  51. package/commons/logUtils.test.js +0 -21
  52. package/commons/logger.js +0 -178
  53. package/commons/mockNetworkRuleFileSchema.json +0 -140
  54. package/commons/npmWrapper.js +0 -174
  55. package/commons/npmWrapper.test.js +0 -374
  56. package/commons/performance-logger.js +0 -71
  57. package/commons/preloadTests.js +0 -29
  58. package/commons/prepareRunner.js +0 -85
  59. package/commons/prepareRunner.test.js +0 -144
  60. package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
  61. package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
  62. package/commons/requireWithFallback.js +0 -25
  63. package/commons/runnerFileCache.js +0 -204
  64. package/commons/socket/baseSocketServiceSocketIO.js +0 -197
  65. package/commons/socket/realDataService.js +0 -59
  66. package/commons/socket/realDataServiceSocketIO.js +0 -33
  67. package/commons/socket/remoteStepService.js +0 -55
  68. package/commons/socket/remoteStepServiceSocketIO.js +0 -61
  69. package/commons/socket/socketService.js +0 -175
  70. package/commons/socket/testResultService.js +0 -62
  71. package/commons/socket/testResultServiceSocketIO.js +0 -64
  72. package/commons/testimAnalytics.js +0 -40
  73. package/commons/testimCloudflare.js +0 -83
  74. package/commons/testimCloudflare.test.js +0 -185
  75. package/commons/testimCustomToken.js +0 -124
  76. package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
  77. package/commons/testimNgrok.js +0 -90
  78. package/commons/testimNgrok.test.js +0 -140
  79. package/commons/testimServicesApi.js +0 -631
  80. package/commons/testimTunnel.js +0 -73
  81. package/commons/testimTunnel.test.js +0 -172
  82. package/commons/xhr2.js +0 -897
  83. package/coverage/SummaryToObjectReport.js +0 -19
  84. package/coverage/jsCoverage.js +0 -252
  85. package/credentialsManager.js +0 -142
  86. package/errors.js +0 -161
  87. package/executionQueue.js +0 -37
  88. package/fixLocalBuild.js +0 -24
  89. package/inputFileUtils.js +0 -103
  90. package/lib/coralogix-winston.transport.js +0 -99
  91. package/player/SeleniumProtocolError.js +0 -100
  92. package/player/WebDriverHttpRequest.js +0 -177
  93. package/player/WebdriverioWebDriverApi.js +0 -671
  94. package/player/appiumTestPlayer.js +0 -90
  95. package/player/chromeLauncherTestPlayer.js +0 -67
  96. package/player/constants.js +0 -332
  97. package/player/extensionTestPlayer.js +0 -32
  98. package/player/findElementStrategy.js +0 -154
  99. package/player/scripts/isElementDisplayed.js +0 -252
  100. package/player/seleniumTestPlayer.js +0 -140
  101. package/player/services/frameLocator.js +0 -170
  102. package/player/services/mobileFrameLocatorMock.js +0 -32
  103. package/player/services/playbackTimeoutCalculator.js +0 -175
  104. package/player/services/portSelector.js +0 -19
  105. package/player/services/tabService.js +0 -551
  106. package/player/services/tabServiceMock.js +0 -167
  107. package/player/services/windowCreationListener.js +0 -8
  108. package/player/stepActions/RefreshStepAction.js +0 -16
  109. package/player/stepActions/apiStepAction.js +0 -89
  110. package/player/stepActions/baseCliJsStepAction.js +0 -51
  111. package/player/stepActions/baseJsStepAction.js +0 -277
  112. package/player/stepActions/cliConditionStepAction.js +0 -11
  113. package/player/stepActions/cliJsStepAction.js +0 -11
  114. package/player/stepActions/dropFileStepAction.js +0 -34
  115. package/player/stepActions/evaluateExpressionStepAction.js +0 -52
  116. package/player/stepActions/extensionOnlyStepAction.js +0 -12
  117. package/player/stepActions/extractTextStepAction.js +0 -19
  118. package/player/stepActions/hoverStepAction.js +0 -55
  119. package/player/stepActions/inputFileStepAction.js +0 -199
  120. package/player/stepActions/jsCodeStepAction.js +0 -11
  121. package/player/stepActions/jsConditionStepAction.js +0 -11
  122. package/player/stepActions/locateStepAction.js +0 -159
  123. package/player/stepActions/mouseStepAction.js +0 -370
  124. package/player/stepActions/navigationStepAction.js +0 -29
  125. package/player/stepActions/nodePackageStepAction.js +0 -47
  126. package/player/stepActions/pixelValidationStepAction.js +0 -39
  127. package/player/stepActions/scripts/dispatchEvents.js +0 -282
  128. package/player/stepActions/scripts/doClick.js +0 -221
  129. package/player/stepActions/scripts/doDragPath.js +0 -225
  130. package/player/stepActions/scripts/doubleClick.js +0 -119
  131. package/player/stepActions/scripts/dropEvent.js +0 -63
  132. package/player/stepActions/scripts/focusElement.js +0 -46
  133. package/player/stepActions/scripts/html5dragAction.js +0 -56
  134. package/player/stepActions/scripts/html5dragActionV2.js +0 -312
  135. package/player/stepActions/scripts/runCode.js +0 -147
  136. package/player/stepActions/scripts/scroll.js +0 -90
  137. package/player/stepActions/scripts/selectOption.js +0 -51
  138. package/player/stepActions/scripts/setText.js +0 -415
  139. package/player/stepActions/scripts/wheel.js +0 -61
  140. package/player/stepActions/scrollStepAction.js +0 -96
  141. package/player/stepActions/selectOptionStepAction.js +0 -49
  142. package/player/stepActions/sfdcRecordedStepAction.js +0 -24
  143. package/player/stepActions/sfdcStepAction.js +0 -28
  144. package/player/stepActions/sleepStepAction.js +0 -12
  145. package/player/stepActions/specialKeyStepAction.js +0 -52
  146. package/player/stepActions/stepAction.js +0 -73
  147. package/player/stepActions/stepActionRegistrar.js +0 -111
  148. package/player/stepActions/submitStepAction.js +0 -12
  149. package/player/stepActions/tdkHybridStepAction.js +0 -18
  150. package/player/stepActions/textStepAction.js +0 -110
  151. package/player/stepActions/textValidationStepAction.js +0 -64
  152. package/player/stepActions/wheelStepAction.js +0 -41
  153. package/player/utils/cookieUtils.js +0 -39
  154. package/player/utils/eyeSdkService.js +0 -250
  155. package/player/utils/imageCaptureUtils.js +0 -267
  156. package/player/utils/screenshotUtils.js +0 -68
  157. package/player/utils/stepActionUtils.js +0 -90
  158. package/player/utils/windowUtils.js +0 -195
  159. package/player/webDriverUtils.js +0 -40
  160. package/player/webDriverUtils.test.js +0 -116
  161. package/player/webdriver.js +0 -976
  162. package/polyfills/Array.prototype.at.js +0 -13
  163. package/polyfills/index.js +0 -13
  164. package/processHandler.js +0 -79
  165. package/processHandler.test.js +0 -55
  166. package/reports/chromeReporter.js +0 -17
  167. package/reports/consoleReporter.js +0 -190
  168. package/reports/debugReporter.js +0 -82
  169. package/reports/jsonReporter.js +0 -55
  170. package/reports/junitReporter.js +0 -183
  171. package/reports/reporter.js +0 -166
  172. package/reports/reporterUtils.js +0 -54
  173. package/reports/teamCityReporter.js +0 -73
  174. package/runOptions.d.ts +0 -305
  175. package/runOptions.js +0 -1288
  176. package/runOptionsAgentFlow.js +0 -87
  177. package/runOptionsUtils.js +0 -60
  178. package/runner.js +0 -355
  179. package/runners/ParallelWorkerManager.js +0 -284
  180. package/runners/TestPlanRunner.js +0 -419
  181. package/runners/buildCodeTests.js +0 -159
  182. package/runners/runnerUtils.js +0 -81
  183. package/services/analyticsService.js +0 -96
  184. package/services/branchService.js +0 -29
  185. package/services/gridService.js +0 -357
  186. package/services/gridService.test.js +0 -357
  187. package/services/labFeaturesService.js +0 -64
  188. package/services/lambdatestService.js +0 -227
  189. package/services/lambdatestService.test.js +0 -353
  190. package/services/localRCASaver.js +0 -124
  191. package/stepPlayers/cliJsStepPlayback.js +0 -40
  192. package/stepPlayers/hybridStepPlayback.js +0 -140
  193. package/stepPlayers/nodePackageStepPlayback.js +0 -28
  194. package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
  195. package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
  196. package/stepPlayers/remoteStepPlayback.js +0 -80
  197. package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
  198. package/stepPlayers/tdkHybridStepPlayback.js +0 -112
  199. package/testRunHandler.js +0 -603
  200. package/testRunStatus.js +0 -567
  201. package/testimNpmDriver.js +0 -52
  202. package/utils/argsUtils.js +0 -91
  203. package/utils/argsUtils.test.js +0 -32
  204. package/utils/fsUtils.js +0 -174
  205. package/utils/index.js +0 -197
  206. package/utils/promiseUtils.js +0 -85
  207. package/utils/stringUtils.js +0 -98
  208. package/utils/stringUtils.test.js +0 -22
  209. package/utils/timeUtils.js +0 -25
  210. package/utils/utils.test.js +0 -27
  211. package/workers/BaseWorker.js +0 -498
  212. package/workers/BaseWorker.test.js +0 -186
  213. package/workers/WorkerAppium.js +0 -180
  214. package/workers/WorkerExtension.js +0 -192
  215. package/workers/WorkerExtensionSingleBrowser.js +0 -77
  216. package/workers/WorkerSelenium.js +0 -253
  217. package/workers/workerUtils.js +0 -20
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- // Only for extension mode
4
- class WindowCreationListener {
5
- on(){}
6
- }
7
-
8
- module.exports = new WindowCreationListener();
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
-
5
- class RefreshStepAction extends StepAction {
6
- async execute() {
7
- try {
8
- await this.driver.reloadTab();
9
- return { success: true };
10
- } catch (error) {
11
- return { success: false, reason: error.message };
12
- }
13
- }
14
- }
15
-
16
- module.exports = RefreshStepAction;
@@ -1,89 +0,0 @@
1
- // @ts-check
2
-
3
- 'use strict';
4
-
5
- const StepAction = require('./stepAction');
6
-
7
- class ApiStepAction extends StepAction {
8
- async runApiInAut(eventData) {
9
- eventData.withCredentials = true;
10
- const timeout = this.context.data.timeToPlayStep + 3000;
11
- const { apiCall } = this.sessionPlayerInit;
12
- try {
13
- const autRes = await this.driver.executeCodeAsync(apiCall, timeout, eventData);
14
- const resp = autRes?.value;
15
- return resp || {};
16
- } catch (err) {
17
- if (err?.message?.includes('Javascript execution context no longer exists')) {
18
- throw new Error(
19
- 'The page refreshed or changed while executing this step. Please consider unchecking "Send via web page" if this is expected.');
20
- }
21
- throw err;
22
- }
23
- }
24
-
25
- runApiInBg(eventData) {
26
- const { apiCall } = this.sessionPlayerInit;
27
- return new Promise(resolve => { apiCall(eventData, resolve); });
28
- }
29
-
30
- async performAction() {
31
- const { commonConstants } = this.sessionPlayerInit;
32
- /** @type {import('clickim/src/common/models/apiStep').ApiStep} */
33
- const step = this.step;
34
- const context = this.context;
35
-
36
- const eventData = {
37
- id: step.id,
38
- url: context.apiUrl,
39
- method: step.method,
40
- headers: context.apiHeaders,
41
- body: context.apiBody,
42
- timeout: context.data.maxTotalStepTime,
43
- omitCookies: step.omitCookies,
44
- formData: step.formData,
45
- fileUrls: context.fileUrls,
46
- };
47
-
48
- let resp;
49
- if (step.sendViaWebApp) {
50
- resp = await this.runApiInAut(eventData);
51
- } else {
52
- resp = await this.runApiInBg(eventData);
53
- }
54
- const result = resp.result || {};
55
- const resultInfo = {
56
- method: step.method,
57
- status: result.status,
58
- url: step.url,
59
- };
60
- if (resp.success) {
61
- if (result.status === 0) {
62
- return {
63
- result,
64
- resultInfo,
65
- shouldRetry: false,
66
- success: false,
67
- reason: 'Connection problem',
68
- errorType: commonConstants.stepResult.API_REQUEST_NETWORK_ERROR,
69
- };
70
- }
71
- return {
72
- result,
73
- resultInfo,
74
- shouldRetry: false,
75
- success: true,
76
- };
77
- }
78
- return {
79
- result,
80
- resultInfo,
81
- shouldRetry: false,
82
- success: false,
83
- reason: result.error || commonConstants.error.REQUEST_TIMED_OUT,
84
- errorType: result.error ? commonConstants.stepResult.API_FAILURE : commonConstants.stepResult.API_REQUEST_NETWORK_ERROR,
85
- };
86
- }
87
- }
88
-
89
- module.exports = ApiStepAction;
@@ -1,51 +0,0 @@
1
- 'use strict';
2
-
3
- const utils = require('../../utils');
4
- const BaseJsStepAction = require('./baseJsStepAction');
5
- const service = require('../../agent/routers/cliJsCode/service');
6
-
7
- class BaseCliJsStepAction extends BaseJsStepAction {
8
- async executeCliCode() {
9
- const { step, context } = this;
10
- const isMobile = this.stepActionUtils.driver.isMobile;
11
- const hasCliAction = context.company?.activePlan?.premiumFeatures?.cliAction;
12
-
13
- if (!hasCliAction && !isMobile) {
14
- return {
15
- success: 'skipped',
16
- reason: 'CLI action is not enabled in your current plan',
17
- };
18
- }
19
-
20
- const { code, id } = step;
21
- const { incomingParams, testResultId, retryIndex, stepResultId } = context;
22
- const contextData = {
23
- config: context.config,
24
- data: context.data,
25
- };
26
- const runTimeout = context.data.timeToPlayStep;
27
- const data = await service.runCodeWithPackages(code, id, incomingParams, contextData, testResultId, retryIndex, stepResultId, runTimeout);
28
- return await this.checkCodeResponse(data);
29
- }
30
-
31
- async performAction() {
32
- try {
33
- return await this.executeCliCode();
34
- } catch (err) {
35
- const { stepResult } = this.sessionPlayerInit.commonConstants;
36
- if (err instanceof utils.TimeoutError) {
37
- return {
38
- success: false,
39
- errorType: stepResult.ACTION_TIMEOUT,
40
- };
41
- }
42
- return {
43
- success: false,
44
- reason: err.message,
45
- exception: err,
46
- };
47
- }
48
- }
49
- }
50
-
51
- module.exports = BaseCliJsStepAction;
@@ -1,277 +0,0 @@
1
- 'use strict';
2
-
3
-
4
- const _ = require('lodash');
5
- const utils = require('../../utils');
6
- const StepAction = require('./stepAction');
7
- const runnerUtils = require('../../utils');
8
- const runCodeScript = require('./scripts/runCode');
9
- const featureFlags = require('../../commons/featureFlags');
10
- const { getLogger } = require('../../commons/logger');
11
-
12
- const logger = getLogger('base-js-step-action');
13
-
14
-
15
- class BaseJsStepAction extends StepAction {
16
- isExceedingMaxResultSize(data, context) {
17
- try {
18
- const shouldEnforceMaxSize = context.project.defaults.enforceMaximumJsResultSize;
19
- const maximumJsResultSize = featureFlags.flags.maximumJsResultSize.getValue();
20
- const dataSizeExceeded = JSON.stringify(data).length > maximumJsResultSize;
21
- if (!shouldEnforceMaxSize) {
22
- if (dataSizeExceeded) {
23
- logger.warn(`js result size exceeded ${maximumJsResultSize}, stepId: ${this.step.id}`);
24
- }
25
- return false;
26
- }
27
- return dataSizeExceeded;
28
- } catch (e) {
29
- return false;
30
- }
31
- }
32
-
33
- executeGetStatus(transactionId) {
34
- return this.driver.executeJS(_transactionId => {
35
- /* eslint-disable no-undef */
36
- const sessionItem = `data-testim-${_transactionId}`;
37
- try {
38
- return window.sessionStorage.getItem(sessionItem);
39
- } catch (err) {
40
- if (
41
- err.message.includes('sessionStorage') || // Chrome + Firefox
42
- err.message.includes('The operation is insecure') // Safari
43
- ) {
44
- const storage = document.head.querySelector('#testim-storage-backup');
45
- if (!storage) {
46
- return '{}';
47
- }
48
- return storage.getAttribute(sessionItem);
49
- }
50
- throw err;
51
- }
52
- /* eslint-enable no-undef */
53
- }, transactionId);
54
- }
55
-
56
- constructJSFunParams(eventData) {
57
- const incomingParams = eventData.incomingParams;
58
-
59
- const params = [
60
- 'context', ...incomingParams.as.functionParameters,
61
- 'exports', 'exportsTest', 'exportsGlobal',
62
- ];
63
-
64
- const args = [eventData.context, ...incomingParams.as.functionArguments];
65
-
66
- params.push(eventData.code);
67
- args.forEach(arg => {
68
- if (_.isObject(arg)) {
69
- runnerUtils.removePropertyFromObject(arg, 'seleniumElement', _.isEqual);
70
- }
71
- });
72
- return {
73
- function: {
74
- params,
75
- args,
76
- },
77
- transactionId: eventData.transactionId,
78
- browser: eventData.browser,
79
- browserMajor: eventData.browserMajor,
80
- };
81
- }
82
-
83
-
84
- checkStatus(transactionId) {
85
- const that = this;
86
- const retryInterval = that.context.config.retryTimeout;
87
- let timeToPlayStep = that.context.data.timeToPlayStep - retryInterval;
88
- async function checkScriptStatus() {
89
- let selRes;
90
- try {
91
- selRes = await that.executeGetStatus(transactionId);
92
- } catch (err) {
93
- logger.warn('failed to get js status', { err });
94
- selRes = { value: { status: 'exception' } };
95
- }
96
- let res;
97
- try {
98
- res = JSON.parse(selRes ? selRes.value : '{}');
99
- } catch (e) {
100
- logger.warn('non object value', { selRes });
101
- res = { status: 'exception' };
102
- }
103
- const abortReason = that.stepActionUtils.abortedSteps.find(abortedStep => abortedStep.id === that.step.id);
104
- if (abortReason) {
105
- return abortReason;
106
- }
107
- if (!res) {
108
- return { success: true };
109
- }
110
- if (res.status && res.status === 'done') {
111
- return res;
112
- }
113
- if (res.status && res.status === 'failed') {
114
- return { success: false, shouldRetry: true, result: res.result };
115
- }
116
- if (timeToPlayStep - retryInterval <= 0) {
117
- return Object.assign(res, { success: false, shouldRetry: true });
118
- }
119
- timeToPlayStep -= retryInterval;
120
- await utils.delay(retryInterval);
121
- return checkScriptStatus();
122
- }
123
-
124
- return checkScriptStatus();
125
- }
126
-
127
- executeInAut(eventMessage) {
128
- const useExperimentalPreCompilation = featureFlags.flags.experimentalPreCodeCompilation.isEnabled();
129
- const experimentalAsyncCustomCode = featureFlags.flags.experimentalAsyncCustomCode.isEnabled();
130
- const rawParams = this.constructJSFunParams(eventMessage);
131
- const hasLocateParams = rawParams.function.args.some(x => Boolean(x?.locatedElement));
132
- let funcToRunString = 'undefined';
133
- if (useExperimentalPreCompilation) {
134
- const paramNames = rawParams.function.params.slice(0, -1);
135
- funcToRunString = experimentalAsyncCustomCode ? `async function(${paramNames.join(',')}) {
136
- ${eventMessage.code}
137
- };` : `function(${paramNames.join(',')}) {
138
- ${eventMessage.code}
139
- };`;
140
- // remove code from call.
141
- rawParams.function.params.pop();
142
- }
143
-
144
- const { codeSnippets } = this.sessionPlayerInit;
145
-
146
- const runCode = `
147
- ${hasLocateParams ? `var getLocatedElement = ${codeSnippets.getLocatedElementCode};` : ';'}
148
- var runCode = ${runCodeScript.toString()};
149
- var eventData = arguments[0];
150
- var funcToRun = ${funcToRunString};
151
- return runCode.call(null, eventData, funcToRun);
152
- `;
153
- if (!useExperimentalPreCompilation) {
154
- return this.driver.executeJS(runCode, rawParams);
155
- }
156
-
157
- return this.driver.executeJS(runCode, rawParams).catch(err => this.handleExecutionError(err));
158
- }
159
-
160
- codeExecDone(resp) {
161
- const { stepResult: constants } = this.sessionPlayerInit.commonConstants;
162
- const { context } = this;
163
- const {
164
- result = {}, tstConsoleLogs, nodeVersion, navigateToDifferentDomain,
165
- } = resp;
166
- if (result.exports) {
167
- context.data.exports = result.exports;
168
- }
169
-
170
- const resultObj = {
171
- nodeVersion,
172
- tstConsoleLogs,
173
- data: context.data,
174
- };
175
-
176
- if (this.isFailedResult(result.resultValue)) {
177
- Object.assign(resultObj, {
178
- success: false,
179
- errorType: constants.JS_ASSERTION_FAILED,
180
- });
181
- } else if (this.isExceedingMaxResultSize({ result, tstConsoleLogs }, context)) {
182
- Object.assign(resultObj, {
183
- success: false,
184
- errorType: constants.JS_RESULT_MAX_SIZE_EXCEEDED,
185
- });
186
- } else {
187
- Object.assign(resultObj, {
188
- success: true,
189
- exportsTest: result.exportsTest,
190
- exportsGlobal: result.exportsGlobal,
191
- });
192
- if (navigateToDifferentDomain) {
193
- resultObj.navigateToDifferentDomain = navigateToDifferentDomain;
194
- }
195
- }
196
- return Promise.resolve(resultObj);
197
- }
198
-
199
- codeExecFailed(resp) {
200
- const { stepResult: constants } = this.sessionPlayerInit.commonConstants;
201
- const { context } = this;
202
- if (resp.type === 'promise') {
203
- return Promise.resolve({
204
- data: context.data,
205
- success: false,
206
- shouldRetry: true,
207
- isPendingPromise: true,
208
- errorType: constants.JS_ASSERTION_FAILED,
209
- });
210
- }
211
- if (resp.reason === 'stopped') {
212
- return Promise.resolve(Object.assign({}, resp, { errorType: constants.STOPPED }));
213
- }
214
- const { result = {}, tstConsoleLogs } = resp;
215
- const message = {
216
- tstConsoleLogs,
217
- data: context.data,
218
- exportsGlobal: result.exportsGlobal,
219
- exportsTest: result.exportsTest,
220
- success: false,
221
- errorType: constants.UNWRAPPED_AUT_REJECT,
222
- resultInfo: { error: result.resultValue },
223
- };
224
- return Promise.resolve(message);
225
- }
226
-
227
- checkCodeResponse(resp) {
228
- return resp?.success ? this.codeExecDone(resp) : this.codeExecFailed(resp);
229
- }
230
-
231
- async performAction() {
232
- const step = this.step;
233
- const context = this.context;
234
-
235
- this.startTimestamp = Date.now();
236
-
237
- const eventMessage = {
238
- transactionId: `${context.testResultId}:${step.id}`,
239
- id: step.id,
240
- eventType: step.type,
241
- code: step.code,
242
- incomingParams: context.incomingParams,
243
- exportsGlobal: this.exportsGlobal,
244
- exportsTest: this.exportsTest,
245
- context: {
246
- config: context.config,
247
- data: context.data,
248
- },
249
- testResultId: context.testResultId,
250
- };
251
-
252
- const browserAndOS = await this.driver.getBrowserAndOS();
253
- Object.assign(eventMessage, { browser: browserAndOS.browser, browserMajor: browserAndOS.browserMajor });
254
-
255
- if (!this.context.isPendingPromise) {
256
- await this.executeInAut(eventMessage);
257
- }
258
-
259
- const resp = await this.checkStatus(eventMessage.transactionId);
260
- return await this.checkCodeResponse(resp);
261
- }
262
-
263
- handleExecutionError(err) {
264
- const canExtractError = err?.seleniumStack && err.seleniumStack.type === 'JavaScriptError' &&
265
- err.seleniumStack.orgStatusMessage;
266
-
267
- if (canExtractError) {
268
- const endOfMessage = err.seleniumStack.orgStatusMessage.indexOf('\nBuild info');
269
- const reason = err.seleniumStack.orgStatusMessage.slice(0, endOfMessage === -1 ? undefined : endOfMessage);
270
- throw new Error(reason);
271
- }
272
-
273
- throw err;
274
- }
275
- }
276
-
277
- module.exports = BaseJsStepAction;
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const BaseCliJsStepAction = require('./baseCliJsStepAction');
4
-
5
- class CliConditionStepAction extends BaseCliJsStepAction {
6
- isFailedResult(resultValue) {
7
- return !resultValue;
8
- }
9
- }
10
-
11
- module.exports = CliConditionStepAction;
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const BaseCliJsStepAction = require('./baseCliJsStepAction');
4
-
5
- class CliJsStepAction extends BaseCliJsStepAction {
6
- isFailedResult(resultValue) {
7
- return resultValue === false;
8
- }
9
- }
10
-
11
- module.exports = CliJsStepAction;
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
- const featureFlagService = require('../../commons/featureFlags');
5
- const downloadFileAndFireDropEvent = require('./scripts/dropEvent');
6
- const { getLogger } = require('../../commons/logger');
7
-
8
- const logger = getLogger('drop-file-step-action');
9
-
10
- class DropFileStepAction extends StepAction {
11
- async performAction() {
12
- const { codeSnippets, utils } = this.sessionPlayerInit;
13
- const target = this.context.data[this.step.targetId || 'targetId'];
14
- const overrideAzureStorageUrl = featureFlagService.flags.overrideAzureStorageUrl.isEnabled();
15
- const fileUrls = await utils.addTokenToFileUrl(
16
- this.context.project.id,
17
- this.step.fileUrls,
18
- this.stepActionUtils.testimServicesApi,
19
- overrideAzureStorageUrl,
20
- logger,
21
- );
22
-
23
- const dropFileCode = `
24
- var getLocatedElement = ${codeSnippets.getLocatedElementCode};
25
- var createDropEvent = ${codeSnippets.createDropEvent.toString()};
26
- var downloadFileAndFireDropEvent = ${downloadFileAndFireDropEvent.toString()};
27
- return downloadFileAndFireDropEvent.apply(null, arguments)
28
- `;
29
-
30
- return await this.driver.executeJSWithArray(dropFileCode, [target.locatedElement, fileUrls]);
31
- }
32
- }
33
-
34
- module.exports = DropFileStepAction;
@@ -1,52 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash');
4
- const StepAction = require('./stepAction');
5
- const { getLogger } = require('../../commons/logger');
6
-
7
- const logger = getLogger('evaluate-expression-step-action');
8
-
9
- class EvaluateExpressionStepAction extends StepAction {
10
- async execute() {
11
- const step = this.step;
12
- const context = this.context;
13
- const exportsGlobal = this.exportsGlobal;
14
- const exportsTest = this.exportsTest;
15
-
16
- try {
17
- logger.info('runner running incoming params evaluation');
18
- let incomingParams = context.incomingParams || {};
19
- if (_.isEmpty(incomingParams)) {
20
- incomingParams = this.sessionPlayerInit.stepParamBuilder.getStepInputs(step, context, exportsGlobal, exportsTest);
21
- }
22
-
23
- const params = ['context', ...incomingParams.as.functionParameters];
24
- const args = [context, ...incomingParams.as.functionArguments];
25
- const expressionToEvaluate = step.subType === 'text' ? `'${step.expression.replace(/'/g, "\\\'")}'` : step.expression;
26
- const code = `return ${expressionToEvaluate}`.replace(/\n/g, '\\n');
27
- const textEvaluateFunction = Function.apply(Function, params.concat([code]));
28
- const evaluatedText = textEvaluateFunction.apply(null, args);
29
-
30
- context.data[step.targetName] = evaluatedText;
31
- context.data[step.targetId] = evaluatedText;
32
- if (context.internalParams) {
33
- context.internalParams.add(step.targetId);
34
- }
35
-
36
- const result = {
37
- success: true,
38
- evaluatedText,
39
- data: context.data,
40
- };
41
-
42
- return result;
43
- } catch (e) {
44
- const { stepResult } = this.sessionPlayerInit.commonConstants;
45
- // TODO: Fix throwing non-error
46
- // eslint-disable-next-line no-throw-literal
47
- throw { errorType: stepResult.EVALUATE_EXPRESSION_EXCEPTION, resultInfo: { exception: e.toString() }, success: false };
48
- }
49
- }
50
- }
51
-
52
- module.exports = EvaluateExpressionStepAction;
@@ -1,12 +0,0 @@
1
- const StepAction = require('./stepAction');
2
-
3
- class ExtensionOnlyStepAction extends StepAction {
4
- async performAction() {
5
- return {
6
- success: 'skipped',
7
- reason: 'This step can run only on Chrome',
8
- };
9
- }
10
- }
11
-
12
- module.exports = ExtensionOnlyStepAction;
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- const StepAction = require('./stepAction');
4
-
5
- class ExtractTextStepAction extends StepAction {
6
- async performAction() {
7
- const paramName = this.step.extractTextParamName;
8
-
9
- const extractedText = await this.stepActionUtils.extractTargetText(this.getTarget());
10
- this.context.data.exports = this.context.data.exports || {};
11
- this.context.data.exports[paramName] = extractedText;
12
- return {
13
- success: true,
14
- data: this.context.data,
15
- };
16
- }
17
- }
18
-
19
- module.exports = ExtractTextStepAction;
@@ -1,55 +0,0 @@
1
- const StepAction = require('./stepAction');
2
-
3
- const toDOMRect = (height, width, x, y) => ({
4
- x,
5
- y,
6
- width,
7
- height,
8
- get top() { return this.y; },
9
- get left() { return this.x; },
10
- get right() { return this.x + this.width; },
11
- get bottom() { return this.y + this.height; },
12
- toJSON() { },
13
- });
14
-
15
- class HoverStepAction extends StepAction {
16
- getRect() {
17
- return this.driver.isFirefox() ?
18
- this.getTarget().rectWithoutFrameOffset :
19
- this.getTarget().rect;
20
- }
21
-
22
- async performAction() {
23
- const target = this.getTarget();
24
- const { seleniumElement, rectWithoutFrameOffset, rect } = target;
25
-
26
- const { width, height } = rect;
27
-
28
- let clickOffsetX = width / 2;
29
- let clickOffsetY = height / 2;
30
-
31
- const offset = this.step.element.clickOffset;
32
- if (offset && this.step.shouldAccountForMouseOffsetInHover) {
33
- const { x, y } = offset;
34
-
35
- if (this.sessionPlayerInit.utils.isWithinTargetRect(toDOMRect(height, width, 0, 0), x, y)) {
36
- clickOffsetX = x;
37
- clickOffsetY = y;
38
- }
39
- }
40
-
41
- const offsets = {
42
- frameOffset: {
43
- x: rect.left - rectWithoutFrameOffset.left,
44
- y: rect.top - rectWithoutFrameOffset.top,
45
- },
46
- rect: rectWithoutFrameOffset,
47
- clickOffset: { x: Math.floor(clickOffsetX), y: Math.floor(clickOffsetY) },
48
- };
49
-
50
- await this.driver.hover(seleniumElement, offsets);
51
- return { success: true };
52
- }
53
- }
54
-
55
- module.exports = HoverStepAction;