@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 CHANGED
@@ -18,6 +18,7 @@
18
18
  ],
19
19
  // Ignored as these are setup files needed during init script. Files inside that folder are copied not transformed
20
20
  "ignore": [
21
- "./src/setup-folder-structure/samples"
21
+ "./src/setup-folder-structure/samples",
22
+ "./src/common/**"
22
23
  ]
23
24
  }
@@ -1,46 +1,19 @@
1
- "use strict";
1
+ import { createBdd , test } from '@zohodesk/testinglibrary';
2
+ import { generateAndCacheTestData } from './DataGeneratorStepsHelper';
2
3
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _testinglibrary = require("@zohodesk/testinglibrary");
5
- var _DataGenerator = _interopRequireDefault(require("@zohodesk/testinglibrary/DataGenerator"));
6
- var _DataGeneratorStepsHelper = require("./DataGeneratorStepsHelper");
7
- const {
8
- Given
9
- } = (0, _testinglibrary.createBdd)();
10
- const dataGenerator = new _DataGenerator.default();
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 API {string}', async ({
21
- page,
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
- 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);
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
- "use strict";
1
+ import { test } from '@zohodesk/testinglibrary';
2
+ import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
2
3
 
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);
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
- "use strict";
1
+ import { createBdd } from '@zohodesk/testinglibrary';
2
+ const { BeforeScenario, Given } = createBdd();
2
3
 
3
- var _testinglibrary = require("@zohodesk/testinglibrary");
4
- const {
5
- BeforeScenario,
6
- Given
7
- } = (0, _testinglibrary.createBdd)();
8
- BeforeScenario(async function ({
9
- actorCtx
10
- }) {
11
- // This will run before each scenario and set all the fixtures into this context
12
- this.setActor = async role => {
13
- const userPage = actorCtx.actorsObj[role];
14
- if (userPage) {
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
- Given("access the {string} profile page", async function ({
26
- page
27
- }, userRole) {
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
- "use strict";
1
+ import { expect } from '@zohodesk/testinglibrary';
2
2
 
3
- var _testinglibrary = require("@zohodesk/testinglibrary");
4
3
  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()}`);
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
- 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;
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
- module.exports = {
35
- executeRpcRequest,
36
- entityIdReConstructor
37
- };
40
+
41
+ module.exports = { executeRpcRequest, entityIdReConstructor };
@@ -1,30 +1,26 @@
1
- "use strict";
1
+ import {createBdd } from '@zohodesk/testinglibrary';
2
+ import { executeRpcRequest , entityIdReConstructor } from '../helpers/rpcRequestHelper';
2
3
 
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
- });
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
+ });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.4.86-n18-experimental",
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.86-n18-experimental",
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.86-n18-experimental",
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"