@zohodesk/testinglibrary 3.1.9 → 3.1.10-experimental
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/.gitlab-ci.yml +0 -14
- package/build/common/data-generator/DataGenerator.js +65 -0
- package/build/common/data-generator/DataGeneratorHelper.js +62 -0
- package/build/common/data-generator/uat/steps/DataGenerator.spec.js +31 -0
- package/build/core/playwright/builtInFixtures/page.js +1 -3
- package/build/core/playwright/helpers/auth/index.js +8 -1
- package/build/core/playwright/helpers/auth/loginSteps.js +1 -0
- package/build/core/playwright/setup/config-creator.js +2 -18
- package/build/core/playwright/setup/config-utils.js +2 -7
- package/build/core/playwright/setup/qc-custom-reporter.js +16 -126
- package/build/test/Test.js +13 -0
- package/build/utils/fileUtils.js +1 -2
- package/package.json +5 -4
- package/test-results/.last-run.json +4 -0
- package/build/core/playwright/helpers/additionalProfiles.js +0 -18
- package/npm-shrinkwrap.json +0 -10873
package/.gitlab-ci.yml
CHANGED
|
@@ -146,18 +146,4 @@ uatconfigmodule:
|
|
|
146
146
|
paths:
|
|
147
147
|
- examples/uat/playwright-report
|
|
148
148
|
|
|
149
|
-
uat-smoketest:
|
|
150
|
-
stage: uat
|
|
151
|
-
script:
|
|
152
|
-
- cd examples
|
|
153
|
-
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
154
|
-
- output=$(npm run uat-smoketest)
|
|
155
|
-
- echo "$output"
|
|
156
|
-
- node ../ValidateUATReport.js examples
|
|
157
|
-
|
|
158
|
-
artifacts:
|
|
159
|
-
when: always
|
|
160
|
-
paths:
|
|
161
|
-
- examples/uat/playwright-report
|
|
162
|
-
|
|
163
149
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
var _DataGeneratorHelper = require("./DataGeneratorHelper");
|
|
11
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
12
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
13
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
14
|
+
var _DataGenerator_brand = /*#__PURE__*/new WeakSet();
|
|
15
|
+
class DataGenerator {
|
|
16
|
+
constructor() {
|
|
17
|
+
_classPrivateMethodInitSpec(this, _DataGenerator_brand);
|
|
18
|
+
}
|
|
19
|
+
async generate(testInfo, actorInfo, page, templateName, scenarioName, dataTable) {
|
|
20
|
+
try {
|
|
21
|
+
const templates = await _assertClassBrand(_DataGenerator_brand, this, _getGenerator).call(this, testInfo, templateName);
|
|
22
|
+
if (!templates) throw new Error(templateName + ' Template not found');
|
|
23
|
+
const {
|
|
24
|
+
crmcsrToken,
|
|
25
|
+
cookieString
|
|
26
|
+
} = await (0, _DataGeneratorHelper.getCookies)(page);
|
|
27
|
+
const processedTemplates = await (0, _DataGeneratorHelper.processTemplate)(templates, dataTable);
|
|
28
|
+
const user = actorInfo;
|
|
29
|
+
let host = process.env.domain.replace("/agent/", "");
|
|
30
|
+
const apiPayload = {
|
|
31
|
+
scenario_name: scenarioName,
|
|
32
|
+
data_generation_templates: processedTemplates,
|
|
33
|
+
account: {
|
|
34
|
+
email: user.email,
|
|
35
|
+
password: user.password,
|
|
36
|
+
storeVariables: {
|
|
37
|
+
orgId: user.orgId
|
|
38
|
+
},
|
|
39
|
+
cookieAuthHeaders: {
|
|
40
|
+
Cookie: cookieString,
|
|
41
|
+
'X-ZCSRF-TOKEN': crmcsrToken
|
|
42
|
+
},
|
|
43
|
+
authentications: ["cookie-auth"]
|
|
44
|
+
},
|
|
45
|
+
environmentDetails: {
|
|
46
|
+
"host": host
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return await (0, _DataGeneratorHelper.makeRequest)(process.env.dataGeneratorDomain + process.env.dataGeneratorAPI, apiPayload);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error creating data:', error);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function _getGenerator(testInfo, templateName) {
|
|
57
|
+
let templateFilePath = await (0, _DataGeneratorHelper.getGeneratorFilePath)(testInfo.file);
|
|
58
|
+
templateFilePath = _path.default.join(templateFilePath, "../../data-generators/template.json");
|
|
59
|
+
if (!templateFilePath) return null;
|
|
60
|
+
const data = _fs.default.readFileSync(templateFilePath, 'utf8');
|
|
61
|
+
const template = JSON.parse(data);
|
|
62
|
+
if (!templateName || !template.generators) return null;
|
|
63
|
+
return template.generators[templateName] || null;
|
|
64
|
+
}
|
|
65
|
+
var _default = exports.default = DataGenerator;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCookies = getCookies;
|
|
7
|
+
exports.getGeneratorFilePath = getGeneratorFilePath;
|
|
8
|
+
exports.makeRequest = makeRequest;
|
|
9
|
+
exports.processTemplate = processTemplate;
|
|
10
|
+
async function getCookies(page) {
|
|
11
|
+
const context = page.context();
|
|
12
|
+
const pageUrl = new URL(page.url());
|
|
13
|
+
const currentDomain = pageUrl.hostname;
|
|
14
|
+
const cookies = await context.cookies([page.url()]);
|
|
15
|
+
const crmcsrCookie = cookies.filter(cookie => cookie.domain.includes(currentDomain) && cookie.name === 'crmcsr');
|
|
16
|
+
return {
|
|
17
|
+
crmcsrToken: crmcsrCookie.map(c => `${'crmcsrfparam'}=${c.value}`).join('; '),
|
|
18
|
+
cookieString: cookies.map(c => `${c.name}=${c.value}`).join('; ')
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//Create payload for the template
|
|
23
|
+
async function processTemplate(template, dataTable) {
|
|
24
|
+
if (!template || !dataTable) {
|
|
25
|
+
return template;
|
|
26
|
+
}
|
|
27
|
+
const data = dataTable.hashes();
|
|
28
|
+
return template.map(tmpl => {
|
|
29
|
+
if (!tmpl.params) {
|
|
30
|
+
return tmpl;
|
|
31
|
+
}
|
|
32
|
+
data.forEach(row => {
|
|
33
|
+
const generatorName = row.DG_APIName;
|
|
34
|
+
if (generatorName === tmpl.name) {
|
|
35
|
+
delete row.DG_APIName;
|
|
36
|
+
Object.entries(row).forEach(([key, value]) => {
|
|
37
|
+
tmpl.params[key] = value;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return tmpl;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async function makeRequest(url, payload) {
|
|
45
|
+
const response = await fetch(url, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: {
|
|
48
|
+
'Content-Type': 'application/json'
|
|
49
|
+
},
|
|
50
|
+
body: JSON.stringify(payload)
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const errorBody = await response.text();
|
|
54
|
+
throw new Error(`HTTP error! status: ${response.status}, body: ${errorBody}`);
|
|
55
|
+
}
|
|
56
|
+
return response.json();
|
|
57
|
+
}
|
|
58
|
+
async function getGeneratorFilePath(featureFile) {
|
|
59
|
+
let generatorPath = featureFile.split('/').slice(0, 9).join("/").concat("/", featureFile.split('/').slice(10, featureFile.length - 1).join("/"));
|
|
60
|
+
generatorPath = generatorPath.replace(".features-gen/", "");
|
|
61
|
+
return generatorPath;
|
|
62
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
5
|
+
var _DataGenerator = _interopRequireDefault(require("../../DataGenerator"));
|
|
6
|
+
const {
|
|
7
|
+
Given,
|
|
8
|
+
When,
|
|
9
|
+
Then
|
|
10
|
+
} = (0, _testinglibrary.createBdd)();
|
|
11
|
+
const dataGenerator = new _DataGenerator.default();
|
|
12
|
+
Given('generate a {string} entity {string} with {string}', async ({
|
|
13
|
+
page,
|
|
14
|
+
context,
|
|
15
|
+
i18N,
|
|
16
|
+
cacheLayer,
|
|
17
|
+
executionContext
|
|
18
|
+
}, module, entityName, generatorName, dataTable) => {
|
|
19
|
+
const testInfo = _testinglibrary.test.info();
|
|
20
|
+
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
21
|
+
const generatedData = await dataGenerator.generate(testInfo, executionContext.actorInfo, page, generatorName, scenarioName, dataTable);
|
|
22
|
+
await cacheLayer.set(entityName, generatedData.value);
|
|
23
|
+
});
|
|
24
|
+
Given('goto generated entity {string} using web URL', async ({
|
|
25
|
+
page,
|
|
26
|
+
cacheLayer
|
|
27
|
+
}, entityName) => {
|
|
28
|
+
const entityData = await cacheLayer.get(entityName);
|
|
29
|
+
const url = entityData.webUrl;
|
|
30
|
+
await page.goto(url);
|
|
31
|
+
});
|
|
@@ -9,8 +9,6 @@ var _auth = require("../helpers/auth");
|
|
|
9
9
|
var _readConfigFile = require("../readConfigFile");
|
|
10
10
|
/* eslint-disable global-require */
|
|
11
11
|
|
|
12
|
-
//import { additionProfiles } from '../helpers/additionalProfiles';
|
|
13
|
-
|
|
14
12
|
function getTagInputFromSelectedTags(tags, inputString) {
|
|
15
13
|
const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
|
|
16
14
|
let tagInput = null;
|
|
@@ -20,7 +18,7 @@ function getTagInputFromSelectedTags(tags, inputString) {
|
|
|
20
18
|
return tagInput;
|
|
21
19
|
}
|
|
22
20
|
function getCustomAccountDetails(tags) {
|
|
23
|
-
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal'
|
|
21
|
+
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal'];
|
|
24
22
|
const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
|
|
25
23
|
if (filteredTags && filteredTags.length > 0) {
|
|
26
24
|
const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
|
|
@@ -4,6 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "DataGenerator", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _DataGenerator.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
Object.defineProperty(exports, "accountLogin", {
|
|
8
14
|
enumerable: true,
|
|
9
15
|
get: function () {
|
|
@@ -73,4 +79,5 @@ Object.defineProperty(exports, "verifyIfCookieFileExists", {
|
|
|
73
79
|
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
74
80
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
75
81
|
var _getUsers = require("./getUsers");
|
|
76
|
-
var _loginSteps = _interopRequireDefault(require("./loginSteps"));
|
|
82
|
+
var _loginSteps = _interopRequireDefault(require("./loginSteps"));
|
|
83
|
+
var _DataGenerator = _interopRequireDefault(require("../../../../common/data-generator/DataGenerator"));
|
|
@@ -10,6 +10,7 @@ var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
|
10
10
|
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
11
11
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
12
12
|
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
13
|
+
var _fs = require("fs");
|
|
13
14
|
/* eslint-disable no-console */
|
|
14
15
|
|
|
15
16
|
async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
@@ -12,7 +12,6 @@ var _configUtils = require("./config-utils");
|
|
|
12
12
|
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
13
13
|
const {
|
|
14
14
|
browsers,
|
|
15
|
-
isSmokeTest,
|
|
16
15
|
trace,
|
|
17
16
|
video,
|
|
18
17
|
isAuthMode,
|
|
@@ -32,7 +31,6 @@ const {
|
|
|
32
31
|
const projects = (0, _configUtils.getProjects)({
|
|
33
32
|
browsers,
|
|
34
33
|
isAuthMode,
|
|
35
|
-
isSmokeTest,
|
|
36
34
|
authFilePath,
|
|
37
35
|
expectTimeout,
|
|
38
36
|
testTimeout,
|
|
@@ -63,21 +61,7 @@ if (customReporter) {
|
|
|
63
61
|
*
|
|
64
62
|
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
65
63
|
*/
|
|
66
|
-
|
|
67
64
|
function getPlaywrightConfig() {
|
|
68
|
-
const commonConfig = {
|
|
69
|
-
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
70
|
-
};
|
|
71
|
-
const dependencies = isAuthMode ? ['setup'] : [];
|
|
72
|
-
const smokeTestProject = isSmokeTest ? {
|
|
73
|
-
name: 'smokeTest',
|
|
74
|
-
testMatch: /.*\.smokeTest\.js/,
|
|
75
|
-
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
76
|
-
use: {
|
|
77
|
-
...commonConfig
|
|
78
|
-
},
|
|
79
|
-
dependencies: dependencies
|
|
80
|
-
} : {};
|
|
81
65
|
const playwrightConfig = {
|
|
82
66
|
testDir,
|
|
83
67
|
globalTimeout: globalTimeout || 3600000,
|
|
@@ -94,11 +78,11 @@ function getPlaywrightConfig() {
|
|
|
94
78
|
testMatch: /.*\.setup\.js/,
|
|
95
79
|
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
96
80
|
teardown: 'cleanup'
|
|
97
|
-
},
|
|
81
|
+
}, {
|
|
98
82
|
name: 'cleanup',
|
|
99
83
|
testMatch: /.*\.teardown\.js/,
|
|
100
84
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
101
|
-
}, ...projects] : [...projects
|
|
85
|
+
}, ...projects] : [...projects],
|
|
102
86
|
...uatConfig
|
|
103
87
|
};
|
|
104
88
|
return playwrightConfig;
|
|
@@ -19,11 +19,9 @@ var _fileUtils = require("../../../utils/fileUtils");
|
|
|
19
19
|
** Playwright project configuration
|
|
20
20
|
* @returns {import('@playwright/test').Project}
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
22
|
function getBrowserConfig({
|
|
24
23
|
browserName,
|
|
25
24
|
isAuthMode,
|
|
26
|
-
isSmokeTest,
|
|
27
25
|
authFilePath,
|
|
28
26
|
expectTimeout,
|
|
29
27
|
testTimeout,
|
|
@@ -34,8 +32,7 @@ function getBrowserConfig({
|
|
|
34
32
|
viewport,
|
|
35
33
|
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
36
34
|
};
|
|
37
|
-
|
|
38
|
-
const dependencies = isSmokeTest ? isAuthMode ? ['setup', 'smokeTest'] : ['smokeTest'] : isAuthMode ? ['setup'] : [];
|
|
35
|
+
const dependencies = isAuthMode ? ['setup'] : [];
|
|
39
36
|
if (browser === 'chrome') {
|
|
40
37
|
return {
|
|
41
38
|
name: _browserTypes.BROWSER_PROJECT_MAPPING.CHROME,
|
|
@@ -102,7 +99,6 @@ function getBrowserConfig({
|
|
|
102
99
|
function getProjects({
|
|
103
100
|
browsers,
|
|
104
101
|
isAuthMode,
|
|
105
|
-
isSmokeTest,
|
|
106
102
|
authFilePath,
|
|
107
103
|
expectTimeout,
|
|
108
104
|
testTimeout,
|
|
@@ -111,7 +107,6 @@ function getProjects({
|
|
|
111
107
|
return browsers.map(browserName => getBrowserConfig({
|
|
112
108
|
browserName,
|
|
113
109
|
isAuthMode,
|
|
114
|
-
isSmokeTest,
|
|
115
110
|
authFilePath,
|
|
116
111
|
expectTimeout,
|
|
117
112
|
testTimeout,
|
|
@@ -172,7 +167,7 @@ function getTestDir(bddMode, cwd, {
|
|
|
172
167
|
}) {
|
|
173
168
|
return bddMode ? (0, _playwrightBdd.defineBddConfig)({
|
|
174
169
|
features: getPathsForFeatureFiles(cwd),
|
|
175
|
-
steps: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js'), require.resolve('../fixtures.js')],
|
|
170
|
+
steps: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js'), _path.default.join(cwd, '/node_modules/@zohodesk/testinglibrary/build/common/', '**', 'uat', '**', '*.spec.js'), require.resolve('../fixtures.js')],
|
|
176
171
|
importTestFrom: require.resolve('../fixtures.js'),
|
|
177
172
|
featuresRoot: _path.default.join(cwd, 'uat'),
|
|
178
173
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
@@ -32,12 +32,23 @@ class CustomJsonReporter {
|
|
|
32
32
|
attachments: result.attachments,
|
|
33
33
|
startTime: result.startTime,
|
|
34
34
|
retry: result.retry,
|
|
35
|
-
stderr: result.stderr.map(err =>
|
|
36
|
-
|
|
35
|
+
stderr: result.stderr.map(err => ({
|
|
36
|
+
text: err
|
|
37
|
+
})),
|
|
38
|
+
stdout: result.stdout.map(out => ({
|
|
39
|
+
text: out
|
|
40
|
+
})),
|
|
37
41
|
workerIndex: result.workerIndex,
|
|
38
42
|
duration: result.duration,
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
errors: ((_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : _result$errors.map(({
|
|
44
|
+
message,
|
|
45
|
+
stack,
|
|
46
|
+
snippet
|
|
47
|
+
}) => ({
|
|
48
|
+
message,
|
|
49
|
+
stack,
|
|
50
|
+
snippet
|
|
51
|
+
}))) ?? [],
|
|
41
52
|
steps: ((_result$steps = result.steps) === null || _result$steps === void 0 ? void 0 : _result$steps.map(step => extractMergedSteps(this.report.config.rootDir, step))) ?? []
|
|
42
53
|
};
|
|
43
54
|
const existingResults = this.testResultsById.get(key) ?? [];
|
|
@@ -152,125 +163,4 @@ const parseLocation = (rootDir, {
|
|
|
152
163
|
file: isRelative ? _path.default.relative(rootDir, file) : file,
|
|
153
164
|
line,
|
|
154
165
|
column
|
|
155
|
-
} : {};
|
|
156
|
-
const stdioEntry = s => typeof s === 'string' ? {
|
|
157
|
-
text: s
|
|
158
|
-
} : {
|
|
159
|
-
buffer: s.toString('base64')
|
|
160
|
-
};
|
|
161
|
-
const processError = error => {
|
|
162
|
-
const message = error.message || error.value || '';
|
|
163
|
-
const stack = error.stack;
|
|
164
|
-
if (!stack && !error.location) return {
|
|
165
|
-
message
|
|
166
|
-
};
|
|
167
|
-
const tokens = [];
|
|
168
|
-
const parsedStack = stack ? constructErrorStack(stack) : undefined;
|
|
169
|
-
tokens.push((parsedStack === null || parsedStack === void 0 ? void 0 : parsedStack.message) || message);
|
|
170
|
-
if (error.snippet) {
|
|
171
|
-
tokens.push('');
|
|
172
|
-
tokens.push(error.snippet);
|
|
173
|
-
}
|
|
174
|
-
if (parsedStack && parsedStack.stackLines.length) {
|
|
175
|
-
const dimmedStackLines = parsedStack.stackLines.split('\n').map(line => dimify(line));
|
|
176
|
-
tokens.push(dimmedStackLines.join('\n'));
|
|
177
|
-
}
|
|
178
|
-
let location = error.location;
|
|
179
|
-
if (parsedStack && !location) location = parsedStack.location;
|
|
180
|
-
if (error.cause) tokens.push(dimify('[cause]: ') + processError(error.cause).message);
|
|
181
|
-
return {
|
|
182
|
-
location,
|
|
183
|
-
message: tokens.join('\n')
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
const constructErrorStack = stack => parseErrorStack(stack, _path.default.sep, false);
|
|
187
|
-
const dimify = text => `\x1b[2m${text}\x1b[22m`;
|
|
188
|
-
const parseErrorStack = (stack, pathSeparator, showInternalStackFrames = false) => {
|
|
189
|
-
const lines = stack.split("\n");
|
|
190
|
-
let firstStackLineIndex = lines.findIndex(line => line.startsWith(" at "));
|
|
191
|
-
if (firstStackLineIndex === -1) firstStackLineIndex = lines.length;
|
|
192
|
-
const message = lines.slice(0, firstStackLineIndex).join("\n");
|
|
193
|
-
const stackStartIndex = indexLocator(stack, '\n', firstStackLineIndex) + 1 || 0;
|
|
194
|
-
const stackLinesString = stackStartIndex ? stack.slice(stackStartIndex) : '';
|
|
195
|
-
let location;
|
|
196
|
-
const stackLinesArr = stackLinesString.split('\n');
|
|
197
|
-
for (const line of stackLinesArr) {
|
|
198
|
-
const frame = parseStackFrame(line, pathSeparator, showInternalStackFrames);
|
|
199
|
-
if (!frame || !frame.file) continue;
|
|
200
|
-
if (isInNodeModules(frame.file, pathSeparator)) continue;
|
|
201
|
-
location = {
|
|
202
|
-
file: frame.file,
|
|
203
|
-
column: frame.column || 0,
|
|
204
|
-
line: frame.line || 0
|
|
205
|
-
};
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
message,
|
|
210
|
-
stackLines: stackLinesString,
|
|
211
|
-
location
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
const indexLocator = (str, pat, n) => {
|
|
215
|
-
let L = str.length,
|
|
216
|
-
i = -1;
|
|
217
|
-
while (n-- && i++ < L) {
|
|
218
|
-
i = str.indexOf(pat, i);
|
|
219
|
-
if (i < 0) break;
|
|
220
|
-
}
|
|
221
|
-
return i;
|
|
222
|
-
};
|
|
223
|
-
const isInNodeModules = (file, pathSeparator) => file.includes(`${pathSeparator}node_modules${pathSeparator}`);
|
|
224
|
-
const parseStackFrame = (text, pathSeparator, showInternalStackFrames) => {
|
|
225
|
-
const re = new RegExp("^(?:\\s*at )?(?:(new) )?(?:(.*?) \\()?(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?(?:(.+?):(\\d+):(\\d+)|(native))(\\)?)$");
|
|
226
|
-
const methodRe = /^(.*?) \[as (.*?)\]$/;
|
|
227
|
-
const match = text && text.match(re);
|
|
228
|
-
if (!match) return null;
|
|
229
|
-
let fname = match[2];
|
|
230
|
-
let file = match[7];
|
|
231
|
-
if (!file) return null;
|
|
232
|
-
if (!showInternalStackFrames && (file.startsWith("internal") || file.startsWith("node:"))) return null;
|
|
233
|
-
const line = match[8];
|
|
234
|
-
const column = match[9];
|
|
235
|
-
const closeParen = match[11] === ")";
|
|
236
|
-
const frame = {
|
|
237
|
-
file: "",
|
|
238
|
-
line: 0,
|
|
239
|
-
column: 0
|
|
240
|
-
};
|
|
241
|
-
if (line) frame.line = Number(line);
|
|
242
|
-
if (column) frame.column = Number(column);
|
|
243
|
-
if (closeParen && file) {
|
|
244
|
-
let closes = 0;
|
|
245
|
-
for (let i = file.length - 1; i > 0; i--) {
|
|
246
|
-
if (file.charAt(i) === ")") {
|
|
247
|
-
closes++;
|
|
248
|
-
} else if (file.charAt(i) === "(" && file.charAt(i - 1) === " ") {
|
|
249
|
-
closes--;
|
|
250
|
-
if (closes === -1 && file.charAt(i - 1) === " ") {
|
|
251
|
-
const before = file.slice(0, i - 1);
|
|
252
|
-
const after = file.slice(i + 1);
|
|
253
|
-
file = after;
|
|
254
|
-
fname += ` (${before}`;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (fname) {
|
|
261
|
-
const methodMatch = fname.match(methodRe);
|
|
262
|
-
if (methodMatch) fname = methodMatch[1];
|
|
263
|
-
}
|
|
264
|
-
if (file) {
|
|
265
|
-
if (file.startsWith("file://")) file = fileURLToPath(file, pathSeparator);
|
|
266
|
-
frame.file = file;
|
|
267
|
-
}
|
|
268
|
-
if (fname) frame.function = fname;
|
|
269
|
-
return frame;
|
|
270
|
-
};
|
|
271
|
-
const fileURLToPath = (fileUrl, pathSeparator) => {
|
|
272
|
-
if (!fileUrl.startsWith("file://")) return fileUrl;
|
|
273
|
-
let path = decodeURIComponent(fileUrl.slice(7));
|
|
274
|
-
if (path.startsWith("/") && /^[a-zA-Z]:/.test(path.slice(1))) path = path.slice(1);
|
|
275
|
-
return path.replace(/\//g, pathSeparator);
|
|
276
|
-
};
|
|
166
|
+
} : {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
delete require.cache[require.resolve('../core/playwright/runner/Runner')];
|
|
4
|
+
function test() {
|
|
5
|
+
const inputString = "@hc";
|
|
6
|
+
const selectedTag = ["@hc_1234"].reverse().find(tag => tag.startsWith(inputString));
|
|
7
|
+
let tagInput = null;
|
|
8
|
+
if (selectedTag) {
|
|
9
|
+
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
console.log(tagInput);
|
|
12
|
+
}
|
|
13
|
+
test();
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -14,8 +14,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
14
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
15
|
var _logger = require("./logger");
|
|
16
16
|
var glob = _interopRequireWildcard(require("glob"));
|
|
17
|
-
function
|
|
18
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
18
|
function checkIfFileExists(file) {
|
|
20
19
|
try {
|
|
21
20
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.10-experimental",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"exports": {
|
|
16
16
|
".": "./build/index.js",
|
|
17
17
|
"./decorators": "./build/decorators.js",
|
|
18
|
-
"./helpers": "./build/core/playwright/helpers/auth/index.js"
|
|
18
|
+
"./helpers": "./build/core/playwright/helpers/auth/index.js",
|
|
19
|
+
"./common_steps": "./build/common/uat/steps/common.spec.js"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [],
|
|
21
22
|
"author": "",
|
|
@@ -36,8 +37,8 @@
|
|
|
36
37
|
"jest-environment-jsdom": "29.6.2",
|
|
37
38
|
"msw": "1.2.3",
|
|
38
39
|
"playwright": "1.52.0",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
40
|
+
"playwright-bdd": "8.2.1",
|
|
41
|
+
"supports-color": "8.1.1"
|
|
41
42
|
},
|
|
42
43
|
"bin": {
|
|
43
44
|
"ZDTestingFramework": "./bin/cli.js"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.additionProfiles = additionProfiles;
|
|
7
|
-
var _getUsers = require("./auth/getUsers");
|
|
8
|
-
function additionProfiles(tags, editionInfo, betaFeature, portalInfo) {
|
|
9
|
-
const additionalProfileTags = tags.filter(tag => tag.startsWith('@additional_profile_'));
|
|
10
|
-
let additionalProfileActors = [];
|
|
11
|
-
if (additionalProfileTags.length > 0 && editionInfo) {
|
|
12
|
-
additionalProfileActors = additionalProfileTags.map(tag => {
|
|
13
|
-
const additionalProfile = tag.replace('@additional_profile_', '');
|
|
14
|
-
return (0, _getUsers.getUserForSelectedEditionAndProfile)(editionInfo, additionalProfile, betaFeature, portalInfo);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return additionalProfileActors;
|
|
18
|
-
}
|