@zohodesk/testinglibrary 0.4.78-n18-experimental → 0.4.80-n18-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/build/common/data-generator/steps/DataGenerator.spec.js +22 -11
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +22 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +37 -0
- package/build/common/searchFake/steps/searchFake.spec.js +30 -0
- package/build/core/dataGenerator/DataGenerator.js +10 -0
- package/build/core/playwright/setup/config-creator.js +2 -1
- package/build/core/playwright/setup/config-utils.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
5
5
|
var _DataGenerator = _interopRequireDefault(require("@zohodesk/testinglibrary/DataGenerator"));
|
|
6
|
+
var _DataGeneratorStepsHelper = require("./DataGeneratorStepsHelper");
|
|
6
7
|
const {
|
|
7
|
-
Given
|
|
8
|
-
When,
|
|
9
|
-
Then
|
|
8
|
+
Given
|
|
10
9
|
} = (0, _testinglibrary.createBdd)();
|
|
11
10
|
const dataGenerator = new _DataGenerator.default();
|
|
12
11
|
Given('generate a {string} entity {string} with generator {string}', async ({
|
|
@@ -16,10 +15,7 @@ Given('generate a {string} entity {string} with generator {string}', async ({
|
|
|
16
15
|
cacheLayer,
|
|
17
16
|
executionContext
|
|
18
17
|
}, module, entityName, generatorName, dataTable) => {
|
|
19
|
-
|
|
20
|
-
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
21
|
-
const generatedData = await dataGenerator.generate(testInfo, executionContext.actorInfo, "template", generatorName, scenarioName, dataTable ? dataTable.hashes() : []);
|
|
22
|
-
await cacheLayer.set(entityName, generatedData.data);
|
|
18
|
+
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "template", generatorName, dataTable, cacheLayer, entityName);
|
|
23
19
|
});
|
|
24
20
|
Given('generate a {string} entity {string} with API {string}', async ({
|
|
25
21
|
page,
|
|
@@ -28,8 +24,23 @@ Given('generate a {string} entity {string} with API {string}', async ({
|
|
|
28
24
|
cacheLayer,
|
|
29
25
|
executionContext
|
|
30
26
|
}, module, entityName, operationId, dataTable) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "API", operationId, dataTable, cacheLayer, entityName);
|
|
28
|
+
});
|
|
29
|
+
Given('generate a {string} entity {string} with generator {string} using {string} profile', async ({
|
|
30
|
+
page,
|
|
31
|
+
context,
|
|
32
|
+
i18N,
|
|
33
|
+
cacheLayer,
|
|
34
|
+
executionContext
|
|
35
|
+
}, module, entityName, generatorName, profile, dataTable) => {
|
|
36
|
+
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "template", generatorName, dataTable, cacheLayer, entityName, profile);
|
|
37
|
+
});
|
|
38
|
+
Given('generate a {string} entity {string} with API {string} using {string} profile', async ({
|
|
39
|
+
page,
|
|
40
|
+
context,
|
|
41
|
+
i18N,
|
|
42
|
+
cacheLayer,
|
|
43
|
+
executionContext
|
|
44
|
+
}, module, entityName, operationId, profile, dataTable) => {
|
|
45
|
+
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "API", operationId, dataTable, cacheLayer, entityName, profile);
|
|
35
46
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.generateAndCacheTestData = generateAndCacheTestData;
|
|
8
|
+
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
9
|
+
var _DataGenerator = _interopRequireDefault(require("@zohodesk/testinglibrary/DataGenerator"));
|
|
10
|
+
const dataGenerator = new _DataGenerator.default();
|
|
11
|
+
async function generateAndCacheTestData(executionContext, type, identifier, dataTable, cacheLayer, entityName, profile = null) {
|
|
12
|
+
let actorInfo;
|
|
13
|
+
const testInfo = _testinglibrary.test.info();
|
|
14
|
+
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
15
|
+
if (profile) {
|
|
16
|
+
actorInfo = await dataGenerator.getDataGenUserExecutionContext(executionContext.actorInfo.edition, profile);
|
|
17
|
+
} else {
|
|
18
|
+
actorInfo = executionContext.actorInfo;
|
|
19
|
+
}
|
|
20
|
+
const generatedData = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []);
|
|
21
|
+
await cacheLayer.set(entityName, generatedData.data);
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
4
|
+
async function executeRpcRequest(page, payload) {
|
|
5
|
+
const url = new URL(page.url());
|
|
6
|
+
const baseUrl = `${url.protocol}//${url.host}`;
|
|
7
|
+
const invokeURL = `${baseUrl}/api/testing/acceptanceTest/rpc/invoke`;
|
|
8
|
+
try {
|
|
9
|
+
const response = await page.request.post(invokeURL, {
|
|
10
|
+
headers: {
|
|
11
|
+
'Content-Type': 'application/json'
|
|
12
|
+
},
|
|
13
|
+
data: payload
|
|
14
|
+
});
|
|
15
|
+
if (!response.ok()) {
|
|
16
|
+
throw new Error(`HTTP ${response.status()}: ${response.statusText()}`);
|
|
17
|
+
}
|
|
18
|
+
const responseData = await response.json();
|
|
19
|
+
(0, _testinglibrary.expect)(responseData.data).toHaveProperty('status', 'success');
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function entityIdReConstructor(payload) {
|
|
25
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
26
|
+
throw new Error('Invalid payload. It must be a non-null object.');
|
|
27
|
+
}
|
|
28
|
+
if (!payload.arguments || typeof payload.arguments.entityId !== 'string') {
|
|
29
|
+
throw new Error('Invalid payload.arguments.entityId. It must be a non-empty string.');
|
|
30
|
+
}
|
|
31
|
+
payload.arguments.entityId = payload.arguments.entityId.split(',').map(id => id.trim());
|
|
32
|
+
return payload;
|
|
33
|
+
}
|
|
34
|
+
module.exports = {
|
|
35
|
+
executeRpcRequest,
|
|
36
|
+
entityIdReConstructor
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
4
|
+
var _rpcRequestHelper = require("../helpers/rpcRequestHelper");
|
|
5
|
+
const {
|
|
6
|
+
Given
|
|
7
|
+
} = (0, _testinglibrary.createBdd)();
|
|
8
|
+
Given('a search entity', async ({
|
|
9
|
+
page
|
|
10
|
+
}, dataTable) => {
|
|
11
|
+
const data = dataTable.hashes();
|
|
12
|
+
for (const row of data) {
|
|
13
|
+
const {
|
|
14
|
+
moduleName,
|
|
15
|
+
entityId,
|
|
16
|
+
searchString
|
|
17
|
+
} = row;
|
|
18
|
+
const payload = {
|
|
19
|
+
className: 'applicationDriver.rpc.desk.integrations.search.SearchFakeDataPopulator',
|
|
20
|
+
methodName: 'populateSearchData',
|
|
21
|
+
arguments: {
|
|
22
|
+
module: moduleName,
|
|
23
|
+
searchString: searchString,
|
|
24
|
+
entityId: entityId
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
await (0, _rpcRequestHelper.entityIdReConstructor)(payload);
|
|
28
|
+
await (0, _rpcRequestHelper.executeRpcRequest)(page, payload);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -9,6 +9,7 @@ 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
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
13
14
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
14
15
|
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"); }
|
|
@@ -35,6 +36,15 @@ class DataGenerator {
|
|
|
35
36
|
throw error;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
async getDataGenUserExecutionContext(edition, profile) {
|
|
40
|
+
try {
|
|
41
|
+
const dataGenUserDetails = await (0, _helpers.getUserForSelectedEditionAndProfile)(edition, profile);
|
|
42
|
+
return dataGenUserDetails;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Error occurred while fetching data generation user details: ', error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
async function _getGenerator(testInfo, generatorName) {
|
|
40
50
|
let generator = null;
|
|
@@ -153,7 +153,7 @@ function getPathsForFeatureFiles(cwd) {
|
|
|
153
153
|
let moduleList = modules.split(',');
|
|
154
154
|
return getModulePathForFeatureFiles(moduleList);
|
|
155
155
|
}
|
|
156
|
-
return [_path.default.join(cwd, 'uat', '**', '*.feature')];
|
|
156
|
+
return [_path.default.join(cwd, 'uat', 'modules', '**', '*.feature')];
|
|
157
157
|
}
|
|
158
158
|
function getModulePathForFeatureFiles(moduleList) {
|
|
159
159
|
let validModuleList = [];
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.80-n18-experimental",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@zohodesk/testinglibrary",
|
|
9
|
-
"version": "0.4.
|
|
9
|
+
"version": "0.4.80-n18-experimental",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|