@zohodesk/testinglibrary 0.4.87-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/.gitlab-ci.yml CHANGED
@@ -160,19 +160,4 @@ uat-smoketest:
160
160
  paths:
161
161
  - examples/uat/playwright-report
162
162
 
163
- uat-data_generator:
164
- stage: uat
165
- script:
166
- - cd examples
167
- - npm install $(npm pack ../../testing-framework | tail -1)
168
- - output=$(npm run uat-data_generator)
169
- - echo "$output"
170
- - node ../ValidateUATReport.js examples
171
-
172
- artifacts:
173
- when: always
174
- paths:
175
- - examples/uat/playwright-report
176
-
177
-
178
-
163
+
package/README.md CHANGED
@@ -12,12 +12,68 @@
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.6 - 02-09-2025
23
+
24
+ #### Feature
25
+
26
+ - Multi-actor execution support – now possible to switch between multiple profile agents within scenarios using the new `actorCtx` custom fixture.
27
+
28
+ ### v3.2.5 - 28-08-2025
29
+
30
+ #### Enhancement
31
+
32
+ - Removed the searchFake dependency from the project level and adopted it inside the framework, reducing project-side maintenance.
33
+
34
+ ### v3.2.4 - 29-07-2025
35
+
36
+ #### Feature
37
+ - Data Generator steps are now supported directly via the framework.
38
+
39
+ ### Bug fix
40
+ - Feature File Root Directory not found issue fixed
41
+
42
+ ### v3.2.3 - 29-07-2025
43
+
44
+ #### Feature
45
+ - Added support for running Smoke Tests in the UAT stage.
46
+
47
+ ### v3.2.0 - 22-06-2025
48
+
49
+ #### Feature
50
+ - Default required spec files are now auto-imported from the library into the project.
51
+
52
+ ### v3.1.13 - 02-07-2025
53
+
54
+ #### Enhancement
55
+ - Below package versions are updated in this release.
56
+ - @cucumber/Cucumber - 11.3.0
57
+ - Playwright/test - 1.53.2
58
+ - Playwright - 1.53.2
59
+ - Playwright-bdd - 8.3.1
60
+ - QC custom reporter changes have been adopted into the framework.
61
+
62
+ ### v3.1.5 - 22-05-2025
63
+
64
+ #### Feature
65
+ - Added support for Module Based Execution UAT stage.
66
+
67
+ ### v3.1.4 - 12-05-2025
68
+
69
+ #### Enhancement
70
+ - Playwright version 1.52.0 adopted in testing framework
71
+
72
+ ### v3.1.3 - 25-04-2025
73
+
74
+ #### Enhancement
75
+ - Playwright version 1.51.0 adopted in testing framework
76
+
21
77
  ### v0.2.8 - 26-09-2024
22
78
 
23
79
  #### Feature
@@ -27,8 +83,6 @@
27
83
  - 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
84
 
29
85
 
30
- ## Version History
31
-
32
86
  ### v3.0.8 - 25-12-2024
33
87
 
34
88
  #### Enhancement
@@ -1,6 +1,3 @@
1
- // const { createBdd } = require("@zohodesk/testinglibrary");
2
- // const { generateAndCacheTestData } = require("./DataGeneratorStepsHelper");
3
-
4
1
  import { createBdd , test } from '@zohodesk/testinglibrary';
5
2
  import { generateAndCacheTestData } from './DataGeneratorStepsHelper';
6
3
 
@@ -1,10 +1,6 @@
1
- // import { test } from '@zohodesk/testinglibrary';
2
- // const DataGenerator = require("@zohodesk/testinglibrary/DataGenerator").default;
3
-
4
1
  import { test } from '@zohodesk/testinglibrary';
5
2
  import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
6
3
 
7
-
8
4
  const dataGenerator = new DataGenerator();
9
5
 
10
6
  export async function generateAndCacheTestData(executionContext, type, identifier, dataTable, cacheLayer, entityName, profile = null) {
@@ -0,0 +1,21 @@
1
+ import { createBdd } from '@zohodesk/testinglibrary';
2
+ const { BeforeScenario, Given } = createBdd();
3
+
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
+ }
16
+ }
17
+ });
18
+
19
+ Given("access the {string} profile page", async function({ page }, userRole) {
20
+ await this.setActor(userRole);
21
+ });
@@ -71,9 +71,7 @@ async function _generateAPIGenerator(operationId) {
71
71
  }];
72
72
  }
73
73
  async function _constructApiPayload(scenarioName, processedGenerators, actorInfo) {
74
- const orgOauth = actorInfo['org_oauth'] || {};
75
74
  const dataGeneratorConfig = actorInfo['data-generator'] || {};
76
- dataGeneratorConfig.account.org_oauth = orgOauth;
77
75
  const apiPayload = {
78
76
  scenario_name: scenarioName,
79
77
  data_generation_templates: processedGenerators,
@@ -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
+ actorCtx: 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 _actorCtx = _interopRequireDefault(require("./actorCtx"));
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
+ ..._actorCtx.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
+ }
@@ -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
  });