@zohodesk/testinglibrary 0.0.50-n20-experimental → 0.0.51-n20-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/.vscode/mcp.json +9 -0
- package/README.md +0 -8
- package/build/common/data-generator/steps/DataGenerator.spec.js +1 -1
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +4 -18
- package/build/core/dataGenerator/DataGenerator.js +15 -63
- package/build/core/playwright/builtInFixtures/cacheLayer.js +2 -171
- package/build/core/playwright/constants/reporterConstants.js +1 -0
- package/build/core/playwright/helpers/auth/getUsers.js +2 -2
- package/build/core/playwright/readConfigFile.js +1 -3
- package/build/core/playwright/reporter/PlaywrightReporter.js +44 -0
- package/build/core/playwright/reporter/UnitReporter.js +27 -0
- package/build/core/playwright/validateFeature.js +0 -11
- package/build/lib/cli.js +30 -7
- package/build/utils/commonUtils.js +9 -0
- package/changelog.md +0 -27
- package/npm-shrinkwrap.json +105 -167
- package/package.json +9 -8
- package/AUTO_CLEANUP_PLAN.md +0 -171
- package/build/core/dataGenerator/validateGenerators.js +0 -82
- package/build/core/playwright/report-generator.js +0 -42
package/.vscode/mcp.json
ADDED
package/README.md
CHANGED
|
@@ -17,14 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
- npm run report
|
|
19
19
|
|
|
20
|
-
### v0.0.44-n20-experimental - 23-03-2026
|
|
21
|
-
|
|
22
|
-
#### Enhancement
|
|
23
|
-
- DataGenerator now walks up the directory tree to discover data-generators folders
|
|
24
|
-
- Supports multiple JSON files in data-generators directory (no longer hardcoded to generators.json)
|
|
25
|
-
- Removed hardcoded folder name dependencies for flexible generator file placement
|
|
26
|
-
- Added duplicate generator name validation to `ZDTestingFramework validate` command
|
|
27
|
-
|
|
28
20
|
### v4.1.1/v3.3.0 - 28-01-2026
|
|
29
21
|
|
|
30
22
|
#### Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test } from '@zohodesk/testinglibrary';
|
|
2
2
|
import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
|
|
3
|
-
import {getUserForSelectedEditionAndProfile
|
|
3
|
+
import {getUserForSelectedEditionAndProfile} from '@zohodesk/testinglibrary/helpers'
|
|
4
4
|
|
|
5
5
|
const dataGenerator = new DataGenerator();
|
|
6
6
|
|
|
@@ -10,26 +10,12 @@ export async function generateAndCacheTestData(executionContext, type, identifie
|
|
|
10
10
|
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
11
11
|
|
|
12
12
|
if (profile) {
|
|
13
|
-
// Explicit profile requested — resolve that profile's credentials
|
|
14
13
|
const { edition, orgName: portal, beta } = executionContext.actorInfo;
|
|
15
14
|
actorInfo = await getUserForSelectedEditionAndProfile(edition, profile, beta, portal);
|
|
16
15
|
} else {
|
|
17
|
-
// Default — use current actor, fall back to org-level data-generator if profile has none
|
|
18
16
|
actorInfo = executionContext.actorInfo;
|
|
19
|
-
if (!actorInfo['data-generator']) {
|
|
20
|
-
const { edition, orgName: portal, beta } = actorInfo;
|
|
21
|
-
const actorsData = getListOfActors(beta);
|
|
22
|
-
const portalData = actorsData.editions[edition]?.find(e => e.orgName === portal);
|
|
23
|
-
if (portalData?.['data-generator']) {
|
|
24
|
-
actorInfo = { ...actorInfo, 'data-generator': portalData['data-generator'] };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const { response, generators } = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []);
|
|
30
|
-
if (cacheLayer._trackForCleanup) {
|
|
31
|
-
cacheLayer._trackForCleanup(entityName, response.data, generators, actorInfo, response.logs, identifier);
|
|
32
|
-
} else {
|
|
33
|
-
cacheLayer.set(entityName, response.data);
|
|
34
17
|
}
|
|
18
|
+
|
|
19
|
+
const generatedData = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []);
|
|
20
|
+
await cacheLayer.set(entityName, generatedData.data);
|
|
35
21
|
}
|
|
@@ -9,22 +9,15 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
10
|
var _logger = require("../../utils/logger");
|
|
11
11
|
var _DataGeneratorHelper = require("./DataGeneratorHelper");
|
|
12
|
+
var _helpers = require("@zohodesk/testinglibrary/helpers");
|
|
12
13
|
var _DataGeneratorError = require("./DataGeneratorError");
|
|
13
|
-
var _readConfigFile = require("../playwright/readConfigFile");
|
|
14
|
-
var _configConstants = _interopRequireDefault(require("../playwright/constants/configConstants"));
|
|
15
|
-
var _ConfigurationHelper = require("../playwright/configuration/ConfigurationHelper");
|
|
16
14
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
17
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
18
15
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
19
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
20
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
21
16
|
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"); }
|
|
22
|
-
var _generatorIndex = /*#__PURE__*/new WeakMap();
|
|
23
17
|
var _DataGenerator_brand = /*#__PURE__*/new WeakSet();
|
|
24
18
|
class DataGenerator {
|
|
25
19
|
constructor() {
|
|
26
20
|
_classPrivateMethodInitSpec(this, _DataGenerator_brand);
|
|
27
|
-
_classPrivateFieldInitSpec(this, _generatorIndex, null);
|
|
28
21
|
}
|
|
29
22
|
async generate(testInfo, actorInfo, generatorType, generatorName, scenarioName, dataTable) {
|
|
30
23
|
try {
|
|
@@ -32,16 +25,13 @@ class DataGenerator {
|
|
|
32
25
|
if (generatorType === 'API') {
|
|
33
26
|
generators = await _assertClassBrand(_DataGenerator_brand, this, _generateAPIGenerator).call(this, generatorName);
|
|
34
27
|
} else {
|
|
35
|
-
generators = await _assertClassBrand(_DataGenerator_brand, this, _getGenerator).call(this, generatorName);
|
|
28
|
+
generators = await _assertClassBrand(_DataGenerator_brand, this, _getGenerator).call(this, testInfo, generatorName);
|
|
36
29
|
}
|
|
37
30
|
const processedGenerators = await (0, _DataGeneratorHelper.processGenerator)(generators, dataTable);
|
|
38
31
|
const apiPayload = await _assertClassBrand(_DataGenerator_brand, this, _constructApiPayload).call(this, scenarioName, processedGenerators, actorInfo);
|
|
39
32
|
const response = await (0, _DataGeneratorHelper.makeRequest)(process.env.DG_SERVICE_DOMAIN + process.env.DG_SERVICE_API_PATH, apiPayload);
|
|
40
33
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Generated response for the generator: ${generatorName} for scenario: ${scenarioName}, Response: ${JSON.stringify(response)}`);
|
|
41
|
-
return
|
|
42
|
-
response,
|
|
43
|
-
generators
|
|
44
|
-
};
|
|
34
|
+
return response;
|
|
45
35
|
} catch (error) {
|
|
46
36
|
if (error instanceof _DataGeneratorError.DataGeneratorError) {
|
|
47
37
|
console.error(error.getMessage());
|
|
@@ -58,59 +48,21 @@ class DataGenerator {
|
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const fullPath = _path.default.join(dir, entry.name);
|
|
71
|
-
if (entry.isDirectory()) {
|
|
72
|
-
_assertClassBrand(_DataGenerator_brand, this, _scanDir).call(this, fullPath, index, pattern);
|
|
73
|
-
} else if (_assertClassBrand(_DataGenerator_brand, this, _matchesPattern).call(this, entry.name, pattern)) {
|
|
74
|
-
try {
|
|
75
|
-
const data = _fs.default.readFileSync(fullPath, 'utf8');
|
|
76
|
-
const obj = JSON.parse(data);
|
|
77
|
-
if (obj.generators) {
|
|
78
|
-
for (const [name, config] of Object.entries(obj.generators)) {
|
|
79
|
-
if (!index.has(name)) {
|
|
80
|
-
index.set(name, config);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} catch (err) {
|
|
85
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to parse generator file: ${fullPath} - ${err.message}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function _buildIndex(modulesRoot, pattern) {
|
|
91
|
-
const index = new Map();
|
|
92
|
-
_assertClassBrand(_DataGenerator_brand, this, _scanDir).call(this, modulesRoot, index, pattern);
|
|
93
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Generator index built: ${index.size} generators found`);
|
|
94
|
-
return index;
|
|
95
|
-
}
|
|
96
|
-
function _getModulesRoot() {
|
|
97
|
-
const stage = (0, _ConfigurationHelper.getRunStage)();
|
|
98
|
-
return _path.default.join(process.cwd(), _configConstants.default.TEST_SLICE_FOLDER, stage, 'modules');
|
|
99
|
-
}
|
|
100
|
-
async function _getGenerator(generatorName) {
|
|
101
|
-
if (!_classPrivateFieldGet(_generatorIndex, this)) {
|
|
102
|
-
const modulesRoot = _assertClassBrand(_DataGenerator_brand, this, _getModulesRoot).call(this);
|
|
103
|
-
const {
|
|
104
|
-
generatorFilePattern: pattern = '*.generators.json'
|
|
105
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
106
|
-
if (modulesRoot) {
|
|
107
|
-
_classPrivateFieldSet(_generatorIndex, this, _assertClassBrand(_DataGenerator_brand, this, _buildIndex).call(this, modulesRoot, pattern));
|
|
51
|
+
async function _getGenerator(testInfo, generatorName) {
|
|
52
|
+
let generator = null;
|
|
53
|
+
let generatorFilePath = await (0, _DataGeneratorHelper.getGeneratorFilePath)(testInfo.file);
|
|
54
|
+
generatorFilePath = _path.default.join(generatorFilePath, "../../data-generators/generators.json");
|
|
55
|
+
if (_fs.default.existsSync(generatorFilePath)) {
|
|
56
|
+
const data = _fs.default.readFileSync(generatorFilePath, 'utf8');
|
|
57
|
+
const generatorObj = JSON.parse(data);
|
|
58
|
+
if (generatorName || generatorObj.generators) {
|
|
59
|
+
generator = generatorObj.generators[generatorName] || null;
|
|
108
60
|
}
|
|
109
61
|
}
|
|
110
|
-
if (
|
|
111
|
-
|
|
62
|
+
if (!generator) {
|
|
63
|
+
throw new _DataGeneratorError.GeneratorError(`Generator "${generatorName}" could not be found in the path located at "${generatorFilePath}"`);
|
|
112
64
|
}
|
|
113
|
-
|
|
65
|
+
return generator;
|
|
114
66
|
}
|
|
115
67
|
async function _generateAPIGenerator(operationId) {
|
|
116
68
|
return [{
|
|
@@ -1,182 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
|
|
9
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
-
var _logger = require("../../../utils/logger");
|
|
11
|
-
var _DataGeneratorHelper = require("../../dataGenerator/DataGeneratorHelper");
|
|
12
|
-
var _readConfigFile = require("../readConfigFile");
|
|
13
|
-
var _jsonpath = _interopRequireDefault(require("jsonpath"));
|
|
14
|
-
let cleanupRegistry = null;
|
|
15
|
-
function getModulesRoot() {
|
|
16
|
-
const configConstants = require('../constants/configConstants');
|
|
17
|
-
const {
|
|
18
|
-
getRunStage
|
|
19
|
-
} = require('../configuration/ConfigurationHelper');
|
|
20
|
-
const stage = getRunStage();
|
|
21
|
-
return _path.default.join(process.cwd(), configConstants.TEST_SLICE_FOLDER, stage, 'modules');
|
|
22
|
-
}
|
|
23
|
-
function buildCleanupRegistry() {
|
|
24
|
-
const modulesRoot = getModulesRoot();
|
|
25
|
-
const registry = {};
|
|
26
|
-
if (!_fs.default.existsSync(modulesRoot)) return registry;
|
|
27
|
-
scanDir(modulesRoot, registry);
|
|
28
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cleanup registry built: ${Object.keys(registry).length} generator chains from ${modulesRoot}`);
|
|
29
|
-
return registry;
|
|
30
|
-
}
|
|
31
|
-
function scanDir(dir, registry) {
|
|
32
|
-
const entries = _fs.default.readdirSync(dir, {
|
|
33
|
-
withFileTypes: true
|
|
34
|
-
});
|
|
35
|
-
for (const entry of entries) {
|
|
36
|
-
const fullPath = _path.default.join(dir, entry.name);
|
|
37
|
-
if (entry.isDirectory()) {
|
|
38
|
-
scanDir(fullPath, registry);
|
|
39
|
-
} else if (entry.name.endsWith('.cleanup.js')) {
|
|
40
|
-
try {
|
|
41
|
-
const cleanupModule = require(fullPath);
|
|
42
|
-
for (const [generatorName, chain] of Object.entries(cleanupModule)) {
|
|
43
|
-
if (registry[generatorName]) {
|
|
44
|
-
throw new Error(`Duplicate cleanup chain for generator "${generatorName}" in ${fullPath}. ` + `Each generator must have exactly one cleanup chain.`);
|
|
45
|
-
}
|
|
46
|
-
registry[generatorName] = chain;
|
|
47
|
-
}
|
|
48
|
-
} catch (err) {
|
|
49
|
-
if (err.message.includes('Duplicate cleanup chain')) {
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to load cleanup file: ${fullPath} - ${err.message}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function extractId(data, idPath) {
|
|
58
|
-
const result = _jsonpath.default.query(data, idPath);
|
|
59
|
-
if (result.length === 0) {
|
|
60
|
-
throw new Error(`Could not extract ID using path "${idPath}"`);
|
|
61
|
-
}
|
|
62
|
-
return result[0];
|
|
63
|
-
}
|
|
64
|
-
function parseLogBody(stepLog) {
|
|
65
|
-
var _stepLog$response;
|
|
66
|
-
if (!(stepLog !== null && stepLog !== void 0 && (_stepLog$response = stepLog.response) !== null && _stepLog$response !== void 0 && _stepLog$response.body)) return null;
|
|
67
|
-
const body = stepLog.response.body;
|
|
68
|
-
return typeof body === 'string' ? JSON.parse(body) : body;
|
|
69
|
-
}
|
|
70
|
-
async function cleanupViaOAS(config, entityId, actorInfo) {
|
|
71
|
-
const dataGeneratorObj = actorInfo['data-generator'];
|
|
72
|
-
if (!dataGeneratorObj) {
|
|
73
|
-
throw new Error('No data-generator config available for cleanup');
|
|
74
|
-
}
|
|
75
|
-
const payload = {
|
|
76
|
-
scenario_name: 'cleanup',
|
|
77
|
-
data_generation_templates: [{
|
|
78
|
-
type: 'dynamic',
|
|
79
|
-
generatorOperationId: config.operationId,
|
|
80
|
-
dataPath: '$.response.body:$',
|
|
81
|
-
name: config.operationId,
|
|
82
|
-
params: {
|
|
83
|
-
id: String(entityId)
|
|
84
|
-
}
|
|
85
|
-
}],
|
|
86
|
-
...dataGeneratorObj
|
|
87
|
-
};
|
|
88
|
-
if (payload.account) {
|
|
89
|
-
payload.account.email = actorInfo.email;
|
|
90
|
-
payload.account.password = actorInfo.password;
|
|
91
|
-
}
|
|
92
|
-
const environmentDetails = payload.environmentDetails || {};
|
|
93
|
-
environmentDetails.iam_url = process.env.DG_IAM_DOMAIN;
|
|
94
|
-
environmentDetails.host = new URL(process.env.domain).origin;
|
|
95
|
-
payload.environmentDetails = environmentDetails;
|
|
96
|
-
await (0, _DataGeneratorHelper.makeRequest)(process.env.DG_SERVICE_DOMAIN + process.env.DG_SERVICE_API_PATH, payload);
|
|
97
|
-
}
|
|
98
|
-
async function cleanupViaAPI(config, entityId) {
|
|
99
|
-
const url = `${new URL(process.env.domain).origin}${config.apiPath.replace('{id}', entityId)}`;
|
|
100
|
-
const options = {
|
|
101
|
-
method: config.method,
|
|
102
|
-
headers: {
|
|
103
|
-
'Content-Type': 'application/json'
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
if (config.body) {
|
|
107
|
-
options.body = JSON.stringify(config.body);
|
|
108
|
-
}
|
|
109
|
-
const response = await fetch(url, options);
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
const errorBody = await response.text();
|
|
112
|
-
throw new Error(`${config.method} ${config.apiPath} - status: ${response.status}, body: ${errorBody}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
7
|
+
const cacheMap = new Map();
|
|
115
8
|
var _default = exports.default = {
|
|
116
9
|
// eslint-disable-next-line no-empty-pattern
|
|
117
10
|
cacheLayer: async ({}, use) => {
|
|
118
|
-
|
|
119
|
-
const cleanupEntries = [];
|
|
120
|
-
cache._trackForCleanup = (entityName, data, generators, actorInfo, logs, generatorName) => {
|
|
121
|
-
cache.set(entityName, data);
|
|
122
|
-
cleanupEntries.push({
|
|
123
|
-
entityName,
|
|
124
|
-
data,
|
|
125
|
-
generators,
|
|
126
|
-
actorInfo,
|
|
127
|
-
logs: logs || [],
|
|
128
|
-
generatorName
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
await use(cache);
|
|
132
|
-
|
|
133
|
-
// TEARDOWN — runs after scenario ends (pass or fail)
|
|
134
|
-
const {
|
|
135
|
-
autoCleanup = true
|
|
136
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
137
|
-
if (!autoCleanup || cleanupEntries.length === 0) {
|
|
138
|
-
cache.clear();
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (!cleanupRegistry) {
|
|
142
|
-
cleanupRegistry = buildCleanupRegistry();
|
|
143
|
-
}
|
|
144
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cleanup started: ${cleanupEntries.length} entities to process`);
|
|
145
|
-
let cleaned = 0;
|
|
146
|
-
let skipped = 0;
|
|
147
|
-
let failed = 0;
|
|
148
|
-
for (const entry of [...cleanupEntries].reverse()) {
|
|
149
|
-
const cleanupChain = cleanupRegistry[entry.generatorName];
|
|
150
|
-
if (!cleanupChain) {
|
|
151
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cleanup: no chain for generator "${entry.generatorName}" — skipping`);
|
|
152
|
-
skipped++;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cleanup entity: "${entry.entityName}" generator: "${entry.generatorName}" (${cleanupChain.length} steps)`);
|
|
156
|
-
for (const cleanupStep of cleanupChain) {
|
|
157
|
-
try {
|
|
158
|
-
// Find the step's response from logs by matching operationId
|
|
159
|
-
const stepLog = entry.logs.find(log => log.generationOperationId === cleanupStep.operationId || log.name === cleanupStep.operationId);
|
|
160
|
-
const stepData = parseLogBody(stepLog) || entry.data;
|
|
161
|
-
const entityId = extractId(stepData, cleanupStep.idPath);
|
|
162
|
-
const actionDesc = cleanupStep.operationId || `${cleanupStep.method} ${cleanupStep.apiPath}`;
|
|
163
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cleanup [${cleanupStep.type}] ${actionDesc} (id: ${entityId})`);
|
|
164
|
-
if (cleanupStep.type === 'oas') {
|
|
165
|
-
await cleanupViaOAS(cleanupStep, entityId, entry.actorInfo);
|
|
166
|
-
} else if (cleanupStep.type === 'api') {
|
|
167
|
-
await cleanupViaAPI(cleanupStep, entityId);
|
|
168
|
-
}
|
|
169
|
-
cleaned++;
|
|
170
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Cleanup success: ${actionDesc} (id: ${entityId})`);
|
|
171
|
-
} catch (err) {
|
|
172
|
-
failed++;
|
|
173
|
-
const actionDesc = cleanupStep.operationId || `${cleanupStep.method} ${cleanupStep.apiPath}`;
|
|
174
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Cleanup failed: ${actionDesc} — ${err.message}`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Cleanup completed: ${cleaned} cleaned, ${skipped} skipped (no chain), ${failed} failed`);
|
|
179
|
-
cleanupEntries.length = 0;
|
|
180
|
-
cache.clear();
|
|
11
|
+
await use(cacheMap);
|
|
181
12
|
}
|
|
182
13
|
};
|
|
@@ -11,5 +11,6 @@ const stage = (0, _ConfigurationHelper.getRunStage)();
|
|
|
11
11
|
class ReporterConstants {
|
|
12
12
|
static DEFAULT_REPORTER_PATH = `${_configConstants.default.TEST_SLICE_FOLDER}/${stage}/test-results/playwright-test-results.json`;
|
|
13
13
|
static LAST_RUN_REPORTER_PATH = `${_configConstants.default.TEST_SLICE_FOLDER}/${stage}/test-results/.last-run.json`;
|
|
14
|
+
static DEFAULT_UNIT_TEST_REPORTER_PATH = `${_configConstants.default.TEST_SLICE_FOLDER}/unit-test/unit_reports/report.html`;
|
|
14
15
|
}
|
|
15
16
|
exports.default = ReporterConstants;
|
|
@@ -96,9 +96,9 @@ function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile,
|
|
|
96
96
|
throw new Error(`There is no "${edition}" edition configured.`);
|
|
97
97
|
}
|
|
98
98
|
if (testDataPortal !== null) {
|
|
99
|
-
testingPortal = userdata[edition].find(editionData => editionData.
|
|
99
|
+
testingPortal = userdata[edition].find(editionData => editionData.orgName === testDataPortal);
|
|
100
100
|
if (!testingPortal) {
|
|
101
|
-
throw new Error(`There is no "${testDataPortal}" portal
|
|
101
|
+
throw new Error(`There is no "${testDataPortal}" portal configured in "${edition}" edition.`);
|
|
102
102
|
}
|
|
103
103
|
} else {
|
|
104
104
|
testingPortal = userdata[edition] ? userdata[edition][0] : {};
|
|
@@ -55,9 +55,7 @@ function getDefaultConfig() {
|
|
|
55
55
|
featureFilesFolder: 'feature-files',
|
|
56
56
|
stepDefinitionsFolder: 'steps',
|
|
57
57
|
testSetup: {},
|
|
58
|
-
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
59
|
-
generatorFilePattern: '*.generators.json',
|
|
60
|
-
autoCleanup: true
|
|
58
|
+
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
61
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -0,0 +1,44 @@
|
|
|
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 _child_process = require("child_process");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _logger = require("../../../utils/logger");
|
|
11
|
+
var _rootPath = require("../../../utils/rootPath");
|
|
12
|
+
var _readConfigFile = require("../readConfigFile");
|
|
13
|
+
class PlaywrightReporter {
|
|
14
|
+
static generate() {
|
|
15
|
+
const userArgs = process.argv.slice(3);
|
|
16
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
17
|
+
const command = playwrightPath;
|
|
18
|
+
const {
|
|
19
|
+
reportPath: htmlPath
|
|
20
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
21
|
+
const args = ['show-report', htmlPath].concat(userArgs);
|
|
22
|
+
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
23
|
+
stdio: 'inherit'
|
|
24
|
+
});
|
|
25
|
+
childProcess.on('error', error => {
|
|
26
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
27
|
+
});
|
|
28
|
+
childProcess.on('exit', (code, signal) => {
|
|
29
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
30
|
+
process.exit();
|
|
31
|
+
});
|
|
32
|
+
process.on('exit', () => {
|
|
33
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
34
|
+
childProcess.kill();
|
|
35
|
+
return;
|
|
36
|
+
});
|
|
37
|
+
process.on('SIGINT', () => {
|
|
38
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Cleaning up...');
|
|
39
|
+
childProcess.kill();
|
|
40
|
+
process.exit();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = PlaywrightReporter;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 _child_process = require("child_process");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _os = require("os");
|
|
11
|
+
var _logger = require("../../../utils/logger");
|
|
12
|
+
var _reporterConstants = _interopRequireDefault(require("../constants/reporterConstants"));
|
|
13
|
+
class UnitReporter {
|
|
14
|
+
static generate() {
|
|
15
|
+
const reportPath = _path.default.resolve(process.cwd(), _reporterConstants.default.DEFAULT_UNIT_TEST_REPORTER_PATH);
|
|
16
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Opening unit test report: ${reportPath}`);
|
|
17
|
+
const os = (0, _os.platform)();
|
|
18
|
+
const openCommand = os === 'darwin' ? 'open' : os === 'win32' ? 'start' : 'xdg-open';
|
|
19
|
+
(0, _child_process.execFile)(openCommand, [reportPath], error => {
|
|
20
|
+
if (error) {
|
|
21
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to open report: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
process.exit();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = UnitReporter;
|
|
@@ -5,15 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
8
|
var _parseUserArgs = _interopRequireDefault(require("./helpers/parseUserArgs"));
|
|
10
9
|
var _readConfigFile = require("./readConfigFile");
|
|
11
10
|
var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
|
|
12
11
|
var _testRunner = require("./test-runner");
|
|
13
12
|
var _logger = require("../../utils/logger");
|
|
14
|
-
var _validateGenerators = require("../dataGenerator/validateGenerators");
|
|
15
|
-
var _configConstants = _interopRequireDefault(require("./constants/configConstants"));
|
|
16
|
-
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
17
13
|
const validateFeatureFiles = () => {
|
|
18
14
|
const userArgsObject = (0, _parseUserArgs.default)();
|
|
19
15
|
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
@@ -21,13 +17,6 @@ const validateFeatureFiles = () => {
|
|
|
21
17
|
editionOrder
|
|
22
18
|
} = uatConfig;
|
|
23
19
|
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
24
|
-
const stage = (0, _ConfigurationHelper.getRunStage)();
|
|
25
|
-
const modulesRoot = _path.default.join(process.cwd(), _configConstants.default.TEST_SLICE_FOLDER, stage, 'modules');
|
|
26
|
-
const generatorResult = (0, _validateGenerators.validateGenerators)(modulesRoot);
|
|
27
|
-
if (!generatorResult.valid) {
|
|
28
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Generator validation failed. Fix duplicate generator names before running tests.');
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
20
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
32
21
|
const tagArgs = tagProcessor.processTags(userArgsObject);
|
|
33
22
|
(0, _testRunner.runPreprocessing)(tagArgs, configPath).then(() => {
|
package/build/lib/cli.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _testRunner = _interopRequireDefault(require("../core/playwright/test-runner"));
|
|
5
|
-
var
|
|
5
|
+
var _unitTestingFramework = require("@zohodesk/unit-testing-framework");
|
|
6
|
+
var _PlaywrightReporter = _interopRequireDefault(require("../core/playwright/reporter/PlaywrightReporter"));
|
|
7
|
+
var _UnitReporter = _interopRequireDefault(require("../core/playwright/reporter/UnitReporter"));
|
|
6
8
|
var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
|
|
7
9
|
var _logger = require("../utils/logger");
|
|
8
10
|
var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
|
|
@@ -11,15 +13,25 @@ var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-cach
|
|
|
11
13
|
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
12
14
|
var _parseUserArgs = _interopRequireDefault(require("../core/playwright/helpers/parseUserArgs"));
|
|
13
15
|
var _validateFeature = _interopRequireDefault(require("../core/playwright/validateFeature"));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
var _commonUtils = require("../utils/commonUtils");
|
|
16
17
|
const [,, option, ...otherOptions] = process.argv;
|
|
17
18
|
switch (option) {
|
|
18
19
|
case 'test':
|
|
19
20
|
{
|
|
20
21
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Tests..');
|
|
21
22
|
(0, _testRunner.default)();
|
|
22
|
-
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case 'unit-test':
|
|
26
|
+
{
|
|
27
|
+
const testFile = process.argv[3];
|
|
28
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Unit Tests..');
|
|
29
|
+
const options = {};
|
|
30
|
+
if (testFile) {
|
|
31
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Filtering tests with pattern: ${testFile}`);
|
|
32
|
+
options.testPathPattern = testFile;
|
|
33
|
+
}
|
|
34
|
+
(0, _unitTestingFramework.createJestRunner)(options);
|
|
23
35
|
break;
|
|
24
36
|
}
|
|
25
37
|
case 'validate':
|
|
@@ -40,9 +52,14 @@ switch (option) {
|
|
|
40
52
|
}
|
|
41
53
|
case 'report':
|
|
42
54
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Generating UAT Reports...');
|
|
56
|
+
_PlaywrightReporter.default.generate();
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'ut-report':
|
|
60
|
+
{
|
|
61
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Generating Unit Test Reports...');
|
|
62
|
+
_UnitReporter.default.generate();
|
|
46
63
|
break;
|
|
47
64
|
}
|
|
48
65
|
case 'codegen':
|
|
@@ -69,6 +86,12 @@ switch (option) {
|
|
|
69
86
|
(0, _clearCaches.default)();
|
|
70
87
|
break;
|
|
71
88
|
}
|
|
89
|
+
case 'stepsGenerator':
|
|
90
|
+
{
|
|
91
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Created agents and prompts md files under .github folder...');
|
|
92
|
+
(0, _commonUtils.copyGithubFolder)();
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
72
95
|
case 'help':
|
|
73
96
|
default:
|
|
74
97
|
{
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.copyCommonSpecs = copyCommonSpecs;
|
|
8
|
+
exports.copyGithubFolder = copyGithubFolder;
|
|
8
9
|
var _fileUtils = require("./fileUtils");
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
var _configConstants = _interopRequireDefault(require("../core/playwright/constants/configConstants"));
|
|
@@ -17,4 +18,12 @@ function copyCommonSpecs() {
|
|
|
17
18
|
const destDirectory = _path.default.resolve(process.cwd(), _configConstants.default.TEST_SLICE_FOLDER, stage, 'modules', '.testingLib-common');
|
|
18
19
|
(0, _fileUtils.deleteFolder)(destDirectory);
|
|
19
20
|
(0, _fileUtils.copyDirectory)(commonSpecPath, destDirectory);
|
|
21
|
+
}
|
|
22
|
+
function copyGithubFolder() {
|
|
23
|
+
const libraryPath = require.resolve("@zohodesk/testinglibrary");
|
|
24
|
+
// libraryPath will be build/index.js, go two levels up to reach the package root where .github lives
|
|
25
|
+
const githubSrcPath = _path.default.resolve(libraryPath, '../../', '.github');
|
|
26
|
+
const destDirectory = _path.default.resolve(process.cwd(), '../../', '.github');
|
|
27
|
+
(0, _fileUtils.deleteFolder)(destDirectory);
|
|
28
|
+
(0, _fileUtils.copyDirectory)(githubSrcPath, destDirectory);
|
|
20
29
|
}
|
package/changelog.md
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
# Testing Framework
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
-
|
|
5
|
-
# 0.0.48-n20-experimental
|
|
6
|
-
|
|
7
|
-
## Data Generator — Global Index Discovery
|
|
8
|
-
- **Global generator index**: Replaced walk-up directory search with index-based global discovery. Generators in any module are now accessible from any feature file.
|
|
9
|
-
- **Deterministic modules root**: Uses `configConstants.TEST_SLICE_FOLDER + stage + 'modules'` instead of unreliable directory walk-up.
|
|
10
|
-
- **Configurable file pattern**: `generatorFilePattern` in `uat.config.js` (default: `*.generators.json`).
|
|
11
|
-
- **TicketBasic generator**: New generator without product step for Express/Free editions.
|
|
12
|
-
|
|
13
|
-
## Data Generator — Profile & Auth Improvements
|
|
14
|
-
- **Org-level DG fallback**: When scenario profile has no `data-generator` config, falls back to org-level from edition JSON.
|
|
15
|
-
|
|
16
|
-
## Auto-Cleanup V2
|
|
17
|
-
- **Co-located `*.cleanup.json` registry**: Each module defines cleanup rules alongside generators. Scanned globally.
|
|
18
|
-
- **Fixture teardown cleanup**: Runs after each scenario (pass or fail). Supports OAS, REST DELETE, REST PATCH.
|
|
19
|
-
- **`autoCleanup` config**: Enable/disable via `uat.config.js` (default: `true`).
|
|
20
|
-
- **Detailed logging**: Cleanup started/completed/success/failed with entity names and IDs.
|
|
21
|
-
|
|
22
|
-
## Portal Resolution — Capability Support
|
|
23
|
-
- **`capability` field**: Portals can define a `capability` field for DC-agnostic resolution.
|
|
24
|
-
- **Dual resolution**: `@portal_` tags resolve by `capability` first, then `orgName` fallback.
|
|
25
|
-
- **Backward compatible**: Existing `orgName`-based tags still work.
|
|
26
|
-
|
|
27
|
-
## Bug Fixes
|
|
28
|
-
- Fixed `#getModulesRoot` hitting nested `modules/` directories.
|
|
29
|
-
- Removed cleanup V1 — replaced by V2.
|
|
30
|
-
|
|
31
4
|
# 0.2.4
|
|
32
5
|
- Issue fixes on custom fixtures
|
|
33
6
|
- Page Fixture
|