@mablhq/mabl-cli 1.13.28 → 1.16.5
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/api/featureSet.js +27 -0
- package/api/mablApiClient.js +21 -20
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +12 -0
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerElementHandle.js +12 -0
- package/commands/tests/executionUtil.js +6 -1
- package/commands/tests/testsUtil.js +2 -0
- package/execution/index.js +1 -1
- package/mablApi/index.js +1 -1
- package/mablscript/MablStep.js +3 -0
- package/mablscript/steps/AccessibilityCheck.js +14 -2
- package/mablscriptFind/index.js +1 -1
- package/package.json +1 -1
- package/resources/mablFind.js +1 -1
- package/util/resourceUtil.js +18 -7
- package/api/entities/JourneyRunScheduledMessage.js +0 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeatureSet = exports.FindImplementationVersion = void 0;
|
|
4
|
+
const runnerType_1 = require("../browserLauncher/runnerType");
|
|
5
|
+
const PLAYWRIGHT_FEATURE_FLAG = 'nodejs_execution_engine_playwright';
|
|
6
|
+
const SMARTER_WAIT_FEATURE_FLAG = 'smarter_wait';
|
|
7
|
+
var FindImplementationVersion;
|
|
8
|
+
(function (FindImplementationVersion) {
|
|
9
|
+
FindImplementationVersion[FindImplementationVersion["V1"] = 0] = "V1";
|
|
10
|
+
FindImplementationVersion[FindImplementationVersion["SmartFind"] = 1] = "SmartFind";
|
|
11
|
+
})(FindImplementationVersion = exports.FindImplementationVersion || (exports.FindImplementationVersion = {}));
|
|
12
|
+
class FeatureSet {
|
|
13
|
+
constructor(featureFlags) {
|
|
14
|
+
this.featureFlags = featureFlags;
|
|
15
|
+
}
|
|
16
|
+
getRunnerType() {
|
|
17
|
+
return this.featureFlags.has(PLAYWRIGHT_FEATURE_FLAG)
|
|
18
|
+
? runnerType_1.RunnerType.Playwright
|
|
19
|
+
: runnerType_1.RunnerType.Puppeteer;
|
|
20
|
+
}
|
|
21
|
+
getFindImplementationVersion() {
|
|
22
|
+
return this.featureFlags.has(SMARTER_WAIT_FEATURE_FLAG)
|
|
23
|
+
? FindImplementationVersion.SmartFind
|
|
24
|
+
: FindImplementationVersion.V1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.FeatureSet = FeatureSet;
|
package/api/mablApiClient.js
CHANGED
|
@@ -26,9 +26,7 @@ const mablApi_1 = require("../mablApi");
|
|
|
26
26
|
const cliConfigProvider_1 = require("../providers/cliConfigProvider");
|
|
27
27
|
const basicApiClient_1 = require("./basicApiClient");
|
|
28
28
|
const queryString = __importStar(require("query-string"));
|
|
29
|
-
const
|
|
30
|
-
const runnerType_1 = require("../browserLauncher/runnerType");
|
|
31
|
-
const PLAYWRIGHT_FEATURE_FLAG = 'nodejs_execution_engine_playwright';
|
|
29
|
+
const featureSet_1 = require("./featureSet");
|
|
32
30
|
class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
33
31
|
constructor(options) {
|
|
34
32
|
super(options);
|
|
@@ -237,12 +235,20 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
237
235
|
}
|
|
238
236
|
async getTestFindSummaries(testId, environmentId) {
|
|
239
237
|
try {
|
|
240
|
-
return await this.makeGetRequest(`${env_1.BASE_API_URL}/findSummary?journey_id=${testId}&environment_id=${environmentId}`);
|
|
238
|
+
return await this.makeGetRequest(`${env_1.BASE_API_URL}/findSummary?journey_id=${testId}&environment_id=${environmentId}`).then((result) => { var _a; return (_a = result.findsummaries) !== null && _a !== void 0 ? _a : []; });
|
|
241
239
|
}
|
|
242
240
|
catch (error) {
|
|
243
241
|
throw toApiError(`Failed to get test find summaries results`, error);
|
|
244
242
|
}
|
|
245
243
|
}
|
|
244
|
+
async getTestFindModels(testId, environmentId) {
|
|
245
|
+
try {
|
|
246
|
+
return await this.makeGetRequest(`${env_1.BASE_API_URL}/findModel/test/${testId}?environment_id=${environmentId}`).then((result) => { var _a; return (_a = result.findModels) !== null && _a !== void 0 ? _a : []; });
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
throw toApiError(`Failed to get test find model results`, error);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
246
252
|
async getTestOverrides(testId, environmentId, selectorOverrideLimit = 10) {
|
|
247
253
|
try {
|
|
248
254
|
return await this.makeGetRequest(`${env_1.BASE_API_URL}/tests/testScripts/${testId}/overrides?environment_id=${environmentId}&selector_override_limit=${selectorOverrideLimit}`).then((result) => { var _a; return (_a = result.overrides) !== null && _a !== void 0 ? _a : []; });
|
|
@@ -687,23 +693,18 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
687
693
|
timeout: 3600000,
|
|
688
694
|
});
|
|
689
695
|
}
|
|
690
|
-
async
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
}
|
|
702
|
-
catch (ex) {
|
|
703
|
-
logUtils_1.logInternal(`Unable to get the playwright feature flag (${ex})`);
|
|
704
|
-
}
|
|
696
|
+
async getEffectiveFeaturesByWorkspaceId(workspaceId) {
|
|
697
|
+
try {
|
|
698
|
+
const workspace = await this.getWorkspace(workspaceId);
|
|
699
|
+
const account = await this.getAccount(workspace.account_id);
|
|
700
|
+
const features = account.effective_features
|
|
701
|
+
? new Set(account.effective_features)
|
|
702
|
+
: new Set();
|
|
703
|
+
return new featureSet_1.FeatureSet(features);
|
|
704
|
+
}
|
|
705
|
+
catch (error) {
|
|
706
|
+
throw toApiError(`Failed to get feature flags for workspace ${workspaceId}`, error);
|
|
705
707
|
}
|
|
706
|
-
return runnerType_1.RunnerType.Puppeteer;
|
|
707
708
|
}
|
|
708
709
|
}
|
|
709
710
|
exports.MablApiClient = MablApiClient;
|
|
@@ -7,6 +7,7 @@ exports.PlaywrightBrowserLauncher = void 0;
|
|
|
7
7
|
const test_1 = require("@playwright/test");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const playwrightBrowser_1 = require("./playwrightBrowser");
|
|
10
|
+
const BROWSER_LAUNCH_TIMEOUT_MS = 60000;
|
|
10
11
|
class PlaywrightBrowserLauncher {
|
|
11
12
|
async connect(options, currentDownloadPath) {
|
|
12
13
|
const browser = await test_1.chromium.connect(options.browserWSEndpoint);
|
|
@@ -35,6 +36,7 @@ class PlaywrightBrowserLauncher {
|
|
|
35
36
|
isMobile: (_a = options.defaultDeviceDescriptor) === null || _a === void 0 ? void 0 : _a.isMobile,
|
|
36
37
|
deviceScaleFactor: (_b = options.defaultDeviceDescriptor) === null || _b === void 0 ? void 0 : _b.deviceScaleFactor,
|
|
37
38
|
hasTouch: (_c = options.defaultDeviceDescriptor) === null || _c === void 0 ? void 0 : _c.hasTouch,
|
|
39
|
+
timeout: BROWSER_LAUNCH_TIMEOUT_MS,
|
|
38
40
|
});
|
|
39
41
|
return new playwrightBrowser_1.PlaywrightBrowser(defaultContext, path_1.default.join(options.downloadPath, 'final'), '');
|
|
40
42
|
}
|
|
@@ -26,6 +26,7 @@ const utils_1 = require("../utils");
|
|
|
26
26
|
const logUtils_1 = require("../../util/logUtils");
|
|
27
27
|
const elementHandle_1 = require("../elementHandle");
|
|
28
28
|
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
29
|
+
const pureUtil_1 = require("../../util/pureUtil");
|
|
29
30
|
exports.NAVIGATION_ERROR_MESSAGE = 'waiting for scheduled navigations to finish';
|
|
30
31
|
class PlaywrightJsHandle {
|
|
31
32
|
constructor(handle, page) {
|
|
@@ -267,5 +268,16 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
267
268
|
var _a;
|
|
268
269
|
return ((_a = this.cdpSession) !== null && _a !== void 0 ? _a : this.page.getCdpSession()).send(method, paramArgs);
|
|
269
270
|
}
|
|
271
|
+
getTagName() {
|
|
272
|
+
return this.element.evaluate((el) => el.tagName.toLowerCase());
|
|
273
|
+
}
|
|
274
|
+
async getAttribute(attributeName) {
|
|
275
|
+
const result = await this.element.evaluate((el, attributeName) => el.getAttribute(attributeName), attributeName);
|
|
276
|
+
return pureUtil_1.isNullish(result) ? undefined : result;
|
|
277
|
+
}
|
|
278
|
+
async getInnerText() {
|
|
279
|
+
const result = await this.element.evaluate((el) => el.innerText);
|
|
280
|
+
return pureUtil_1.isNullish(result) ? undefined : result;
|
|
281
|
+
}
|
|
270
282
|
}
|
|
271
283
|
exports.PlaywrightElementHandle = PlaywrightElementHandle;
|
|
@@ -5,6 +5,7 @@ const puppeteerJsHandle_1 = require("./puppeteerJsHandle");
|
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
7
7
|
const elementHandle_1 = require("../elementHandle");
|
|
8
|
+
const pureUtil_1 = require("../../util/pureUtil");
|
|
8
9
|
const msBetweenClicks = 100;
|
|
9
10
|
class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
|
|
10
11
|
constructor(element, parentPage) {
|
|
@@ -123,5 +124,16 @@ class PuppeteerElementHandle extends puppeteerJsHandle_1.PuppeteerJsHandle {
|
|
|
123
124
|
getValue() {
|
|
124
125
|
return this.element.evaluate((el) => el.value);
|
|
125
126
|
}
|
|
127
|
+
async getInnerText() {
|
|
128
|
+
const result = await this.element.evaluate((el) => el.innerText);
|
|
129
|
+
return pureUtil_1.isNullish(result) ? undefined : result;
|
|
130
|
+
}
|
|
131
|
+
getTagName() {
|
|
132
|
+
return this.element.evaluate((el) => el.tagName.toLowerCase());
|
|
133
|
+
}
|
|
134
|
+
async getAttribute(attributeName) {
|
|
135
|
+
const result = await this.element.evaluate((el, attributeName) => el.getAttribute(attributeName), attributeName);
|
|
136
|
+
return pureUtil_1.isNullish(result) ? undefined : result;
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
139
|
exports.PuppeteerElementHandle = PuppeteerElementHandle;
|
|
@@ -15,7 +15,12 @@ async function runTheTestInNewWindow(test, flows, branchName, url, credentialsId
|
|
|
15
15
|
const authConfig = await new authenticationProvider_1.AuthenticationProvider().getAuthConfigWithAutoRenew();
|
|
16
16
|
const browserPreferences = testsUtil_1.generateChromiumPreferencesFile();
|
|
17
17
|
const browserPreferencesDirectory = await testsUtil_1.prepareChromePreferencesDirectory(browserPreferences);
|
|
18
|
-
const
|
|
18
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
19
|
+
if (!test.organization_id) {
|
|
20
|
+
throw new Error('The test workspace ID is required, but it is not set.');
|
|
21
|
+
}
|
|
22
|
+
const featureFlags = await apiClient.getEffectiveFeaturesByWorkspaceId(test.organization_id);
|
|
23
|
+
const runnerType = featureFlags.getRunnerType();
|
|
19
24
|
const trainingBrowser = await testsUtil_1.createBrowserWithAuthedExtension(authConfig.accessToken, width || exports.DEFAULT_BROWSER_WIDTH, height || exports.DEFAULT_BROWSER_HEIGHT, browserPreferencesDirectory, {
|
|
20
25
|
runnerType,
|
|
21
26
|
});
|
|
@@ -158,6 +158,8 @@ async function launchBrowserInstance(chromePath, launchArgs, userDataDir, headle
|
|
|
158
158
|
messaging_1.mablEventEmitter.log(error.message);
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
+
messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
|
|
162
|
+
messaging_1.mablEventEmitter.log(error.message);
|
|
161
163
|
}
|
|
162
164
|
return browser;
|
|
163
165
|
}
|