@zohodesk/testinglibrary 0.4.90-n18-experimental → 0.4.92-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,3 +160,32 @@ uat-smoketest:
160
160
  paths:
161
161
  - examples/uat/playwright-report
162
162
 
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
176
+
177
+ uat-data_generator:
178
+ stage: uat
179
+ script:
180
+ - cd examples
181
+ - npm install $(npm pack ../../testing-framework | tail -1)
182
+ - output=$(npm run uat-data_generator)
183
+ - echo "$output"
184
+ - node ../ValidateUATReport.js examples
185
+
186
+ artifacts:
187
+ when: always
188
+ paths:
189
+ - examples/uat/playwright-report
190
+
191
+
package/README.md CHANGED
@@ -19,6 +19,17 @@
19
19
 
20
20
  ## Version History
21
21
 
22
+ #### Feature
23
+ - To store the login session in NFS, we have provided the teardown option in the configuration
24
+
25
+ ### v3.2.8 - 18-09-2025
26
+
27
+ ### Bug fix
28
+
29
+ - Default profile switching handled in Multi actor – Improved handling of default profile switching to ensure smoother execution flow.
30
+
31
+ - QC Report tags issue fixed – Resolved an issue where QC Report tags were not displaying correctly in reports.
32
+
22
33
  ### v3.2.7 - 10-09-2025
23
34
 
24
35
  ### Bug fix
@@ -10,6 +10,7 @@ var _fs = _interopRequireDefault(require("fs"));
10
10
  var _logger = require("../../utils/logger");
11
11
  var _DataGeneratorHelper = require("./DataGeneratorHelper");
12
12
  var _helpers = require("@zohodesk/testinglibrary/helpers");
13
+ var _DataGeneratorError = require("./DataGeneratorError");
13
14
  function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
14
15
  function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
15
16
  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"); }
@@ -32,6 +33,16 @@ class DataGenerator {
32
33
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Generated response for the generator: ${generatorName} for scenario: ${scenarioName}, Response: ${JSON.stringify(response)}`);
33
34
  return response;
34
35
  } catch (error) {
36
+ if (error instanceof _DataGeneratorError.DataGeneratorError) {
37
+ console.error(error.getMessage());
38
+ console.error("Stack trace:", error.stack);
39
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, error.getMessage());
40
+ } else {
41
+ console.error("Error Type:", error.constructor.name);
42
+ console.error("Error Message:", error.message);
43
+ console.error("Stack trace:", error.stack);
44
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `${error.constructor.name} - Message: ${error.message}`);
45
+ }
35
46
  console.error('Data Generation failed for the generator: ', generatorName, "\n\nError response :", error);
36
47
  throw error;
37
48
  }
@@ -58,7 +69,7 @@ async function _getGenerator(testInfo, generatorName) {
58
69
  }
59
70
  }
60
71
  if (!generator) {
61
- throw new Error(`Generator "${generatorName}" could not be found in the path located at "${generatorFilePath}"`);
72
+ throw new _DataGeneratorError.GeneratorError(`Generator "${generatorName}" could not be found in the path located at "${generatorFilePath}"`);
62
73
  }
63
74
  return generator;
64
75
  }
@@ -71,11 +82,14 @@ async function _generateAPIGenerator(operationId) {
71
82
  }];
72
83
  }
73
84
  async function _constructApiPayload(scenarioName, processedGenerators, actorInfo) {
74
- const dataGeneratorConfig = actorInfo['data-generator'] || {};
85
+ const dataGeneratorObj = actorInfo['data-generator'];
86
+ if (!dataGeneratorObj) {
87
+ throw new _DataGeneratorError.DataGeneratorConfigurationError(`Data Generator configuration is missing for the profile: ${actorInfo['profile']}`);
88
+ }
75
89
  const apiPayload = {
76
90
  scenario_name: scenarioName,
77
91
  data_generation_templates: processedGenerators,
78
- ...dataGeneratorConfig
92
+ ...dataGeneratorObj
79
93
  };
80
94
  const account = apiPayload.account;
81
95
  if (account) {
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GeneratorError = exports.DataGeneratorError = exports.DataGeneratorConfigurationError = void 0;
7
+ class DataGeneratorError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'DataGeneratorError';
11
+
12
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
13
+ if (Error.captureStackTrace) {
14
+ Error.captureStackTrace(this, DataGeneratorError);
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Get formatted error message with error type and message
20
+ * @returns {string} Formatted error message
21
+ */
22
+ getMessage() {
23
+ return `\n\n ${this.name} ::: \n\n Error Message: ${this.message} \n\n `;
24
+ }
25
+ }
26
+
27
+ // Specific error for Data Generator configuration issues
28
+ exports.DataGeneratorError = DataGeneratorError;
29
+ class DataGeneratorConfigurationError extends DataGeneratorError {
30
+ constructor(message) {
31
+ super(message);
32
+ this.name = 'DataGeneratorConfigurationError';
33
+ if (Error.captureStackTrace) {
34
+ Error.captureStackTrace(this, DataGeneratorConfigurationError);
35
+ }
36
+ }
37
+ }
38
+
39
+ // Specific error for Generator related issues
40
+ exports.DataGeneratorConfigurationError = DataGeneratorConfigurationError;
41
+ class GeneratorError extends DataGeneratorError {
42
+ constructor(message) {
43
+ super(message);
44
+ this.name = 'GeneratorError';
45
+ if (Error.captureStackTrace) {
46
+ Error.captureStackTrace(this, GeneratorError);
47
+ }
48
+ }
49
+ }
50
+ exports.GeneratorError = GeneratorError;
@@ -15,7 +15,7 @@ async function processGenerator(generators, dataTable) {
15
15
  dataTable.forEach(row => {
16
16
  const generatorName = row.DG_API_NAME;
17
17
  if (generatorName === generator.name) {
18
- generator.params = generator.params ? generator.params : [];
18
+ generator.params = generator.params ? generator.params : {};
19
19
 
20
20
  // The API name row is only used for matching the template
21
21
  // Filter out DG_API_NAME and collect other values
@@ -14,7 +14,7 @@ function additionProfiles(tags) {
14
14
  } = (0, _customFixturesHelper.extractTagInfo)(tags);
15
15
  const additionalProfileTags = tags.filter(tag => tag.startsWith('@additional_profile_'));
16
16
  let additionalProfileActors = {};
17
- if (additionalProfileTags.length > 0 && editionInfo) {
17
+ if (additionalProfileTags.length > 0) {
18
18
  additionalProfileTags.forEach(tag => {
19
19
  const additionalProfile = tag.replace('@additional_profile_', '');
20
20
  const actorDetails = (0, _getUsers.getUserForSelectedEditionAndProfile)(editionInfo, additionalProfile, betaFeature, portalInfo);
@@ -19,6 +19,7 @@ var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
19
19
  let cachedConfig = null;
20
20
  function getDefaultConfig() {
21
21
  return {
22
+ isTearDown: true,
22
23
  uatDirectory: _path.default.join(process.cwd(), 'uat'),
23
24
  headless: false,
24
25
  browsers: ['Chrome'],
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ class Project {
4
+ constructor(name) {
5
+ this.properties = {};
6
+ this.properties.name = name;
7
+ }
8
+ setTestDir(value) {
9
+ this.properties.testDir = value;
10
+ }
11
+ setTestMatch(value) {
12
+ this.properties.testMatch = value;
13
+ }
14
+ setRetries(value) {
15
+ this.properties.retries = value;
16
+ }
17
+ setUse(value) {
18
+ this.properties.use = value;
19
+ }
20
+ setTearDown(value) {
21
+ this.properties.teardown = value;
22
+ }
23
+ setDependencies(value) {
24
+ this.properties.dependencies = value;
25
+ }
26
+ setProperty(key, value) {
27
+ this.properties[key] = value;
28
+ }
29
+ getProperties() {
30
+ return this.properties;
31
+ }
32
+ }
33
+ module.exports = {
34
+ Project
35
+ };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.cleanupConfig = cleanupConfig;
8
+ exports.defaultConfig = defaultConfig;
9
+ exports.setupConfig = setupConfig;
10
+ exports.smokeTestConfig = smokeTestConfig;
11
+ var _path = _interopRequireDefault(require("path"));
12
+ var _Project = require("./Project");
13
+ var _configUtils = require("./config-utils");
14
+ var _readConfigFile = require("../readConfigFile");
15
+ const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
16
+ const {
17
+ isAuthMode,
18
+ isTearDown,
19
+ isSmokeTest,
20
+ bddMode,
21
+ authFilePath,
22
+ trace,
23
+ video,
24
+ testIdAttribute,
25
+ viewport
26
+ } = uatConfig;
27
+ function setupConfig() {
28
+ const setupProject = new _Project.Project('setup');
29
+ setupProject.setTestMatch(/.*\.setup\.js/);
30
+ setupProject.setTestDir(_path.default.join(process.cwd(), 'uat'));
31
+ setupProject.setTearDown(isTearDown ? 'cleanup' : '');
32
+ const setupProjectConfig = [setupProject.getProperties()];
33
+ return setupProjectConfig;
34
+ }
35
+ function smokeTestConfig() {
36
+ const smokeTestProject = new _Project.Project('smokeTest');
37
+ const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
38
+ featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
39
+ stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
40
+ outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
41
+ uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
42
+ });
43
+ const commonConfig = {
44
+ storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
45
+ };
46
+ smokeTestProject.setTestDir(smokeTestDir);
47
+ smokeTestProject.setRetries(0);
48
+ smokeTestProject.setUse({
49
+ ...commonConfig
50
+ });
51
+ smokeTestProject.setDependencies(isAuthMode ? ['setup'] : []);
52
+ const smokeTestProjectConfig = [smokeTestProject.getProperties()];
53
+ return smokeTestProjectConfig;
54
+ }
55
+ function defaultConfig() {
56
+ const defaultProject = new _Project.Project('default');
57
+ const testDir = (0, _configUtils.getTestDir)(bddMode, {
58
+ featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
59
+ stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
60
+ outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
61
+ uatPath: _path.default.join(process.cwd(), 'uat')
62
+ });
63
+ const use = {
64
+ trace,
65
+ video,
66
+ viewport,
67
+ testIdAttribute
68
+ };
69
+ defaultProject.setUse(use);
70
+ defaultProject.setTestDir(testDir);
71
+ defaultProject.setDependencies(isSmokeTest ? ['smokeTest'] : []);
72
+ const defaultProjectConfig = [defaultProject.getProperties()];
73
+ return defaultProjectConfig;
74
+ }
75
+ function cleanupConfig() {
76
+ const cleanupProject = new _Project.Project('cleanup');
77
+ cleanupProject.setTestMatch(/.*\.teardown\.js/);
78
+ cleanupProject.setTestDir(_path.default.join(process.cwd(), 'uat'));
79
+ const cleanupProjectConfig = [cleanupProject.getProperties()];
80
+ return cleanupProjectConfig;
81
+ }
@@ -9,47 +9,35 @@ var _test = require("@playwright/test");
9
9
  var _path = _interopRequireDefault(require("path"));
10
10
  var _readConfigFile = require("../readConfigFile");
11
11
  var _configUtils = require("./config-utils");
12
+ var _ProjectConfiguration = require("./ProjectConfiguration");
12
13
  const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
13
14
  const {
14
15
  browsers,
15
16
  isSmokeTest,
16
- trace,
17
- video,
17
+ isTearDown,
18
18
  isAuthMode,
19
19
  openReportOn,
20
20
  reportPath,
21
- bddMode,
22
21
  expectTimeout,
23
22
  testTimeout,
24
23
  authFilePath,
25
24
  viewport,
26
- featureFilesFolder,
27
- stepDefinitionsFolder,
28
- testIdAttribute,
29
25
  globalTimeout,
30
- customReporter
26
+ customReporter,
27
+ trace,
28
+ video,
29
+ testIdAttribute
31
30
  } = uatConfig;
32
31
  const projects = (0, _configUtils.getProjects)({
33
32
  browsers,
34
33
  isAuthMode,
35
34
  isSmokeTest,
35
+ isTearDown,
36
36
  authFilePath,
37
37
  expectTimeout,
38
38
  testTimeout,
39
39
  viewport
40
40
  });
41
- const testDir = (0, _configUtils.getTestDir)(bddMode, {
42
- featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
43
- stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
44
- outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
45
- uatPath: _path.default.join(process.cwd(), 'uat')
46
- });
47
- const use = {
48
- trace,
49
- video,
50
- viewport,
51
- testIdAttribute
52
- };
53
41
  let reporter = [['html', {
54
42
  outputFolder: reportPath,
55
43
  open: openReportOn
@@ -66,31 +54,18 @@ if (customReporter) {
66
54
  * @returns {import('@playwright/test').PlaywrightTestConfig}
67
55
  */
68
56
 
57
+ const use = {
58
+ trace,
59
+ video,
60
+ viewport,
61
+ testIdAttribute
62
+ };
69
63
  function getPlaywrightConfig() {
70
- const commonConfig = {
71
- storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
72
- };
73
- const dependencies = isAuthMode ? ['setup'] : [];
74
- const smokeTestProject = isSmokeTest ? smokeTestConfig() : [];
75
- function smokeTestConfig() {
76
- const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
77
- featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
78
- stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
79
- outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
80
- uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
81
- });
82
- return [{
83
- name: 'smokeTest',
84
- testDir: smokeTestDir,
85
- use: {
86
- ...commonConfig
87
- },
88
- dependencies: dependencies,
89
- retries: 0
90
- }];
91
- }
64
+ const smokeTestProject = isSmokeTest ? (0, _ProjectConfiguration.smokeTestConfig)() : [];
65
+ const setupProject = isAuthMode ? (0, _ProjectConfiguration.setupConfig)() : [];
66
+ const cleanupProject = isTearDown ? (0, _ProjectConfiguration.cleanupConfig)() : [];
67
+ const defaultProject = (0, _ProjectConfiguration.defaultConfig)();
92
68
  const playwrightConfig = {
93
- testDir,
94
69
  globalTimeout: globalTimeout || 3600000,
95
70
  outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
96
71
  fullyParallel: true,
@@ -100,16 +75,7 @@ function getPlaywrightConfig() {
100
75
  timeout: expectTimeout
101
76
  },
102
77
  use,
103
- projects: isAuthMode ? [{
104
- name: 'setup',
105
- testMatch: /.*\.setup\.js/,
106
- testDir: _path.default.join(process.cwd(), 'uat'),
107
- teardown: 'cleanup'
108
- }, ...smokeTestProject, {
109
- name: 'cleanup',
110
- testMatch: /.*\.teardown\.js/,
111
- testDir: _path.default.join(process.cwd(), 'uat')
112
- }, ...projects] : [...projects, ...smokeTestProject],
78
+ projects: [...setupProject, ...smokeTestProject, ...defaultProject, ...cleanupProject, ...projects],
113
79
  ...uatConfig
114
80
  };
115
81
  return playwrightConfig;
@@ -16,6 +16,7 @@ jest.mock('../../../../../core/playwright/helpers/auth/getUsers', () => ({
16
16
  }));
17
17
  const defaultTags = ['@profile_admin', '@edition_enterprise'];
18
18
  const editionTags = ['@profile_admin', '@edition_enterprise', '@additional_profile_manager', '@additional_profile_agent'];
19
+ const editionAndPortalTags = ['@profile_admin', '@edition_enterprise', '@beta_parentchild', '@portal_clientuat2', '@additional_profile_manager'];
19
20
  describe('additionalProfiles', () => {
20
21
  beforeEach(() => {
21
22
  jest.clearAllMocks();
@@ -24,15 +25,21 @@ describe('additionalProfiles', () => {
24
25
  const result = (0, _additionalProfiles.additionProfiles)(defaultTags);
25
26
  expect(result).toEqual({});
26
27
  });
27
- test('should return empty object when additional profile tags are present but no editionInfo', () => {
28
- const tags = ['@smoke', '@additional_profile_admin'];
29
- const result = (0, _additionalProfiles.additionProfiles)(tags);
30
- expect(result).toEqual({});
31
- });
32
28
  test('should return additional profile actors when additional profile tags and editionInfo are present', () => {
33
- const mockBetaFeature = null;
34
- const mockPortalInfo = null;
35
- const result = (0, _additionalProfiles.additionProfiles)(editionTags, mockBetaFeature, mockPortalInfo);
29
+ const result = (0, _additionalProfiles.additionProfiles)(editionTags);
36
30
  expect(Object.keys(result)).toEqual(['manager', 'agent']);
31
+ expect(result.manager).toHaveProperty('email');
32
+ expect(result.agent).toHaveProperty('email');
33
+ expect(result.manager.profile).toBe('manager');
34
+ expect(result.manager.betaFeature).toBe(null);
35
+ expect(result.agent.portalInfo).toBe(null);
36
+ });
37
+ test('should return additional profile actors when all actor details are present', () => {
38
+ const result = (0, _additionalProfiles.additionProfiles)(editionAndPortalTags);
39
+ expect(Object.keys(result)).toEqual(['manager']);
40
+ expect(result.manager).toHaveProperty('email');
41
+ expect(result.manager.profile).toBe('manager');
42
+ expect(result.manager.betaFeature).toBe("parentchild");
43
+ expect(result.manager.portalInfo).toBe("clientuat2");
37
44
  });
38
45
  });