@zohodesk/testinglibrary 0.4.86-n18-experimental → 0.4.88-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/.babelrc +2 -1
- package/build/common/data-generator/steps/DataGenerator.spec.js +15 -42
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +17 -20
- package/build/common/multi-actor/steps/additionalContext.spec.js +17 -25
- package/build/common/searchFake/helpers/rpcRequestHelper.js +35 -31
- package/build/common/searchFake/steps/searchFake.spec.js +25 -29
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/.babelrc
CHANGED
|
@@ -1,46 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { createBdd , test } from '@zohodesk/testinglibrary';
|
|
2
|
+
import { generateAndCacheTestData } from './DataGeneratorStepsHelper';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Given('generate a {string} entity {string} with generator {string}', async ({
|
|
12
|
-
page,
|
|
13
|
-
context,
|
|
14
|
-
i18N,
|
|
15
|
-
cacheLayer,
|
|
16
|
-
executionContext
|
|
17
|
-
}, module, entityName, generatorName, dataTable) => {
|
|
18
|
-
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "template", generatorName, dataTable, cacheLayer, entityName);
|
|
4
|
+
const { Given } = createBdd();
|
|
5
|
+
|
|
6
|
+
Given('generate a {string} entity {string} with generator {string}', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, generatorName, dataTable) => {
|
|
7
|
+
await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
Given('generate a {string} entity {string} with API {string}', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, dataTable) => {
|
|
11
|
+
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName);
|
|
19
12
|
});
|
|
20
|
-
Given('generate a {string} entity {string} with
|
|
21
|
-
|
|
22
|
-
context,
|
|
23
|
-
i18N,
|
|
24
|
-
cacheLayer,
|
|
25
|
-
executionContext
|
|
26
|
-
}, module, entityName, operationId, dataTable) => {
|
|
27
|
-
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "API", operationId, dataTable, cacheLayer, entityName);
|
|
13
|
+
Given('generate a {string} entity {string} with generator {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, generatorName, profile, dataTable) => {
|
|
14
|
+
await generateAndCacheTestData(executionContext, "template", generatorName, dataTable, cacheLayer, entityName, profile);
|
|
28
15
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
i18N,
|
|
33
|
-
cacheLayer,
|
|
34
|
-
executionContext
|
|
35
|
-
}, module, entityName, generatorName, profile, dataTable) => {
|
|
36
|
-
await (0, _DataGeneratorStepsHelper.generateAndCacheTestData)(executionContext, "template", generatorName, dataTable, cacheLayer, entityName, profile);
|
|
16
|
+
|
|
17
|
+
Given('generate a {string} entity {string} with API {string} using {string} profile', async ({ page, context, i18N, cacheLayer, executionContext}, module, entityName, operationId, profile, dataTable) => {
|
|
18
|
+
await generateAndCacheTestData(executionContext, "API", operationId, dataTable, cacheLayer, entityName, profile);
|
|
37
19
|
});
|
|
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);
|
|
46
|
-
});
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { test } from '@zohodesk/testinglibrary';
|
|
2
|
+
import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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);
|
|
4
|
+
const dataGenerator = new DataGenerator();
|
|
5
|
+
|
|
6
|
+
export async function generateAndCacheTestData(executionContext, type, identifier, dataTable, cacheLayer, entityName, profile = null) {
|
|
7
|
+
let actorInfo;
|
|
8
|
+
const testInfo = test.info();
|
|
9
|
+
const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
|
|
10
|
+
|
|
11
|
+
if (profile) {
|
|
12
|
+
actorInfo = await dataGenerator.getDataGenUserExecutionContext(executionContext.actorInfo.edition, profile);
|
|
13
|
+
} else {
|
|
14
|
+
actorInfo = executionContext.actorInfo;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const generatedData = await dataGenerator.generate(testInfo, actorInfo, type, identifier, scenarioName, dataTable ? dataTable.hashes() : []);
|
|
18
|
+
await cacheLayer.set(entityName, generatedData.data);
|
|
22
19
|
}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { createBdd } from '@zohodesk/testinglibrary';
|
|
2
|
+
const { BeforeScenario, Given } = createBdd();
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.page = userPage.page;
|
|
16
|
-
this.context = userPage.context;
|
|
17
|
-
this.browser = userPage.browser;
|
|
18
|
-
this.executionContext = userPage.actorInfo;
|
|
19
|
-
} else {
|
|
20
|
-
const availableRoles = Object.keys(actorCtx.actorsObj);
|
|
21
|
-
throw new Error(`Actor "${role}" not found in user pages. Available roles: [${availableRoles.join(', ')}]`);
|
|
4
|
+
BeforeScenario(async function({ actorCtx }) {
|
|
5
|
+
// This will run before each scenario and set all the fixtures into this context
|
|
6
|
+
this.setActor = async (role) => {
|
|
7
|
+
const userPage = actorCtx.actorsObj[role];
|
|
8
|
+
if (userPage) {
|
|
9
|
+
this.page = userPage.page;
|
|
10
|
+
this.context = userPage.context;
|
|
11
|
+
this.browser = userPage.browser;
|
|
12
|
+
this.executionContext = userPage.actorInfo;
|
|
13
|
+
} else {
|
|
14
|
+
throw new Error(`Actor "${role}" not found in user pages.`);
|
|
15
|
+
}
|
|
22
16
|
}
|
|
23
|
-
};
|
|
24
17
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
await this.setActor(userRole);
|
|
18
|
+
|
|
19
|
+
Given("access the {string} profile page", async function({ page }, userRole) {
|
|
20
|
+
await this.setActor(userRole);
|
|
29
21
|
});
|
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
import { expect } from '@zohodesk/testinglibrary';
|
|
2
2
|
|
|
3
|
-
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
4
3
|
async function executeRpcRequest(page, payload) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
|
|
5
|
+
const url = new URL(page.url());
|
|
6
|
+
const baseUrl = `${url.protocol}//${url.host}`;
|
|
7
|
+
const invokeURL = `${baseUrl}/api/testing/acceptanceTest/rpc/invoke`;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const response = await page.request.post(invokeURL, {
|
|
11
|
+
headers: {'Content-Type': 'application/json'},
|
|
12
|
+
data: payload
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (!response.ok()) {
|
|
16
|
+
throw new Error(`HTTP ${response.status()}: ${response.statusText()}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const responseData = await response.json();
|
|
20
|
+
expect(responseData.data).toHaveProperty('status', 'success');
|
|
21
|
+
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw error;
|
|
17
24
|
}
|
|
18
|
-
const responseData = await response.json();
|
|
19
|
-
(0, _testinglibrary.expect)(responseData.data).toHaveProperty('status', 'success');
|
|
20
|
-
} catch (error) {
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
|
|
24
28
|
async function entityIdReConstructor(payload) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
|
|
30
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
31
|
+
throw new Error('Invalid payload. It must be a non-null object.');
|
|
32
|
+
}
|
|
33
|
+
if (!payload.arguments || typeof payload.arguments.entityId !== 'string') {
|
|
34
|
+
throw new Error('Invalid payload.arguments.entityId. It must be a non-empty string.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
payload.arguments.entityId = payload.arguments.entityId.split(',').map(id => id.trim());
|
|
38
|
+
return payload;
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
entityIdReConstructor
|
|
37
|
-
};
|
|
40
|
+
|
|
41
|
+
module.exports = { executeRpcRequest, entityIdReConstructor };
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import {createBdd } from '@zohodesk/testinglibrary';
|
|
2
|
+
import { executeRpcRequest , entityIdReConstructor } from '../helpers/rpcRequestHelper';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
await (0, _rpcRequestHelper.entityIdReConstructor)(payload);
|
|
28
|
-
await (0, _rpcRequestHelper.executeRpcRequest)(page, payload);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
4
|
+
const { Given } = createBdd();
|
|
5
|
+
|
|
6
|
+
Given('a search entity', async ({page}, dataTable)=>{
|
|
7
|
+
const data = dataTable.hashes();
|
|
8
|
+
|
|
9
|
+
for (const row of data) {
|
|
10
|
+
|
|
11
|
+
const { moduleName, entityId, searchString } = row;
|
|
12
|
+
const payload = {
|
|
13
|
+
className: 'applicationDriver.rpc.desk.integrations.search.SearchFakeDataPopulator',
|
|
14
|
+
methodName: 'populateSearchData',
|
|
15
|
+
arguments: {
|
|
16
|
+
module: moduleName,
|
|
17
|
+
searchString: searchString,
|
|
18
|
+
entityId: entityId
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
await entityIdReConstructor(payload);
|
|
22
|
+
|
|
23
|
+
await executeRpcRequest(page, payload);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
});
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.88-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.88-n18-experimental",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.88-n18-experimental",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"clean": "rm -rf build && mkdir build",
|
|
10
10
|
"build-babel": "babel -d ./build ./src --copy-files",
|
|
11
|
+
"copy-common": "cp -r src/common build/",
|
|
11
12
|
"build": "npm run clean && npm run build-babel",
|
|
12
13
|
"prepare": "npm run build",
|
|
13
14
|
"lint": "eslint src/* --fix"
|