@zohodesk/testinglibrary 3.1.9-experimental → 3.1.9
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 +14 -0
- package/build/core/playwright/builtInFixtures/page.js +3 -1
- package/build/core/playwright/helpers/additionalProfiles.js +18 -0
- package/build/core/playwright/helpers/auth/index.js +1 -8
- package/build/core/playwright/helpers/auth/loginSteps.js +0 -1
- package/build/core/playwright/setup/config-creator.js +18 -2
- package/build/core/playwright/setup/config-utils.js +7 -2
- package/build/core/playwright/setup/qc-custom-reporter.js +126 -16
- package/build/utils/fileUtils.js +2 -1
- package/npm-shrinkwrap.json +10873 -0
- package/package.json +4 -6
- package/build/common/data-generator/DataGenerator.js +0 -65
- package/build/common/data-generator/DataGeneratorHelper.js +0 -62
- package/build/common/data-generator/uat/steps/DataGenerator.spec.js +0 -31
- package/build/test/Test.js +0 -13
- package/test-results/.last-run.json +0 -4
- package/zohodesk-testinglibrary-3.1.5.tgz +0 -0
package/.gitlab-ci.yml
CHANGED
|
@@ -146,4 +146,18 @@ 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
|
+
|
|
149
163
|
|
|
@@ -9,6 +9,8 @@ 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
|
+
|
|
12
14
|
function getTagInputFromSelectedTags(tags, inputString) {
|
|
13
15
|
const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
|
|
14
16
|
let tagInput = null;
|
|
@@ -18,7 +20,7 @@ function getTagInputFromSelectedTags(tags, inputString) {
|
|
|
18
20
|
return tagInput;
|
|
19
21
|
}
|
|
20
22
|
function getCustomAccountDetails(tags) {
|
|
21
|
-
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal'];
|
|
23
|
+
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal', '@additional_profile'];
|
|
22
24
|
const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
|
|
23
25
|
if (filteredTags && filteredTags.length > 0) {
|
|
24
26
|
const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -4,12 +4,6 @@ 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
|
-
});
|
|
13
7
|
Object.defineProperty(exports, "accountLogin", {
|
|
14
8
|
enumerable: true,
|
|
15
9
|
get: function () {
|
|
@@ -79,5 +73,4 @@ Object.defineProperty(exports, "verifyIfCookieFileExists", {
|
|
|
79
73
|
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
80
74
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
81
75
|
var _getUsers = require("./getUsers");
|
|
82
|
-
var _loginSteps = _interopRequireDefault(require("./loginSteps"));
|
|
83
|
-
var _DataGenerator = _interopRequireDefault(require("../../../../common/data-generator/DataGenerator"));
|
|
76
|
+
var _loginSteps = _interopRequireDefault(require("./loginSteps"));
|
|
@@ -10,7 +10,6 @@ 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");
|
|
14
13
|
/* eslint-disable no-console */
|
|
15
14
|
|
|
16
15
|
async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
@@ -12,6 +12,7 @@ var _configUtils = require("./config-utils");
|
|
|
12
12
|
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
13
13
|
const {
|
|
14
14
|
browsers,
|
|
15
|
+
isSmokeTest,
|
|
15
16
|
trace,
|
|
16
17
|
video,
|
|
17
18
|
isAuthMode,
|
|
@@ -31,6 +32,7 @@ const {
|
|
|
31
32
|
const projects = (0, _configUtils.getProjects)({
|
|
32
33
|
browsers,
|
|
33
34
|
isAuthMode,
|
|
35
|
+
isSmokeTest,
|
|
34
36
|
authFilePath,
|
|
35
37
|
expectTimeout,
|
|
36
38
|
testTimeout,
|
|
@@ -61,7 +63,21 @@ if (customReporter) {
|
|
|
61
63
|
*
|
|
62
64
|
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
63
65
|
*/
|
|
66
|
+
|
|
64
67
|
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
|
+
} : {};
|
|
65
81
|
const playwrightConfig = {
|
|
66
82
|
testDir,
|
|
67
83
|
globalTimeout: globalTimeout || 3600000,
|
|
@@ -78,11 +94,11 @@ function getPlaywrightConfig() {
|
|
|
78
94
|
testMatch: /.*\.setup\.js/,
|
|
79
95
|
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
80
96
|
teardown: 'cleanup'
|
|
81
|
-
}, {
|
|
97
|
+
}, smokeTestProject, {
|
|
82
98
|
name: 'cleanup',
|
|
83
99
|
testMatch: /.*\.teardown\.js/,
|
|
84
100
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
85
|
-
}, ...projects] : [...projects],
|
|
101
|
+
}, ...projects] : [...projects, smokeTestProject],
|
|
86
102
|
...uatConfig
|
|
87
103
|
};
|
|
88
104
|
return playwrightConfig;
|
|
@@ -19,9 +19,11 @@ var _fileUtils = require("../../../utils/fileUtils");
|
|
|
19
19
|
** Playwright project configuration
|
|
20
20
|
* @returns {import('@playwright/test').Project}
|
|
21
21
|
*/
|
|
22
|
+
|
|
22
23
|
function getBrowserConfig({
|
|
23
24
|
browserName,
|
|
24
25
|
isAuthMode,
|
|
26
|
+
isSmokeTest,
|
|
25
27
|
authFilePath,
|
|
26
28
|
expectTimeout,
|
|
27
29
|
testTimeout,
|
|
@@ -32,7 +34,8 @@ function getBrowserConfig({
|
|
|
32
34
|
viewport,
|
|
33
35
|
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
34
36
|
};
|
|
35
|
-
|
|
37
|
+
// Determine dependencies based on the mode and smoke test status
|
|
38
|
+
const dependencies = isSmokeTest ? isAuthMode ? ['setup', 'smokeTest'] : ['smokeTest'] : isAuthMode ? ['setup'] : [];
|
|
36
39
|
if (browser === 'chrome') {
|
|
37
40
|
return {
|
|
38
41
|
name: _browserTypes.BROWSER_PROJECT_MAPPING.CHROME,
|
|
@@ -99,6 +102,7 @@ function getBrowserConfig({
|
|
|
99
102
|
function getProjects({
|
|
100
103
|
browsers,
|
|
101
104
|
isAuthMode,
|
|
105
|
+
isSmokeTest,
|
|
102
106
|
authFilePath,
|
|
103
107
|
expectTimeout,
|
|
104
108
|
testTimeout,
|
|
@@ -107,6 +111,7 @@ function getProjects({
|
|
|
107
111
|
return browsers.map(browserName => getBrowserConfig({
|
|
108
112
|
browserName,
|
|
109
113
|
isAuthMode,
|
|
114
|
+
isSmokeTest,
|
|
110
115
|
authFilePath,
|
|
111
116
|
expectTimeout,
|
|
112
117
|
testTimeout,
|
|
@@ -167,7 +172,7 @@ function getTestDir(bddMode, cwd, {
|
|
|
167
172
|
}) {
|
|
168
173
|
return bddMode ? (0, _playwrightBdd.defineBddConfig)({
|
|
169
174
|
features: getPathsForFeatureFiles(cwd),
|
|
170
|
-
steps: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js'),
|
|
175
|
+
steps: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js'), require.resolve('../fixtures.js')],
|
|
171
176
|
importTestFrom: require.resolve('../fixtures.js'),
|
|
172
177
|
featuresRoot: _path.default.join(cwd, 'uat'),
|
|
173
178
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
@@ -32,23 +32,12 @@ class CustomJsonReporter {
|
|
|
32
32
|
attachments: result.attachments,
|
|
33
33
|
startTime: result.startTime,
|
|
34
34
|
retry: result.retry,
|
|
35
|
-
stderr: result.stderr.map(err => (
|
|
36
|
-
|
|
37
|
-
})),
|
|
38
|
-
stdout: result.stdout.map(out => ({
|
|
39
|
-
text: out
|
|
40
|
-
})),
|
|
35
|
+
stderr: result.stderr.map(err => stdioEntry(err)),
|
|
36
|
+
stdout: result.stdout.map(out => stdioEntry(out)),
|
|
41
37
|
workerIndex: result.workerIndex,
|
|
42
38
|
duration: result.duration,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
stack,
|
|
46
|
-
snippet
|
|
47
|
-
}) => ({
|
|
48
|
-
message,
|
|
49
|
-
stack,
|
|
50
|
-
snippet
|
|
51
|
-
}))) ?? [],
|
|
39
|
+
error: result.error,
|
|
40
|
+
errors: (_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : _result$errors.map(processError),
|
|
52
41
|
steps: ((_result$steps = result.steps) === null || _result$steps === void 0 ? void 0 : _result$steps.map(step => extractMergedSteps(this.report.config.rootDir, step))) ?? []
|
|
53
42
|
};
|
|
54
43
|
const existingResults = this.testResultsById.get(key) ?? [];
|
|
@@ -163,4 +152,125 @@ const parseLocation = (rootDir, {
|
|
|
163
152
|
file: isRelative ? _path.default.relative(rootDir, file) : file,
|
|
164
153
|
line,
|
|
165
154
|
column
|
|
166
|
-
} : {};
|
|
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
|
+
};
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -14,7 +14,8 @@ 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
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
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; }
|
|
18
19
|
function checkIfFileExists(file) {
|
|
19
20
|
try {
|
|
20
21
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|