@zohodesk/testinglibrary 0.0.52-n20-experimental → 0.0.54-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/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 +7625 -2922
- package/package.json +15 -11
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54-n20-experimental",
|
|
4
4
|
"main": "./build/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node bin/postinstall.js",
|
|
@@ -26,11 +26,13 @@
|
|
|
26
26
|
"@playwright/test": "1.56.1",
|
|
27
27
|
"@reportportal/agent-js-playwright": "5.2.2",
|
|
28
28
|
"@testing-library/jest-dom": "6.9.1",
|
|
29
|
-
"
|
|
29
|
+
"@zohodesk/unit-testing-framework": "0.0.30-experimental",
|
|
30
|
+
"babel-jest": "29.7.0",
|
|
30
31
|
"babel-plugin-transform-dynamic-import": "2.1.0",
|
|
32
|
+
"commander": "14.0.2",
|
|
31
33
|
"fast-glob": "3.3.3",
|
|
32
|
-
"jest": "
|
|
33
|
-
"jest-environment-jsdom": "
|
|
34
|
+
"jest": "29.7.0",
|
|
35
|
+
"jest-environment-jsdom": "29.7.0",
|
|
34
36
|
"jsonpath": "1.1.1",
|
|
35
37
|
"msw": "2.11.6",
|
|
36
38
|
"playwright": "1.56.1",
|
|
@@ -47,13 +49,15 @@
|
|
|
47
49
|
"react-dom": "*"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "7.28.
|
|
51
|
-
"@babel/core": "7.
|
|
52
|
-
"@babel/node": "7.
|
|
52
|
+
"@babel/cli": "7.28.6",
|
|
53
|
+
"@babel/core": "7.29.0",
|
|
54
|
+
"@babel/node": "7.29.0",
|
|
53
55
|
"@babel/plugin-transform-runtime": "7.28.3",
|
|
54
|
-
"@babel/preset-env": "7.
|
|
55
|
-
"@babel/
|
|
56
|
-
"
|
|
57
|
-
"jest-html-reporter": "4.3.0"
|
|
56
|
+
"@babel/preset-env": "7.29.0",
|
|
57
|
+
"@babel/preset-react": "7.26.3",
|
|
58
|
+
"@babel/runtime": "7.28.6",
|
|
59
|
+
"jest-html-reporter": "4.3.0",
|
|
60
|
+
"ts-jest": "29.3.2",
|
|
61
|
+
"@babel/preset-typescript": "7.26.0"
|
|
58
62
|
}
|
|
59
63
|
}
|
package/AUTO_CLEANUP_PLAN.md
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
# Data Generator System — Design & Current State
|
|
2
|
-
|
|
3
|
-
## Data Generator Overview
|
|
4
|
-
|
|
5
|
-
### How It Works
|
|
6
|
-
- BDD step: `Given generate a "{Type}" entity "{name}" with generator "{GeneratorName}"`
|
|
7
|
-
- Framework builds a **global generator index** at first use — scans all `*.generators.json` files under `modules/`
|
|
8
|
-
- Generator names must be **unique across the entire UAT suite**
|
|
9
|
-
- `ZDTestingFramework validate` checks for duplicate generator names before test run
|
|
10
|
-
- Data generated using **org-level OAuth credentials** (org-oauth) by default
|
|
11
|
-
- When scenario runs under a non-admin profile (`@profile_agent`), data generation still uses org-level `data-generator` — falls back automatically if profile has no own credentials
|
|
12
|
-
|
|
13
|
-
### Generator File Convention
|
|
14
|
-
- **Pattern:** `*.generators.json` (configurable via `generatorFilePattern` in `uat.config.js`)
|
|
15
|
-
- **Location:** anywhere under `modules/` — discovered globally via recursive scan
|
|
16
|
-
- **Examples:** `ticket.generators.json`, `account.generators.json`, `webhook.generators.json`
|
|
17
|
-
|
|
18
|
-
### Generator JSON Structure
|
|
19
|
-
```json
|
|
20
|
-
{
|
|
21
|
-
"generators": {
|
|
22
|
-
"GeneratorName": [
|
|
23
|
-
{
|
|
24
|
-
"type": "dynamic",
|
|
25
|
-
"name": "stepName",
|
|
26
|
-
"generatorOperationId": "support.Module.operationName",
|
|
27
|
-
"dataPath": "$.response.body:$",
|
|
28
|
-
"params": { "key": "$previousStep.value" }
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Discovery Mechanism
|
|
36
|
-
- **Index-based** — built once, O(1) lookups
|
|
37
|
-
- `#getModulesRoot()` uses `configConstants.TEST_SLICE_FOLDER + stage + 'modules'` (deterministic)
|
|
38
|
-
- Scans recursively for files matching `generatorFilePattern` (default: `*.generators.json`)
|
|
39
|
-
- First generator name match wins (no duplicates enforced by validator)
|
|
40
|
-
|
|
41
|
-
### Profile Resolution for Data Generation
|
|
42
|
-
- **Default (no `using` profile):** Uses org-level `data-generator` from edition JSON. If scenario profile (e.g., `@profile_agent`) has no `data-generator`, falls back to org-level via `getListOfActors()`.
|
|
43
|
-
- **Explicit profile (`using "agent" profile`):** Resolves that profile's credentials via `getUserForSelectedEditionAndProfile()`.
|
|
44
|
-
|
|
45
|
-
### Constraints
|
|
46
|
-
| Constraint | Detail |
|
|
47
|
-
|---|---|
|
|
48
|
-
| **Unique generator names** | Generator names must be unique across all `*.generators.json` files |
|
|
49
|
-
| **Global discovery** | Framework scans entire `modules/` tree — generators in any module are accessible from any feature file |
|
|
50
|
-
| **File pattern** | Configurable via `generatorFilePattern` in `uat.config.js` (default: `*.generators.json`) |
|
|
51
|
-
| **DG_API_NAME matching** | In Gherkin data tables, `DG_API_NAME` column matches generator step's `name` field to inject params |
|
|
52
|
-
| **Chained steps** | Multi-step generators use `$previousStep.value` syntax to pass output between steps |
|
|
53
|
-
| **dataPath extraction** | `dataPath` uses JSONPath to extract specific fields from DG service response |
|
|
54
|
-
| **Cached response** | Generated data is cached via `cacheLayer.set(entityName, response.data)` for use in subsequent steps |
|
|
55
|
-
| **Org-level auth fallback** | If profile has no `data-generator`, org-level config from edition JSON is used automatically |
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## Current Generators
|
|
60
|
-
|
|
61
|
-
| Generator | File | Steps | Used By |
|
|
62
|
-
|---|---|---|---|
|
|
63
|
-
| `TicketWithDepartment` | `Ticket/data-generators/ticket.generators.json` | getDepartments → createProduct → createTicket | 452+ scenarios |
|
|
64
|
-
| `TicketBasic` | `Ticket/data-generators/ticket.generators.json` | getDepartments → createTicket (no product) | Express/Free editions |
|
|
65
|
-
| `CreateAccountRecord` | `Account/data-generators/account.generators.json` | createAccount | 37 scenarios |
|
|
66
|
-
| `CreateContactRecord` | `Contact/data-generators/contact.generators.json` | createContact | 42 scenarios |
|
|
67
|
-
| `CreateContractRecord` | `Contract/DV/Subtabs/*/data-generators/contract.generators.json` | getDepartments → createAccount → createContract | 4 scenarios |
|
|
68
|
-
| `CreateWebhookRecord` | `Webhooks/List/data-generators/webhook.generators.json` | createWebhook (with default subscriptions) | Webhook scenarios |
|
|
69
|
-
| `ProductWithDepartment` | `Search/products/data-generators/products.generators.json` | getDepartments → createProduct | Product/Search scenarios |
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Auto-Cleanup — Design (Not Yet Implemented)
|
|
74
|
-
|
|
75
|
-
### Status
|
|
76
|
-
- **V1 implemented then removed** in `0.0.47` — CleanupTracker + DataCleanup were too tightly coupled
|
|
77
|
-
- **V2 planned** — proper redesign needed
|
|
78
|
-
|
|
79
|
-
### Why Cleanup Was Removed
|
|
80
|
-
1. `cleanupTracker` fixture added complexity to all step definitions (extra parameter)
|
|
81
|
-
2. Cleanup ran inside fixture teardown — failures were hard to debug
|
|
82
|
-
3. REST API cleanup needed auth that wasn't available in the cleanup context
|
|
83
|
-
4. No way to control cleanup order for cross-entity dependencies
|
|
84
|
-
|
|
85
|
-
### V2 Design Principles
|
|
86
|
-
1. **Cleanup config stays in generator JSON** — `cleanup` property on each step (same as V1)
|
|
87
|
-
2. **Separate cleanup phase** — not in fixture teardown, but as explicit post-scenario hook
|
|
88
|
-
3. **Auth-aware** — cleanup uses the same `actorInfo` that created the data
|
|
89
|
-
4. **Configurable** — cleanup can be disabled per scenario or globally
|
|
90
|
-
5. **Non-blocking** — cleanup failures never fail the test
|
|
91
|
-
|
|
92
|
-
### Cleanup Types (unchanged from V1 design)
|
|
93
|
-
|
|
94
|
-
#### Type 1: `oas` — DG service delete
|
|
95
|
-
```json
|
|
96
|
-
"cleanup": {
|
|
97
|
-
"type": "oas",
|
|
98
|
-
"operationId": "support.Contact.deleteContact",
|
|
99
|
-
"idPath": "$.id"
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
#### Type 2: `api` — Direct REST API DELETE
|
|
104
|
-
```json
|
|
105
|
-
"cleanup": {
|
|
106
|
-
"type": "api",
|
|
107
|
-
"method": "DELETE",
|
|
108
|
-
"apiPath": "/api/v1/contracts/{id}",
|
|
109
|
-
"idPath": "$.id"
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
#### Type 3: `api` — Disable via PATCH
|
|
114
|
-
```json
|
|
115
|
-
"cleanup": {
|
|
116
|
-
"type": "api",
|
|
117
|
-
"method": "PATCH",
|
|
118
|
-
"apiPath": "/api/v1/webhooks/{id}",
|
|
119
|
-
"idPath": "$.id",
|
|
120
|
-
"body": { "isActive": false }
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
#### No cleanup — read-only operations
|
|
125
|
-
Steps without `cleanup` property are skipped (e.g., `getDepartments`).
|
|
126
|
-
|
|
127
|
-
### V2 Implementation Plan
|
|
128
|
-
|
|
129
|
-
1. **CleanupManager** (replaces CleanupTracker + DataCleanup)
|
|
130
|
-
- Single class managing both tracking and execution
|
|
131
|
-
- Runs after scenario via `testSetup` hook (not fixture teardown)
|
|
132
|
-
- Uses `actorInfo` from the generation step for auth
|
|
133
|
-
|
|
134
|
-
2. **Config flag** in `uat.config.js`:
|
|
135
|
-
```javascript
|
|
136
|
-
autoCleanup: true, // default: true
|
|
137
|
-
cleanupTimeout: 30000 // per-entity timeout
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
3. **Per-scenario opt-out** via tag:
|
|
141
|
-
```gherkin
|
|
142
|
-
@skip_cleanup
|
|
143
|
-
Scenario: Test that needs data to persist
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
4. **Cleanup order**: reverse of creation (dependent entities first)
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Seed Data System — Design (Planned)
|
|
151
|
-
|
|
152
|
-
See `SEED_DATA_PLAN.md` in the consumer repo for the full design.
|
|
153
|
-
|
|
154
|
-
### Summary
|
|
155
|
-
- **Edition-scoped** — data maps to edition tiers, not portal names
|
|
156
|
-
- **Profile-based** — support creating data as specific profiles (agent login)
|
|
157
|
-
- **OAS + REST** — both API types supported
|
|
158
|
-
- **Runs before scenarios** — in `page.js` fixture after login
|
|
159
|
-
- **Idempotent** — skips existing data, creates only missing
|
|
160
|
-
|
|
161
|
-
---
|
|
162
|
-
|
|
163
|
-
## Multi-DC Portability — Design (Planned)
|
|
164
|
-
|
|
165
|
-
See `MULTI_DC_STRATEGY.md` in the consumer repo for the full design.
|
|
166
|
-
|
|
167
|
-
### Summary
|
|
168
|
-
- **`capability` field** on each portal for DC-agnostic resolution
|
|
169
|
-
- **Department aliases** in portal config for cross-DC mapping
|
|
170
|
-
- **Framework resolves** by `capability` first, `orgName` fallback
|
|
171
|
-
- **Same feature files** work across all DCs
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.validateGenerators = validateGenerators;
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
-
var _logger = require("../../utils/logger");
|
|
11
|
-
var _readConfigFile = require("../playwright/readConfigFile");
|
|
12
|
-
function matchesPattern(filename, pattern) {
|
|
13
|
-
const regex = new RegExp('^' + pattern.replace(/\./g, '\\.').replace(/\*/g, '.*') + '$');
|
|
14
|
-
return regex.test(filename);
|
|
15
|
-
}
|
|
16
|
-
function findGeneratorFiles(dir, pattern, results = []) {
|
|
17
|
-
const entries = _fs.default.readdirSync(dir, {
|
|
18
|
-
withFileTypes: true
|
|
19
|
-
});
|
|
20
|
-
for (const entry of entries) {
|
|
21
|
-
const fullPath = _path.default.join(dir, entry.name);
|
|
22
|
-
if (entry.isDirectory()) {
|
|
23
|
-
findGeneratorFiles(fullPath, pattern, results);
|
|
24
|
-
} else if (matchesPattern(entry.name, pattern)) {
|
|
25
|
-
results.push(fullPath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return results;
|
|
29
|
-
}
|
|
30
|
-
function validateGenerators(modulesRoot) {
|
|
31
|
-
if (!_fs.default.existsSync(modulesRoot)) {
|
|
32
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Modules directory not found: ${modulesRoot}. Skipping generator validation.`);
|
|
33
|
-
return {
|
|
34
|
-
valid: true,
|
|
35
|
-
duplicates: []
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const {
|
|
39
|
-
generatorFilePattern: pattern = '*.generators.json'
|
|
40
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
41
|
-
const generatorMap = {};
|
|
42
|
-
const generatorFiles = findGeneratorFiles(modulesRoot, pattern);
|
|
43
|
-
for (const filePath of generatorFiles) {
|
|
44
|
-
try {
|
|
45
|
-
const data = _fs.default.readFileSync(filePath, 'utf8');
|
|
46
|
-
const generatorObj = JSON.parse(data);
|
|
47
|
-
if (generatorObj.generators) {
|
|
48
|
-
for (const name of Object.keys(generatorObj.generators)) {
|
|
49
|
-
if (!generatorMap[name]) {
|
|
50
|
-
generatorMap[name] = [];
|
|
51
|
-
}
|
|
52
|
-
generatorMap[name].push(filePath);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
} catch (err) {
|
|
56
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to parse generator file: ${filePath} - ${err.message}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const duplicates = Object.entries(generatorMap).filter(([, files]) => files.length > 1).map(([name, files]) => ({
|
|
60
|
-
name,
|
|
61
|
-
files
|
|
62
|
-
}));
|
|
63
|
-
if (duplicates.length > 0) {
|
|
64
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Duplicate generator names found:');
|
|
65
|
-
for (const dup of duplicates) {
|
|
66
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, ` Generator "${dup.name}" defined in:`);
|
|
67
|
-
for (const file of dup.files) {
|
|
68
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, ` - ${file}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
valid: false,
|
|
73
|
-
duplicates
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const generatorCount = Object.keys(generatorMap).length;
|
|
77
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Generator validation passed. ${generatorCount} unique generators found across ${generatorFiles.length} generator files.`);
|
|
78
|
-
return {
|
|
79
|
-
valid: true,
|
|
80
|
-
duplicates: []
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = generateReport;
|
|
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
|
-
async function generateReport() {
|
|
14
|
-
// await preProcessReport()
|
|
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
|
-
}
|