@zohodesk/testinglibrary 3.2.5 → 3.2.7

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
  }
package/README.md CHANGED
@@ -12,12 +12,76 @@
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.7 - 10-09-2025
23
+
24
+ ### Bug fix
25
+ - Fixed a bug where the default profile page was not being handled properly in `this`.
26
+
27
+ ### v3.2.6 - 05-09-2025
28
+
29
+ #### Feature
30
+
31
+ - Multi-actor execution support – now possible to switch between multiple profile agents within scenarios using the predefined step: - `access the {string} profile page`
32
+
33
+ ### Bug fix
34
+ - Fixed the issue where localapp and hcapp UAT were not running properly.
35
+
36
+ ### v3.2.5 - 28-08-2025
37
+
38
+ #### Enhancement
39
+
40
+ - 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)`
41
+
42
+ ### v3.2.4 - 29-07-2025
43
+
44
+ #### Feature
45
+ - Data Generator steps are now supported directly via the framework.
46
+
47
+ ### Bug fix
48
+ - Feature File Root Directory not found issue fixed
49
+
50
+ ### v3.2.3 - 29-07-2025
51
+
52
+ #### Feature
53
+ - Added support for running Smoke Tests in the UAT stage.
54
+
55
+ ### v3.2.0 - 22-06-2025
56
+
57
+ #### Feature
58
+ - Default required spec files are now auto-imported from the library into the project.
59
+
60
+ ### v3.1.13 - 02-07-2025
61
+
62
+ #### Enhancement
63
+ - Below package versions are updated in this release.
64
+ - @cucumber/Cucumber - 11.3.0
65
+ - Playwright/test - 1.53.2
66
+ - Playwright - 1.53.2
67
+ - Playwright-bdd - 8.3.1
68
+ - QC custom reporter changes have been adopted into the framework.
69
+
70
+ ### v3.1.5 - 22-05-2025
71
+
72
+ #### Feature
73
+ - Added support for Module Based Execution UAT stage.
74
+
75
+ ### v3.1.4 - 12-05-2025
76
+
77
+ #### Enhancement
78
+ - Playwright version 1.52.0 adopted in testing framework
79
+
80
+ ### v3.1.3 - 25-04-2025
81
+
82
+ #### Enhancement
83
+ - Playwright version 1.51.0 adopted in testing framework
84
+
21
85
  ### v0.2.8 - 26-09-2024
22
86
 
23
87
  #### Feature
@@ -27,8 +91,6 @@
27
91
  - 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
92
 
29
93
 
30
- ## Version History
31
-
32
94
  ### v3.0.8 - 25-12-2024
33
95
 
34
96
  #### Enhancement
@@ -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
  }
@@ -0,0 +1,25 @@
1
+ import { createBdd } from '@zohodesk/testinglibrary';
2
+ const { BeforeScenario, Given } = createBdd();
3
+
4
+ BeforeScenario(async function({ page, context, browser, 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.executionContext = executionContext;
10
+ this.setActor = async (role) => {
11
+ const userPage = actorContext.actorsObj[role];
12
+ if (userPage) {
13
+ this.page = userPage.page;
14
+ this.context = userPage.context;
15
+ this.browser = userPage.browser;
16
+ this.executionContext = userPage.actorInfo;
17
+ } else {
18
+ throw new Error(`Actor "${role}" not found in user pages.`);
19
+ }
20
+ }
21
+ });
22
+
23
+ Given("access the {string} profile page", async function({ page }, userRole) {
24
+ await this.setActor(userRole);
25
+ });
@@ -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
+ });
@@ -0,0 +1,61 @@
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 _customFixturesHelper = require("../helpers/customFixturesHelper");
9
+ var _loginDefaultStepsHelper = require("../helpers/auth/loginDefaultStepsHelper");
10
+ class additionalActorContext {
11
+ constructor() {
12
+ this.actorsObj = {};
13
+ }
14
+ async setupAdditionalActors(browser, $tags, testInfo) {
15
+ try {
16
+ const actorInfoMap = (0, _customFixturesHelper.getCustomAccountDetails)($tags);
17
+ const additionalActors = actorInfoMap.additional;
18
+ await Promise.all(Object.entries(additionalActors).map(async ([role, actorInfo]) => {
19
+ let context = await browser.newContext();
20
+ let page = await context.newPage();
21
+ let ctxTestDetails = {
22
+ page,
23
+ $tags,
24
+ context,
25
+ ...actorInfo
26
+ };
27
+ await (0, _loginDefaultStepsHelper.executeDefaultLoginSteps)(context, testInfo, ctxTestDetails, actorInfo);
28
+ this.actorsObj[role] = {
29
+ role,
30
+ browser,
31
+ context,
32
+ page,
33
+ actorInfo
34
+ };
35
+ }));
36
+ } catch (error) {
37
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to setup additional actors:`, error);
38
+ throw error;
39
+ }
40
+ }
41
+ async cleanup() {
42
+ for (const actor of Object.values(this.actorsObj)) {
43
+ try {
44
+ await actor.context.close();
45
+ } catch (error) {
46
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to close context for actor ${actor.role}:`, error);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ var _default = exports.default = {
52
+ actorContext: async ({
53
+ $tags,
54
+ browser
55
+ }, use, testInfo) => {
56
+ const ctxObject = new additionalActorContext();
57
+ await ctxObject.setupAdditionalActors(browser, $tags, testInfo);
58
+ await use(ctxObject);
59
+ await ctxObject.cleanup();
60
+ }
61
+ };
@@ -4,14 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _page = require("./page");
7
+ var _customFixturesHelper = require("../helpers/customFixturesHelper");
8
8
  var _default = exports.default = {
9
9
  executionContext: async ({
10
10
  $tags
11
11
  }, use) => {
12
- let testPortalActorDetails = {
13
- actorInfo: (0, _page.getCustomAccountDetails)($tags)
14
- };
15
- await use(testPortalActorDetails);
12
+ const allActorsObj = (0, _customFixturesHelper.getCustomAccountDetails)($tags);
13
+ const currentActor = allActorsObj.main;
14
+ await use(currentActor);
16
15
  }
17
16
  };
@@ -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
- exports.getCustomAccountDetails = getCustomAccountDetails;
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,
@@ -63,7 +13,7 @@ var _default = exports.default = {
63
13
  page,
64
14
  executionContext
65
15
  }, use, testInfo) => {
66
- let testPortalDetails = executionContext.actorInfo;
16
+ let testPortalDetails = executionContext;
67
17
  let testDetails = {
68
18
  page,
69
19
  $tags,
@@ -76,24 +26,11 @@ var _default = exports.default = {
76
26
  await context.clearCookies();
77
27
  return;
78
28
  }
79
- const {
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
  }
@@ -7,11 +7,12 @@ exports.additionProfiles = additionProfiles;
7
7
  var _getUsers = require("./auth/getUsers");
8
8
  function additionProfiles(tags, editionInfo, betaFeature, portalInfo) {
9
9
  const additionalProfileTags = tags.filter(tag => tag.startsWith('@additional_profile_'));
10
- let additionalProfileActors = [];
10
+ let additionalProfileActors = {};
11
11
  if (additionalProfileTags.length > 0 && editionInfo) {
12
- additionalProfileActors = additionalProfileTags.map(tag => {
12
+ additionalProfileTags.forEach(tag => {
13
13
  const additionalProfile = tag.replace('@additional_profile_', '');
14
- return (0, _getUsers.getUserForSelectedEditionAndProfile)(editionInfo, additionalProfile, betaFeature, portalInfo);
14
+ const actorDetails = (0, _getUsers.getUserForSelectedEditionAndProfile)(editionInfo, additionalProfile, betaFeature, portalInfo);
15
+ additionalProfileActors[additionalProfile] = actorDetails;
15
16
  });
16
17
  }
17
18
  return additionalProfileActors;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.executeDefaultLoginSteps = executeDefaultLoginSteps;
7
+ exports.loginSteps = loginSteps;
8
+ exports.performDefaultPageSteps = performDefaultPageSteps;
9
+ exports.verifyPageIsLoaded = verifyPageIsLoaded;
10
+ var _auth = require("../auth");
11
+ var _readConfigFile = require("../../readConfigFile");
12
+ let {
13
+ testSetup,
14
+ isAuthMode
15
+ } = (0, _readConfigFile.generateConfigFromFile)();
16
+ async function loginSteps(pageDetail) {
17
+ const {
18
+ page
19
+ } = pageDetail;
20
+ if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
21
+ return await testSetup.loginSteps(pageDetail);
22
+ } else {
23
+ await page.goto(process.env.domain);
24
+ }
25
+ }
26
+ async function performDefaultPageSteps(testInfo) {
27
+ if (testSetup.page && typeof testSetup.page === 'function') {
28
+ await testSetup.page(testInfo);
29
+ }
30
+ }
31
+ async function verifyPageIsLoaded(testInfo) {
32
+ if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
33
+ return await testSetup.validateLogin(testInfo);
34
+ }
35
+ return true;
36
+ }
37
+ async function executeDefaultLoginSteps(context, testInfo, testDetails, testPortalDetails) {
38
+ if (!isAuthMode) {
39
+ return;
40
+ }
41
+ try {
42
+ const projectName = testInfo.project.name;
43
+ if (testPortalDetails && projectName !== 'setup' && projectName !== 'cleanup') {
44
+ await context.clearCookies();
45
+ await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
46
+ return await verifyPageIsLoaded(testInfo);
47
+ }, loginSteps);
48
+ process.env.actorInfo = JSON.stringify(testPortalDetails);
49
+ }
50
+ } catch (error) {
51
+ Logger.log(Logger.FAILURE_TYPE, 'Error while executing the default login steps:', error);
52
+ }
53
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCustomAccountDetails = getCustomAccountDetails;
7
+ var _auth = require("../helpers/auth");
8
+ var _additionalProfiles = require("../helpers/additionalProfiles");
9
+ var _logger = require("../../../utils/logger");
10
+ /* eslint-disable global-require */
11
+
12
+ function getTagInputFromSelectedTags(tags, inputString) {
13
+ const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
14
+ let tagInput = null;
15
+ if (selectedTag) {
16
+ tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
17
+ }
18
+ return tagInput;
19
+ }
20
+ function getCustomAccountDetails(tags) {
21
+ try {
22
+ const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal', '@additional_profile'];
23
+ const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
24
+ if (filteredTags && filteredTags.length > 0) {
25
+ const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
26
+ const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
27
+ const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
28
+ const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
29
+ const mainActor = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
30
+ const additionalActors = (0, _additionalProfiles.additionProfiles)(tags, editionInfo, betaFeature, portalInfo);
31
+ return {
32
+ main: mainActor,
33
+ additional: additionalActors
34
+ };
35
+ }
36
+ return {
37
+ main: (0, _auth.getDefaultActor)(),
38
+ additional: {}
39
+ };
40
+ } catch (err) {
41
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error while getting custom account details:', err);
42
+ }
43
+ }
@@ -2,6 +2,6 @@
2
2
  "environment": "dev",
3
3
  "edition": "enterprise",
4
4
  "profile": "admin",
5
- "domain": "https://zdesk-devops16.csez.zohocorpin.com:31025/agent",
5
+ "domain": "https://zdesk-devops25.csez.zohocorpin.com:31037/agent",
6
6
  "devUrl" : ""
7
7
  }
@@ -1,27 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _page = require("../../../../../core/playwright/builtInFixtures/page");
4
+ var _customFixturesHelper = require("../../../../../core/playwright/helpers/customFixturesHelper");
5
5
  var _executionContext = _interopRequireDefault(require("../../../../../core/playwright/builtInFixtures/executionContext"));
6
- jest.mock('../../../../../core/playwright/builtInFixtures/page');
6
+ jest.mock('../../../../../core/playwright/helpers/customFixturesHelper');
7
7
  describe('executionContext', () => {
8
8
  test('should pass actorInfo with details from getCustomAccountDetails to use', async () => {
9
9
  const mockTags = ['tag1', 'tag2'];
10
- const mockActorInfo = {
10
+ const mockMainActorInfo = {
11
11
  id: '1',
12
12
  edition: 'enterprise',
13
13
  orgName: 'orgName',
14
14
  profile: 'admin',
15
15
  email: 'xxx.x+uat@zohotest.com'
16
16
  };
17
- _page.getCustomAccountDetails.mockReturnValue(mockActorInfo);
17
+ const mockActorInfo = {
18
+ main: mockMainActorInfo,
19
+ additional: {}
20
+ };
21
+ _customFixturesHelper.getCustomAccountDetails.mockReturnValue(mockActorInfo);
18
22
  const use = jest.fn();
19
23
  await _executionContext.default.executionContext({
20
24
  $tags: mockTags
21
25
  }, use);
22
- expect(_page.getCustomAccountDetails).toHaveBeenCalledWith(mockTags);
23
- expect(use).toHaveBeenCalledWith({
24
- actorInfo: mockActorInfo
25
- });
26
+ expect(_customFixturesHelper.getCustomAccountDetails).toHaveBeenCalledWith(mockTags);
27
+ expect(use).toHaveBeenCalledWith(mockMainActorInfo);
26
28
  });
27
29
  });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@zohodesk/testinglibrary",
9
- "version": "3.2.5",
9
+ "version": "3.2.7",
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": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -0,0 +1,260 @@
1
+ <html><head><meta charset="utf-8"/><title>Unit Report</title><style type="text/css">html,
2
+ body {
3
+ font-family: Arial, Helvetica, sans-serif;
4
+ font-size: 1rem;
5
+ margin: 0;
6
+ padding: 0;
7
+ color: #333;
8
+ }
9
+ body {
10
+ padding: 2rem 1rem;
11
+ font-size: 0.85rem;
12
+ }
13
+ .jesthtml-content {
14
+ margin: 0 auto;
15
+ max-width: 70rem;
16
+ }
17
+ header {
18
+ display: flex;
19
+ align-items: center;
20
+ }
21
+ #title {
22
+ margin: 0;
23
+ flex-grow: 1;
24
+ }
25
+ #logo {
26
+ height: 4rem;
27
+ }
28
+ #timestamp {
29
+ color: #777;
30
+ margin-top: 0.5rem;
31
+ }
32
+
33
+ /** SUMMARY */
34
+ #summary {
35
+ color: #333;
36
+ margin: 2rem 0;
37
+ display: flex;
38
+ font-family: monospace;
39
+ font-size: 1rem;
40
+ }
41
+ #summary > div {
42
+ margin-right: 2rem;
43
+ background: #eee;
44
+ padding: 1rem;
45
+ min-width: 15rem;
46
+ }
47
+ #summary > div:last-child {
48
+ margin-right: 0;
49
+ }
50
+ @media only screen and (max-width: 720px) {
51
+ #summary {
52
+ flex-direction: column;
53
+ }
54
+ #summary > div {
55
+ margin-right: 0;
56
+ margin-top: 2rem;
57
+ }
58
+ #summary > div:first-child {
59
+ margin-top: 0;
60
+ }
61
+ }
62
+
63
+ .summary-total {
64
+ font-weight: bold;
65
+ margin-bottom: 0.5rem;
66
+ }
67
+ .summary-passed {
68
+ color: #4f8a10;
69
+ border-left: 0.4rem solid #4f8a10;
70
+ padding-left: 0.5rem;
71
+ }
72
+ .summary-failed,
73
+ .summary-obsolete-snapshots {
74
+ color: #d8000c;
75
+ border-left: 0.4rem solid #d8000c;
76
+ padding-left: 0.5rem;
77
+ }
78
+ .summary-pending {
79
+ color: #9f6000;
80
+ border-left: 0.4rem solid #9f6000;
81
+ padding-left: 0.5rem;
82
+ }
83
+ .summary-empty {
84
+ color: #999;
85
+ border-left: 0.4rem solid #999;
86
+ }
87
+
88
+ .test-result {
89
+ padding: 1rem;
90
+ margin-bottom: 0.25rem;
91
+ }
92
+ .test-result:last-child {
93
+ border: 0;
94
+ }
95
+ .test-result.passed {
96
+ background-color: #dff2bf;
97
+ color: #4f8a10;
98
+ }
99
+ .test-result.failed {
100
+ background-color: #ffbaba;
101
+ color: #d8000c;
102
+ }
103
+ .test-result.pending {
104
+ background-color: #ffdf61;
105
+ color: #9f6000;
106
+ }
107
+
108
+ .test-info {
109
+ display: flex;
110
+ justify-content: space-between;
111
+ }
112
+ .test-suitename {
113
+ width: 20%;
114
+ text-align: left;
115
+ font-weight: bold;
116
+ word-break: break-word;
117
+ }
118
+ .test-title {
119
+ width: 40%;
120
+ text-align: left;
121
+ font-style: italic;
122
+ }
123
+ .test-status {
124
+ width: 20%;
125
+ text-align: right;
126
+ }
127
+ .test-duration {
128
+ width: 10%;
129
+ text-align: right;
130
+ font-size: 0.75rem;
131
+ }
132
+
133
+ .failureMessages {
134
+ padding: 0 1rem;
135
+ margin-top: 1rem;
136
+ border-top: 1px dashed #d8000c;
137
+ }
138
+ .failureMessages.suiteFailure {
139
+ border-top: none;
140
+ }
141
+ .failureMsg {
142
+ white-space: pre-wrap;
143
+ white-space: -moz-pre-wrap;
144
+ white-space: -pre-wrap;
145
+ white-space: -o-pre-wrap;
146
+ word-wrap: break-word;
147
+ }
148
+
149
+ .suite-container {
150
+ margin-bottom: 2rem;
151
+ }
152
+ .suite-container > input[type="checkbox"] {
153
+ position: absolute;
154
+ left: -100vw;
155
+ }
156
+ .suite-container label {
157
+ display: block;
158
+ }
159
+ .suite-container .suite-tests {
160
+ overflow-y: hidden;
161
+ height: 0;
162
+ }
163
+ .suite-container > input[type="checkbox"]:checked ~ .suite-tests {
164
+ height: auto;
165
+ overflow: visible;
166
+ }
167
+ .suite-info {
168
+ padding: 1rem;
169
+ background-color: #eee;
170
+ color: #777;
171
+ display: flex;
172
+ align-items: center;
173
+ margin-bottom: 0.25rem;
174
+ }
175
+ .suite-info:hover {
176
+ background-color: #ddd;
177
+ cursor: pointer;
178
+ }
179
+ .suite-info .suite-path {
180
+ word-break: break-all;
181
+ flex-grow: 1;
182
+ font-family: monospace;
183
+ font-size: 1rem;
184
+ }
185
+ .suite-info .suite-time {
186
+ margin-left: 0.5rem;
187
+ padding: 0.2rem 0.3rem;
188
+ font-size: 0.75rem;
189
+ }
190
+ .suite-info .suite-time.warn {
191
+ background-color: #d8000c;
192
+ color: #fff;
193
+ }
194
+ .suite-info:before {
195
+ content: "\2303";
196
+ display: inline-block;
197
+ margin-right: 0.5rem;
198
+ transform: rotate(0deg);
199
+ }
200
+ .suite-container > input[type="checkbox"]:checked ~ label .suite-info:before {
201
+ transform: rotate(180deg);
202
+ }
203
+
204
+ /* CONSOLE LOGS */
205
+ .suite-consolelog {
206
+ margin-bottom: 0.25rem;
207
+ padding: 1rem;
208
+ background-color: #efefef;
209
+ }
210
+ .suite-consolelog-header {
211
+ font-weight: bold;
212
+ }
213
+ .suite-consolelog-item {
214
+ padding: 0.5rem;
215
+ }
216
+ .suite-consolelog-item pre {
217
+ margin: 0.5rem 0;
218
+ white-space: pre-wrap;
219
+ white-space: -moz-pre-wrap;
220
+ white-space: -pre-wrap;
221
+ white-space: -o-pre-wrap;
222
+ word-wrap: break-word;
223
+ }
224
+ .suite-consolelog-item-origin {
225
+ color: #777;
226
+ font-weight: bold;
227
+ }
228
+ .suite-consolelog-item-message {
229
+ color: #000;
230
+ font-size: 1rem;
231
+ padding: 0 0.5rem;
232
+ }
233
+
234
+ /* OBSOLETE SNAPSHOTS */
235
+ .suite-obsolete-snapshots {
236
+ margin-bottom: 0.25rem;
237
+ padding: 1rem;
238
+ background-color: #ffbaba;
239
+ color: #d8000c;
240
+ }
241
+ .suite-obsolete-snapshots-header {
242
+ font-weight: bold;
243
+ }
244
+ .suite-obsolete-snapshots-item {
245
+ padding: 0.5rem;
246
+ }
247
+ .suite-obsolete-snapshots-item pre {
248
+ margin: 0.5rem 0;
249
+ white-space: pre-wrap;
250
+ white-space: -moz-pre-wrap;
251
+ white-space: -pre-wrap;
252
+ white-space: -o-pre-wrap;
253
+ word-wrap: break-word;
254
+ }
255
+ .suite-obsolete-snapshots-item-message {
256
+ color: #000;
257
+ font-size: 1rem;
258
+ padding: 0 0.5rem;
259
+ }
260
+ </style></head><body><div class="jesthtml-content"><header><h1 id="title">Unit Report</h1></header><div id="metadata-container"><div id="timestamp">Started: 2025-09-03 08:57:31</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed ">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed ">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><input id="collapsible-0" type="checkbox" class="toggle" checked="checked"/><label for="collapsible-0"><div class="suite-info"><div class="suite-path">/Users/muthu-19817/git/testing-framework/src/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js</div><div class="suite-time">0.851s</div></div></label><div class="suite-tests"><div class="test-result passed"><div class="test-info"><div class="test-suitename">executionContext</div><div class="test-title">should pass actorInfo with details from getCustomAccountDetails to use</div><div class="test-status">passed</div><div class="test-duration">0.004s</div></div></div></div></div></div></body></html>