@zohodesk/testinglibrary 0.0.3-n20-experimental → 0.0.4-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/.babelrc +2 -1
- package/.gitlab-ci.yml +13 -1
- package/README.md +72 -2
- package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +19 -0
- package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +41 -0
- package/build/common/searchFake/steps/searchFake.spec.js +26 -0
- package/build/core/dataGenerator/DataGenerator.js +94 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +49 -0
- package/build/core/playwright/builtInFixtures/actorContext.js +75 -0
- package/build/core/playwright/builtInFixtures/executionContext.js +5 -5
- package/build/core/playwright/builtInFixtures/index.js +2 -0
- package/build/core/playwright/builtInFixtures/page.js +3 -66
- package/build/core/playwright/helpers/additionalProfiles.js +12 -5
- package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +54 -0
- package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
- package/build/core/playwright/runner/SpawnRunner.js +3 -0
- package/build/core/playwright/setup/config-creator.js +20 -16
- package/build/core/playwright/setup/config-utils.js +2 -3
- package/build/core/playwright/setup/qc-custom-reporter.js +1 -1
- package/build/core/playwright/test-runner.js +1 -1
- package/build/setup-folder-structure/samples/settings.json +1 -1
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +6 -6
- package/build/test/core/playwright/helpers/__tests__/additionalProfiles.test.js +45 -0
- package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
- package/build/utils/commonUtils.js +17 -0
- package/build/utils/fileUtils.js +20 -0
- package/build/utils/logger.js +0 -29
- package/npm-shrinkwrap.json +1964 -2743
- package/package.json +20 -19
- package/test-results/.last-run.json +4 -0
- package/unit_reports/unit-report.html +260 -0
package/.babelrc
CHANGED
package/.gitlab-ci.yml
CHANGED
|
@@ -160,4 +160,16 @@ uat-smoketest:
|
|
|
160
160
|
paths:
|
|
161
161
|
- examples/uat/playwright-report
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
uat-multiactor:
|
|
164
|
+
stage: uat
|
|
165
|
+
script:
|
|
166
|
+
- cd examples
|
|
167
|
+
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
168
|
+
- output=$(npm run uat-multiactor)
|
|
169
|
+
- echo "$output"
|
|
170
|
+
- node ../ValidateUATReport.js examples
|
|
171
|
+
|
|
172
|
+
artifacts:
|
|
173
|
+
when: always
|
|
174
|
+
paths:
|
|
175
|
+
- examples/uat/playwright-report
|
package/README.md
CHANGED
|
@@ -12,12 +12,84 @@
|
|
|
12
12
|
### Run TestCase
|
|
13
13
|
|
|
14
14
|
- npm run test
|
|
15
|
+
|
|
15
16
|
### Generate Report
|
|
16
17
|
|
|
17
18
|
- npm run report
|
|
18
19
|
|
|
19
20
|
## Version History
|
|
20
21
|
|
|
22
|
+
### v3.2.8 - 18-09-2025
|
|
23
|
+
|
|
24
|
+
### Bug fix
|
|
25
|
+
|
|
26
|
+
- Default profile switching handled in Multi actor – Improved handling of default profile switching to ensure smoother execution flow.
|
|
27
|
+
|
|
28
|
+
- QC Report tags issue fixed – Resolved an issue where QC Report tags were not displaying correctly in reports.
|
|
29
|
+
|
|
30
|
+
### v3.2.7 - 10-09-2025
|
|
31
|
+
|
|
32
|
+
### Bug fix
|
|
33
|
+
- Fixed a bug where the default profile page was not being handled properly in `this`.
|
|
34
|
+
|
|
35
|
+
### v3.2.6 - 05-09-2025
|
|
36
|
+
|
|
37
|
+
#### Feature
|
|
38
|
+
|
|
39
|
+
- Multi-actor execution support – now possible to switch between multiple profile agents within scenarios using the predefined step: - `access the {string} profile page`
|
|
40
|
+
|
|
41
|
+
### Bug fix
|
|
42
|
+
- Fixed the issue where localapp and hcapp UAT were not running properly.
|
|
43
|
+
|
|
44
|
+
### v3.2.5 - 28-08-2025
|
|
45
|
+
|
|
46
|
+
#### Enhancement
|
|
47
|
+
|
|
48
|
+
- Removed the searchFake dependency from the project level and adopted it inside the framework, reducing project-side maintenance. use this predefined step: - `Given (a search entity)`
|
|
49
|
+
|
|
50
|
+
### v3.2.4 - 29-07-2025
|
|
51
|
+
|
|
52
|
+
#### Feature
|
|
53
|
+
- Data Generator steps are now supported directly via the framework.
|
|
54
|
+
|
|
55
|
+
### Bug fix
|
|
56
|
+
- Feature File Root Directory not found issue fixed
|
|
57
|
+
|
|
58
|
+
### v3.2.3 - 29-07-2025
|
|
59
|
+
|
|
60
|
+
#### Feature
|
|
61
|
+
- Added support for running Smoke Tests in the UAT stage.
|
|
62
|
+
|
|
63
|
+
### v3.2.0 - 22-06-2025
|
|
64
|
+
|
|
65
|
+
#### Feature
|
|
66
|
+
- Default required spec files are now auto-imported from the library into the project.
|
|
67
|
+
|
|
68
|
+
### v3.1.13 - 02-07-2025
|
|
69
|
+
|
|
70
|
+
#### Enhancement
|
|
71
|
+
- Below package versions are updated in this release.
|
|
72
|
+
- @cucumber/Cucumber - 11.3.0
|
|
73
|
+
- Playwright/test - 1.53.2
|
|
74
|
+
- Playwright - 1.53.2
|
|
75
|
+
- Playwright-bdd - 8.3.1
|
|
76
|
+
- QC custom reporter changes have been adopted into the framework.
|
|
77
|
+
|
|
78
|
+
### v3.1.5 - 22-05-2025
|
|
79
|
+
|
|
80
|
+
#### Feature
|
|
81
|
+
- Added support for Module Based Execution UAT stage.
|
|
82
|
+
|
|
83
|
+
### v3.1.4 - 12-05-2025
|
|
84
|
+
|
|
85
|
+
#### Enhancement
|
|
86
|
+
- Playwright version 1.52.0 adopted in testing framework
|
|
87
|
+
|
|
88
|
+
### v3.1.3 - 25-04-2025
|
|
89
|
+
|
|
90
|
+
#### Enhancement
|
|
91
|
+
- Playwright version 1.51.0 adopted in testing framework
|
|
92
|
+
|
|
21
93
|
### v0.2.8 - 26-09-2024
|
|
22
94
|
|
|
23
95
|
#### Feature
|
|
@@ -27,8 +99,6 @@
|
|
|
27
99
|
- Updated the custom-reported to include the errors in tests during the executions. It will help us avoid the stage passed without the actual test execution.
|
|
28
100
|
|
|
29
101
|
|
|
30
|
-
## Version History
|
|
31
|
-
|
|
32
102
|
### v3.0.8 - 25-12-2024
|
|
33
103
|
|
|
34
104
|
#### Enhancement
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createBdd , test } from '@zohodesk/testinglibrary';
|
|
2
|
+
import { generateAndCacheTestData } from './DataGeneratorStepsHelper';
|
|
3
|
+
|
|
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);
|
|
12
|
+
});
|
|
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);
|
|
15
|
+
});
|
|
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);
|
|
19
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { test } from '@zohodesk/testinglibrary';
|
|
2
|
+
import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
|
|
3
|
+
|
|
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);
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createBdd } from '@zohodesk/testinglibrary';
|
|
2
|
+
const { BeforeScenario, Given } = createBdd();
|
|
3
|
+
|
|
4
|
+
BeforeScenario(async function({ page, context, browser, cacheLayer, executionContext, actorContext }) {
|
|
5
|
+
// This will run before each scenario and set all the fixtures into this context
|
|
6
|
+
this.page = page;
|
|
7
|
+
this.context = context;
|
|
8
|
+
this.browser = browser;
|
|
9
|
+
this.cacheLayer = cacheLayer;
|
|
10
|
+
this.executionContext = executionContext;
|
|
11
|
+
this.setActor = async (role) => {
|
|
12
|
+
const userPage = actorContext.actorsObj[role];
|
|
13
|
+
if (userPage) {
|
|
14
|
+
this.page = userPage.page;
|
|
15
|
+
this.context = userPage.context;
|
|
16
|
+
this.browser = userPage.browser;
|
|
17
|
+
this.executionContext = userPage.executionContext;
|
|
18
|
+
} else {
|
|
19
|
+
throw new Error(`Actor "${role}" not found in user pages.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
Given("access the {string} profile page", async function({ page }, userRole) {
|
|
25
|
+
await this.setActor(userRole);
|
|
26
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { expect } from '@zohodesk/testinglibrary';
|
|
2
|
+
|
|
3
|
+
async function executeRpcRequest(page, payload) {
|
|
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;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async function entityIdReConstructor(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;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = { executeRpcRequest, entityIdReConstructor };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {createBdd } from '@zohodesk/testinglibrary';
|
|
2
|
+
import { executeRpcRequest , entityIdReConstructor } from '../helpers/rpcRequestHelper';
|
|
3
|
+
|
|
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
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
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 _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
var _logger = require("../../utils/logger");
|
|
11
|
+
var _DataGeneratorHelper = require("./DataGeneratorHelper");
|
|
12
|
+
var _helpers = require("@zohodesk/testinglibrary/helpers");
|
|
13
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
14
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
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"); }
|
|
16
|
+
var _DataGenerator_brand = /*#__PURE__*/new WeakSet();
|
|
17
|
+
class DataGenerator {
|
|
18
|
+
constructor() {
|
|
19
|
+
_classPrivateMethodInitSpec(this, _DataGenerator_brand);
|
|
20
|
+
}
|
|
21
|
+
async generate(testInfo, actorInfo, generatorType, generatorName, scenarioName, dataTable) {
|
|
22
|
+
try {
|
|
23
|
+
let generators;
|
|
24
|
+
if (generatorType === 'API') {
|
|
25
|
+
generators = await _assertClassBrand(_DataGenerator_brand, this, _generateAPIGenerator).call(this, generatorName);
|
|
26
|
+
} else {
|
|
27
|
+
generators = await _assertClassBrand(_DataGenerator_brand, this, _getGenerator).call(this, testInfo, generatorName);
|
|
28
|
+
}
|
|
29
|
+
const processedGenerators = await (0, _DataGeneratorHelper.processGenerator)(generators, dataTable);
|
|
30
|
+
const apiPayload = await _assertClassBrand(_DataGenerator_brand, this, _constructApiPayload).call(this, scenarioName, processedGenerators, actorInfo);
|
|
31
|
+
const response = await (0, _DataGeneratorHelper.makeRequest)(process.env.DG_SERVICE_DOMAIN + process.env.DG_SERVICE_API_PATH, apiPayload);
|
|
32
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Generated response for the generator: ${generatorName} for scenario: ${scenarioName}, Response: ${JSON.stringify(response)}`);
|
|
33
|
+
return response;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Data Generation failed for the generator: ', generatorName, "\n\nError response :", error);
|
|
36
|
+
throw error;
|
|
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
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function _getGenerator(testInfo, generatorName) {
|
|
50
|
+
let generator = null;
|
|
51
|
+
let generatorFilePath = await (0, _DataGeneratorHelper.getGeneratorFilePath)(testInfo.file);
|
|
52
|
+
generatorFilePath = _path.default.join(generatorFilePath, "../../data-generators/generators.json");
|
|
53
|
+
if (_fs.default.existsSync(generatorFilePath)) {
|
|
54
|
+
const data = _fs.default.readFileSync(generatorFilePath, 'utf8');
|
|
55
|
+
const generatorObj = JSON.parse(data);
|
|
56
|
+
if (generatorName || generatorObj.generators) {
|
|
57
|
+
generator = generatorObj.generators[generatorName] || null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!generator) {
|
|
61
|
+
throw new Error(`Generator "${generatorName}" could not be found in the path located at "${generatorFilePath}"`);
|
|
62
|
+
}
|
|
63
|
+
return generator;
|
|
64
|
+
}
|
|
65
|
+
async function _generateAPIGenerator(operationId) {
|
|
66
|
+
return [{
|
|
67
|
+
type: "dynamic",
|
|
68
|
+
generatorOperationId: operationId,
|
|
69
|
+
dataPath: "$.response.body:$",
|
|
70
|
+
name: operationId
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
async function _constructApiPayload(scenarioName, processedGenerators, actorInfo) {
|
|
74
|
+
const dataGeneratorConfig = actorInfo['data-generator'] || {};
|
|
75
|
+
const apiPayload = {
|
|
76
|
+
scenario_name: scenarioName,
|
|
77
|
+
data_generation_templates: processedGenerators,
|
|
78
|
+
...dataGeneratorConfig
|
|
79
|
+
};
|
|
80
|
+
const account = apiPayload.account;
|
|
81
|
+
if (account) {
|
|
82
|
+
account.email = actorInfo.email;
|
|
83
|
+
account.password = actorInfo.password;
|
|
84
|
+
}
|
|
85
|
+
const environmentDetails = apiPayload.environmentDetails || {};
|
|
86
|
+
if (environmentDetails) {
|
|
87
|
+
environmentDetails.iam_url = process.env.DG_IAM_DOMAIN;
|
|
88
|
+
const domainUrl = new URL(process.env.domain);
|
|
89
|
+
environmentDetails.host = domainUrl.origin;
|
|
90
|
+
}
|
|
91
|
+
apiPayload.environmentDetails = environmentDetails;
|
|
92
|
+
return apiPayload;
|
|
93
|
+
}
|
|
94
|
+
var _default = exports.default = DataGenerator;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getGeneratorFilePath = getGeneratorFilePath;
|
|
7
|
+
exports.makeRequest = makeRequest;
|
|
8
|
+
exports.processGenerator = processGenerator;
|
|
9
|
+
//Create payload for the generators
|
|
10
|
+
async function processGenerator(generators, dataTable) {
|
|
11
|
+
if (!dataTable) {
|
|
12
|
+
return generators;
|
|
13
|
+
}
|
|
14
|
+
return generators.map(generator => {
|
|
15
|
+
dataTable.forEach(row => {
|
|
16
|
+
const generatorName = row.DG_API_NAME;
|
|
17
|
+
if (generatorName === generator.name) {
|
|
18
|
+
generator.params = generator.params ? generator.params : [];
|
|
19
|
+
|
|
20
|
+
// The API name row is only used for matching the template
|
|
21
|
+
// Filter out DG_API_NAME and collect other values
|
|
22
|
+
Object.entries(row).filter(([key]) => key !== 'DG_API_NAME').forEach(([key, value]) => {
|
|
23
|
+
if (value !== '') {
|
|
24
|
+
generator.params[key] = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return generator;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function makeRequest(url, payload) {
|
|
33
|
+
const response = await fetch(url, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json'
|
|
37
|
+
},
|
|
38
|
+
body: JSON.stringify(payload)
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
const errorBody = await response.text();
|
|
42
|
+
throw new Error(`HTTP error! status: ${response.status}, body: ${errorBody}`);
|
|
43
|
+
}
|
|
44
|
+
return response.json();
|
|
45
|
+
}
|
|
46
|
+
async function getGeneratorFilePath(featureFile) {
|
|
47
|
+
let generatorPath = featureFile.replace(".features-gen/", "");
|
|
48
|
+
return generatorPath;
|
|
49
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _logger = require("../../../utils/logger");
|
|
8
|
+
var _additionalProfiles = require("../helpers/additionalProfiles");
|
|
9
|
+
var _loginDefaultStepsHelper = require("../helpers/auth/loginDefaultStepsHelper");
|
|
10
|
+
class ActorContext {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.actorsObj = {};
|
|
13
|
+
}
|
|
14
|
+
async setup(browser, $tags, testInfo, context, page, executionContext) {
|
|
15
|
+
try {
|
|
16
|
+
const {
|
|
17
|
+
profile
|
|
18
|
+
} = executionContext.actorInfo;
|
|
19
|
+
this.actorsObj[profile] = {
|
|
20
|
+
role: profile,
|
|
21
|
+
browser,
|
|
22
|
+
context,
|
|
23
|
+
page,
|
|
24
|
+
executionContext
|
|
25
|
+
};
|
|
26
|
+
const additionalActors = (0, _additionalProfiles.additionProfiles)($tags);
|
|
27
|
+
await Promise.all(Object.entries(additionalActors).map(async ([role, actorInfo]) => {
|
|
28
|
+
let context = await browser.newContext();
|
|
29
|
+
let page = await context.newPage();
|
|
30
|
+
let ctxTestDetails = {
|
|
31
|
+
page,
|
|
32
|
+
$tags,
|
|
33
|
+
context,
|
|
34
|
+
...actorInfo
|
|
35
|
+
};
|
|
36
|
+
await (0, _loginDefaultStepsHelper.executeDefaultLoginSteps)(context, testInfo, ctxTestDetails, actorInfo);
|
|
37
|
+
this.actorsObj[role] = {
|
|
38
|
+
role,
|
|
39
|
+
browser,
|
|
40
|
+
context,
|
|
41
|
+
page,
|
|
42
|
+
executionContext: {
|
|
43
|
+
actorInfo
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to setup additional actors:`, error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async cleanup() {
|
|
53
|
+
for (const actor of Object.values(this.actorsObj)) {
|
|
54
|
+
try {
|
|
55
|
+
await actor.context.close();
|
|
56
|
+
} catch (error) {
|
|
57
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to close context for actor ${actor.role}:`, error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
var _default = exports.default = {
|
|
63
|
+
actorContext: async ({
|
|
64
|
+
page,
|
|
65
|
+
context,
|
|
66
|
+
executionContext,
|
|
67
|
+
$tags,
|
|
68
|
+
browser
|
|
69
|
+
}, use, testInfo) => {
|
|
70
|
+
const ctxObject = new ActorContext();
|
|
71
|
+
await ctxObject.setup(browser, $tags, testInfo, context, page, executionContext);
|
|
72
|
+
await use(ctxObject);
|
|
73
|
+
await ctxObject.cleanup();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _customFixturesHelper = require("../helpers/customFixturesHelper");
|
|
8
8
|
var _default = exports.default = {
|
|
9
9
|
executionContext: async ({
|
|
10
10
|
$tags
|
|
11
11
|
}, use) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const actorInfo = (0, _customFixturesHelper.getCustomAccountDetails)($tags);
|
|
13
|
+
await use({
|
|
14
|
+
actorInfo
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
17
|
};
|
|
@@ -12,12 +12,14 @@ var _addTags = _interopRequireDefault(require("./addTags"));
|
|
|
12
12
|
var _i18N = _interopRequireDefault(require("./i18N"));
|
|
13
13
|
var _unauthenticatedPage = _interopRequireDefault(require("./unauthenticatedPage"));
|
|
14
14
|
var _executionContext = _interopRequireDefault(require("./executionContext"));
|
|
15
|
+
var _actorContext = _interopRequireDefault(require("./actorContext"));
|
|
15
16
|
function extractTagsFromTitle(text) {
|
|
16
17
|
return text.match(/@\w+/g) || [];
|
|
17
18
|
}
|
|
18
19
|
function getBuiltInFixtures(bddMode) {
|
|
19
20
|
let builtInFixtures = {
|
|
20
21
|
..._page.default,
|
|
22
|
+
..._actorContext.default,
|
|
21
23
|
..._context.default,
|
|
22
24
|
..._cacheLayer.default,
|
|
23
25
|
..._i18N.default,
|
|
@@ -4,58 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _auth = require("../helpers/auth");
|
|
9
|
-
var _readConfigFile = require("../readConfigFile");
|
|
7
|
+
var _loginDefaultStepsHelper = require("../helpers/auth/loginDefaultStepsHelper");
|
|
10
8
|
/* eslint-disable global-require */
|
|
11
|
-
|
|
12
|
-
//import { additionProfiles } from '../helpers/additionalProfiles';
|
|
13
|
-
|
|
14
|
-
function getTagInputFromSelectedTags(tags, inputString) {
|
|
15
|
-
const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
|
|
16
|
-
let tagInput = null;
|
|
17
|
-
if (selectedTag) {
|
|
18
|
-
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
19
|
-
}
|
|
20
|
-
return tagInput;
|
|
21
|
-
}
|
|
22
|
-
function getCustomAccountDetails(tags) {
|
|
23
|
-
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal', '@additional_profile'];
|
|
24
|
-
const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
|
|
25
|
-
if (filteredTags && filteredTags.length > 0) {
|
|
26
|
-
const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
|
|
27
|
-
const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
|
|
28
|
-
const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
|
|
29
|
-
const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
|
|
30
|
-
const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
|
|
31
|
-
return user;
|
|
32
|
-
}
|
|
33
|
-
return (0, _auth.getDefaultActor)();
|
|
34
|
-
}
|
|
35
|
-
const {
|
|
36
|
-
testSetup
|
|
37
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
38
|
-
async function loginSteps(pageDetail) {
|
|
39
|
-
const {
|
|
40
|
-
page
|
|
41
|
-
} = pageDetail;
|
|
42
|
-
if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
|
|
43
|
-
return await testSetup.loginSteps(pageDetail);
|
|
44
|
-
} else {
|
|
45
|
-
await page.goto(process.env.domain);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async function performDefaultPageSteps(testInfo) {
|
|
49
|
-
if (testSetup.page && typeof testSetup.page === 'function') {
|
|
50
|
-
await testSetup.page(testInfo);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async function verifyPageIsLoaded(testInfo) {
|
|
54
|
-
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
55
|
-
return await testSetup.validateLogin(testInfo);
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
9
|
var _default = exports.default = {
|
|
60
10
|
page: async ({
|
|
61
11
|
context,
|
|
@@ -76,24 +26,11 @@ var _default = exports.default = {
|
|
|
76
26
|
await context.clearCookies();
|
|
77
27
|
return;
|
|
78
28
|
}
|
|
79
|
-
|
|
80
|
-
isAuthMode
|
|
81
|
-
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
82
|
-
if (!isAuthMode) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const projectName = testInfo.project.name;
|
|
86
|
-
if (testPortalDetails && projectName !== 'setup' && projectName !== 'cleanup') {
|
|
87
|
-
await context.clearCookies();
|
|
88
|
-
await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
|
|
89
|
-
return await verifyPageIsLoaded(testInfo);
|
|
90
|
-
}, loginSteps);
|
|
91
|
-
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
92
|
-
}
|
|
29
|
+
await (0, _loginDefaultStepsHelper.executeDefaultLoginSteps)(context, testInfo, testDetails, testPortalDetails);
|
|
93
30
|
} catch (e) {
|
|
94
31
|
console.error('Error during page', e);
|
|
95
32
|
} finally {
|
|
96
|
-
await performDefaultPageSteps(testDetails);
|
|
33
|
+
await (0, _loginDefaultStepsHelper.performDefaultPageSteps)(testDetails);
|
|
97
34
|
await use(page);
|
|
98
35
|
await context.close();
|
|
99
36
|
}
|
|
@@ -5,13 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.additionProfiles = additionProfiles;
|
|
7
7
|
var _getUsers = require("./auth/getUsers");
|
|
8
|
-
|
|
8
|
+
var _customFixturesHelper = require("./customFixturesHelper");
|
|
9
|
+
function additionProfiles(tags) {
|
|
10
|
+
const {
|
|
11
|
+
editionInfo,
|
|
12
|
+
betaFeature,
|
|
13
|
+
portalInfo
|
|
14
|
+
} = (0, _customFixturesHelper.extractTagInfo)(tags);
|
|
9
15
|
const additionalProfileTags = tags.filter(tag => tag.startsWith('@additional_profile_'));
|
|
10
|
-
let additionalProfileActors =
|
|
11
|
-
if (additionalProfileTags.length > 0
|
|
12
|
-
|
|
16
|
+
let additionalProfileActors = {};
|
|
17
|
+
if (additionalProfileTags.length > 0) {
|
|
18
|
+
additionalProfileTags.forEach(tag => {
|
|
13
19
|
const additionalProfile = tag.replace('@additional_profile_', '');
|
|
14
|
-
|
|
20
|
+
const actorDetails = (0, _getUsers.getUserForSelectedEditionAndProfile)(editionInfo, additionalProfile, betaFeature, portalInfo);
|
|
21
|
+
additionalProfileActors[additionalProfile] = actorDetails;
|
|
15
22
|
});
|
|
16
23
|
}
|
|
17
24
|
return additionalProfileActors;
|