@zohodesk/testinglibrary 0.4.81-n18-experimental → 0.4.83-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/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
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _testinglibrary = require("@zohodesk/testinglibrary");
4
+ const {
5
+ BeforeScenario,
6
+ Given
7
+ } = (0, _testinglibrary.createBdd)();
8
+ BeforeScenario(async function ({
9
+ actorCtx,
10
+ page,
11
+ context,
12
+ browser,
13
+ executionContext
14
+ }) {
15
+ // This will run before each scenario and set all the fixtures into this context
16
+ this.page = page;
17
+ this.context = context;
18
+ this.browser = browser;
19
+ this.executionContext = executionContext;
20
+ this.setActor = async role => {
21
+ const userPage = actorCtx.userPages.find(up => up.role === role);
22
+ if (userPage) {
23
+ this.page = userPage.page;
24
+ this.context = userPage.context;
25
+ this.browser = userPage.browser;
26
+ this.executionContext = userPage.actorInfo;
27
+ } else {
28
+ throw new Error(`Actor ${role} not found`);
29
+ }
30
+ };
31
+ });
32
+ Given("switch to {string} profile user page", async function ({
33
+ page
34
+ }, userRole) {
35
+ await this.setActor(userRole);
36
+ });
@@ -0,0 +1,88 @@
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
+ class actorContext {
10
+ constructor() {
11
+ this.page = null;
12
+ this.browser = null;
13
+ this.context = null;
14
+ this.actorInfo = null;
15
+ this.userPages = [];
16
+ this.actorsList = {};
17
+ }
18
+ async setupAllActors(browser, $tags, testInfo, defaultPage, defaultContext) {
19
+ const actorInfoMap = (0, _customFixturesHelper.getCustomAccountDetails)($tags);
20
+ await Promise.all(Object.entries(actorInfoMap).map(async ([role, actorInfo], index) => {
21
+ let context, page;
22
+ if (index === 0) {
23
+ context = defaultContext;
24
+ page = defaultPage;
25
+ } else {
26
+ context = await browser.newContext();
27
+ page = await context.newPage();
28
+ }
29
+ let ctxTestDetails = {
30
+ page,
31
+ $tags,
32
+ context,
33
+ ...actorInfo
34
+ };
35
+ await (0, _customFixturesHelper.executeDefaultLoginSteps)(context, testInfo, ctxTestDetails, actorInfo);
36
+ this.actorsList[role] = {
37
+ role,
38
+ browser,
39
+ context,
40
+ page,
41
+ actorInfo,
42
+ isPrimary: index === 0
43
+ };
44
+ await this.addUserPage(role, browser, page, context, actorInfo);
45
+ }));
46
+ for (const actorObj of Object.values(this.actorsList)) {
47
+ await (0, _customFixturesHelper.performDefaultPageSteps)({
48
+ context: actorObj.context,
49
+ page: actorObj.page,
50
+ $tags,
51
+ ...actorObj.actorInfo
52
+ });
53
+ }
54
+ }
55
+ async addUserPage(role, browser, page, context, actorInfo) {
56
+ this.userPages.push({
57
+ role,
58
+ browser,
59
+ page,
60
+ context,
61
+ actorInfo
62
+ });
63
+ }
64
+ async cleanup() {
65
+ for (const actor of Object.values(this.actorsList)) {
66
+ if (!actor.isPrimary && actor.context) {
67
+ try {
68
+ await actor.context.close();
69
+ } catch (error) {
70
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Failed to close context for actor ${actor.role}:`, error);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ var _default = exports.default = {
77
+ actorCtx: async ({
78
+ $tags,
79
+ browser,
80
+ context,
81
+ page
82
+ }, use, testInfo) => {
83
+ const ctxObject = new actorContext();
84
+ await ctxObject.setupAllActors(browser, $tags, testInfo, page, context);
85
+ await use(ctxObject);
86
+ await ctxObject.cleanup();
87
+ }
88
+ };
@@ -4,14 +4,14 @@ 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 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 _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 _customFixturesHelper = require("../helpers/customFixturesHelper");
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.actorInfo[Object.keys(executionContext.actorInfo)[0]];
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, _customFixturesHelper.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, _customFixturesHelper.performDefaultPageSteps)(testDetails);
97
34
  await use(page);
98
35
  await context.close();
99
36
  }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.executeDefaultLoginSteps = executeDefaultLoginSteps;
7
+ exports.getCustomAccountDetails = getCustomAccountDetails;
8
+ exports.loginSteps = loginSteps;
9
+ exports.performDefaultPageSteps = performDefaultPageSteps;
10
+ exports.verifyPageIsLoaded = verifyPageIsLoaded;
11
+ var _auth = require("../helpers/auth");
12
+ var _additionalProfiles = require("../helpers/additionalProfiles");
13
+ var _readConfigFile = require("../readConfigFile");
14
+ var _logger = require("../../../utils/logger");
15
+ /* eslint-disable global-require */
16
+
17
+ let {
18
+ testSetup,
19
+ isAuthMode
20
+ } = (0, _readConfigFile.generateConfigFromFile)();
21
+ function getTagInputFromSelectedTags(tags, inputString) {
22
+ const selectedTag = [...tags].reverse().find(tag => tag.startsWith(inputString));
23
+ let tagInput = null;
24
+ if (selectedTag) {
25
+ tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
26
+ }
27
+ return tagInput;
28
+ }
29
+ function getCustomAccountDetails(tags) {
30
+ const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal', '@additional_profile'];
31
+ const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
32
+ if (filteredTags && filteredTags.length > 0) {
33
+ const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
34
+ const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
35
+ const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
36
+ const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
37
+ const defaultActor = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
38
+ const actors = {
39
+ [defaultActor.profile]: defaultActor
40
+ };
41
+ const additionalProfileActors = (0, _additionalProfiles.additionProfiles)(tags, editionInfo, betaFeature, portalInfo);
42
+ const additionalProfileTags = tags.filter(tag => tag.startsWith('@additional_profile_'));
43
+ additionalProfileTags.forEach((tag, index) => {
44
+ const profileName = tag.replace('@additional_profile_', '');
45
+ actors[`${profileName}`] = additionalProfileActors[index];
46
+ });
47
+ return actors;
48
+ }
49
+ const actiorInfoDetail = (0, _auth.getDefaultActor)();
50
+ return {
51
+ [actiorInfoDetail.profile]: actiorInfoDetail
52
+ };
53
+ }
54
+ async function loginSteps(pageDetail) {
55
+ const {
56
+ page
57
+ } = pageDetail;
58
+ if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
59
+ return await testSetup.loginSteps(pageDetail);
60
+ } else {
61
+ await page.goto(process.env.domain);
62
+ }
63
+ }
64
+ async function performDefaultPageSteps(testInfo) {
65
+ if (testSetup.page && typeof testSetup.page === 'function') {
66
+ await testSetup.page(testInfo);
67
+ }
68
+ }
69
+ async function verifyPageIsLoaded(testInfo) {
70
+ if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
71
+ return await testSetup.validateLogin(testInfo);
72
+ }
73
+ return true;
74
+ }
75
+ async function executeDefaultLoginSteps(context, testInfo, testDetails, testPortalDetails) {
76
+ if (!isAuthMode) {
77
+ return;
78
+ }
79
+ try {
80
+ const projectName = testInfo.project.name;
81
+ if (testPortalDetails && projectName !== 'setup' && projectName !== 'cleanup') {
82
+ await context.clearCookies();
83
+ await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
84
+ return await verifyPageIsLoaded(testInfo);
85
+ }, loginSteps);
86
+ process.env.actorInfo = JSON.stringify(testPortalDetails);
87
+ }
88
+ } catch (error) {
89
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error while executing the default login steps:', error);
90
+ }
91
+ }
@@ -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,9 +1,9 @@
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'];
@@ -14,12 +14,12 @@ describe('executionContext', () => {
14
14
  profile: 'admin',
15
15
  email: 'xxx.x+uat@zohotest.com'
16
16
  };
17
- _page.getCustomAccountDetails.mockReturnValue(mockActorInfo);
17
+ _customFixturesHelper.getCustomAccountDetails.mockReturnValue(mockActorInfo);
18
18
  const use = jest.fn();
19
19
  await _executionContext.default.executionContext({
20
20
  $tags: mockTags
21
21
  }, use);
22
- expect(_page.getCustomAccountDetails).toHaveBeenCalledWith(mockTags);
22
+ expect(_customFixturesHelper.getCustomAccountDetails).toHaveBeenCalledWith(mockTags);
23
23
  expect(use).toHaveBeenCalledWith({
24
24
  actorInfo: mockActorInfo
25
25
  });