@zohodesk/testinglibrary 0.4.97-n18-experimental → 0.4.99-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
@@ -188,19 +188,19 @@ uat-data_generator:
188
188
  paths:
189
189
  - examples/uat/playwright-report
190
190
 
191
- uat-search_indexing:
192
- stage: uat
193
- script:
194
- - cd examples
195
- - npm install $(npm pack ../../testing-framework | tail -1)
196
- - output=$(npm run uat-search_indexing)
197
- - echo "$output"
198
- - node ../ValidateUATReport.js examples
199
-
200
- artifacts:
201
- when: always
202
- paths:
203
- - examples/uat/playwright-report
191
+ # uat-search_indexing:
192
+ # stage: uat
193
+ # script:
194
+ # - cd examples
195
+ # - npm install $(npm pack ../../testing-framework | tail -1)
196
+ # - output=$(npm run uat-search_indexing)
197
+ # - echo "$output"
198
+ # - node ../ValidateUATReport.js examples
199
+
200
+ # artifacts:
201
+ # when: always
202
+ # paths:
203
+ # - examples/uat/playwright-report
204
204
 
205
205
 
206
206
 
package/README.md CHANGED
@@ -17,13 +17,22 @@
17
17
 
18
18
  - npm run report
19
19
 
20
- ## Version History
20
+ ### v3.2.13 - 30-10-2025
21
+
22
+ #### Enhancement
21
23
 
22
- ### Unpublished release
24
+ - A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
23
25
 
24
- ### Feature
26
+ ### Issue fix
25
27
 
26
- - New step `a search entity using {string}` provided for search indexing, This step will use run time data generation response as input for the indexing
28
+ - Custom teardown comment provided
29
+
30
+ ### v3.2.11 - 13-10-2025
31
+
32
+ ### Feature
33
+
34
+ - New step a search entity using {string} provided for search indexing, This step will use run time data generation response as input for the indexing
35
+
27
36
 
28
37
  ### v3.2.9 - 26-09-2025
29
38
 
@@ -32,6 +41,7 @@
32
41
  - Authentication deatils for data generation can be configured in org level
33
42
  - reference link : https://learn.zoho.in/portal/zohocorp/knowledge/manual/client-uat/article/data-generation#_Tocpd3n7yt9ngeg
34
43
 
44
+
35
45
  ### v3.2.8 - 18-09-2025
36
46
 
37
47
  ### Bug fix
@@ -1,6 +1,5 @@
1
1
  import { test } from '@zohodesk/testinglibrary';
2
2
  import DataGenerator from '@zohodesk/testinglibrary/DataGenerator';
3
- import {getUserForSelectedEditionAndProfile} from '@zohodesk/testinglibrary/helpers'
4
3
 
5
4
  const dataGenerator = new DataGenerator();
6
5
 
@@ -10,8 +9,7 @@ export async function generateAndCacheTestData(executionContext, type, identifie
10
9
  const scenarioName = testInfo.title.split('/').pop() || 'Unknown Scenario';
11
10
 
12
11
  if (profile) {
13
- const { edition, orgName: portal, beta } = executionContext.actorInfo;
14
- actorInfo = await getUserForSelectedEditionAndProfile(edition, profile, beta, portal);
12
+ actorInfo = await dataGenerator.getDataGenUserExecutionContext(executionContext.actorInfo.edition, profile);
15
13
  } else {
16
14
  actorInfo = executionContext.actorInfo;
17
15
  }
@@ -47,6 +47,15 @@ class DataGenerator {
47
47
  throw error;
48
48
  }
49
49
  }
50
+ async getDataGenUserExecutionContext(edition, profile) {
51
+ try {
52
+ const dataGenUserDetails = await (0, _helpers.getUserForSelectedEditionAndProfile)(edition, profile);
53
+ return dataGenUserDetails;
54
+ } catch (error) {
55
+ console.error('Error occurred while fetching data generation user details: ', error);
56
+ throw error;
57
+ }
58
+ }
50
59
  }
51
60
  async function _getGenerator(testInfo, generatorName) {
52
61
  let generator = null;
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.combineConfiguration = combineConfiguration;
8
7
  exports.getApplicationConfig = getApplicationConfig;
9
- var _path = _interopRequireDefault(require("path"));
8
+ exports.getRunStage = getRunStage;
10
9
  var _logger = require("../../../utils/logger");
11
10
  var _configFileNameProvider = require("../helpers/configFileNameProvider");
12
11
  var _mergeObjects = require("../helpers/mergeObjects");
13
12
  var _fs = require("fs");
14
- const Configuration = require("./Configuration");
15
13
  function combineConfiguration(defaultConfig, userConfiguration) {
16
14
  let configurationObj = {};
17
15
  Object.keys(userConfiguration).forEach(configKey => {
@@ -26,10 +24,10 @@ function combineConfiguration(defaultConfig, userConfiguration) {
26
24
  });
27
25
  return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
28
26
  }
29
- function getApplicationConfig(mode) {
27
+ function getApplicationConfig(stage, mode) {
30
28
  let filePath = "";
31
29
  try {
32
- filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)(mode));
30
+ filePath = (0, _configFileNameProvider.getUATFileName)(stage, mode);
33
31
  if (!(0, _fs.existsSync)(filePath)) {
34
32
  throw new Error("Exception while getting the uat file from the application - " + filePath);
35
33
  }
@@ -40,4 +38,8 @@ function getApplicationConfig(mode) {
40
38
  _logger.Logger.error(err);
41
39
  return {};
42
40
  }
41
+ }
42
+ function getRunStage() {
43
+ const stage = process.env.stage;
44
+ return stage || 'uat';
43
45
  }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UAT_CONFIG_FILE = exports.TEST_SUMMARY_FILE = exports.STAGE_CONFIG_MAP_FILE = exports.SETTINGS_FILE = exports.INDEX_FILE = exports.DEFAULT_CONFIG_DIR = exports.BETA_DIR = exports.ACTOR_DIR = void 0;
7
+ const DEFAULT_CONFIG_DIR = exports.DEFAULT_CONFIG_DIR = 'default';
8
+ const BETA_DIR = exports.BETA_DIR = 'beta';
9
+ const ACTOR_DIR = exports.ACTOR_DIR = 'actors';
10
+ const UAT_CONFIG_FILE = exports.UAT_CONFIG_FILE = 'uat.config.js';
11
+ const INDEX_FILE = exports.INDEX_FILE = 'index.js';
12
+ const SETTINGS_FILE = exports.SETTINGS_FILE = 'settings.json';
13
+ const TEST_SUMMARY_FILE = exports.TEST_SUMMARY_FILE = 'test-summary.json';
14
+ const STAGE_CONFIG_MAP_FILE = exports.STAGE_CONFIG_MAP_FILE = 'uat/conf-path-map.properties';
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CUSTOM_COMMANDS = void 0;
7
- const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules'];
7
+ const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['stage', 'mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules', 'isTearDown'];
@@ -17,19 +17,20 @@ function setEnvironmentVariables(configJSON) {
17
17
  }
18
18
  function addHelperLogsForEnvInitialization() {
19
19
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Mode under which test cases should run has not been specified in args.`);
20
- _logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/prod' while running ZDTestingFramework test`);
20
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/ci/cd/devautomation' while running ZDTestingFramework test`);
21
21
  _logger.Logger.log(_logger.Logger.INFO_TYPE, `Going to use default mode as dev`);
22
22
  }
23
- function initializeEnvConfig(mode, isAuthMode) {
23
+ function initializeEnvConfig(stage, mode, isAuthMode) {
24
+ if (!mode) {
25
+ addHelperLogsForEnvInitialization();
26
+ mode = 'dev';
27
+ }
28
+ const configFilePath = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), `./${(0, _configFileNameProvider.getEnvConfigFilePath)(stage, mode)}`));
24
29
  try {
25
- if (!mode) {
26
- addHelperLogsForEnvInitialization();
27
- mode = 'dev';
28
- }
29
- const configFile = (0, _fs.readFileSync)(_path.default.resolve(process.cwd(), `./${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)}`));
30
- const configJSON = JSON.parse(configFile);
30
+ const configJSON = JSON.parse(configFilePath);
31
31
  setEnvironmentVariables({
32
32
  ...configJSON,
33
+ stage,
33
34
  mode
34
35
  });
35
36
  if (isAuthMode) {
@@ -38,6 +39,6 @@ function initializeEnvConfig(mode, isAuthMode) {
38
39
  }
39
40
  } catch (err) {
40
41
  _logger.Logger.error(err);
41
- throw new Error(`Config File Not Exists. Please provide a config file ${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)} to intiailize the environment variables `);
42
+ throw new Error(`Config File Not Exists. Please provide a ${configFilePath} to initialize the environment variables`);
42
43
  }
43
44
  }
@@ -13,7 +13,9 @@ exports.isCI = isCI;
13
13
  exports.isDevelopmentSetup = isDevelopmentSetup;
14
14
  var _path = _interopRequireDefault(require("path"));
15
15
  var _fs = require("fs");
16
- var _readConfigFile = require("../../readConfigFile");
16
+ var _configPathResolver = require("../configPathResolver");
17
+ var _ConfigurationHelper = require("./../../configuration/ConfigurationHelper");
18
+ var _configFiles = require("../../constants/configFiles");
17
19
  /* eslint-disable global-require */
18
20
  function getRunMode() {
19
21
  let {
@@ -30,19 +32,18 @@ function isDevelopmentSetup() {
30
32
  return mode === 'DEV' || mode === 'dev';
31
33
  }
32
34
  function getDefaultActorConf() {
33
- const {
34
- uatDirectory
35
- } = (0, _readConfigFile.generateConfigFromFile)();
36
- const modeSettingsFile = `conf/${getRunMode()}/settings.json`;
37
- const filePath = _path.default.join(uatDirectory, modeSettingsFile);
35
+ const stage = (0, _ConfigurationHelper.getRunStage)();
36
+ const stagePath = (0, _configPathResolver.getConfigPath)(stage);
37
+ const modeSettingsFile = `${stagePath}/${getRunMode()}/${_configFiles.SETTINGS_FILE}`;
38
+ const filePath = _path.default.join(_path.default.resolve(process.cwd(), modeSettingsFile));
38
39
  try {
39
40
  if (!(0, _fs.existsSync)(filePath)) {
40
- const defaultSettingsFile = _path.default.join(uatDirectory, `conf/default/settings.json`);
41
+ const defaultSettingsFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${_configFiles.DEFAULT_CONFIG_DIR}/${_configFiles.SETTINGS_FILE}`));
41
42
  return require(defaultSettingsFile);
42
43
  }
43
44
  return require(filePath);
44
45
  } catch (error) {
45
- throw new Error(`${defaultSettingFile} ${filePath} both files are missing.`);
46
+ throw new Error(`${filePath} file missing.`);
46
47
  }
47
48
  }
48
49
  function getDefaultActor() {
@@ -53,18 +54,17 @@ function getDefaultActor() {
53
54
  return getUserForSelectedEditionAndProfile(edition, profile);
54
55
  }
55
56
  function getListOfActors(betaFeature) {
56
- const {
57
- uatDirectory
58
- } = (0, _readConfigFile.generateConfigFromFile)();
59
57
  const mode = getRunMode();
60
- let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
58
+ const stage = (0, _ConfigurationHelper.getRunStage)();
59
+ const stagePath = (0, _configPathResolver.getConfigPath)(stage);
60
+ let configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${mode}/${_configFiles.ACTOR_DIR}/${_configFiles.INDEX_FILE}`));
61
61
  let betaReference = mode;
62
62
  if (!(0, _fs.existsSync)(configFile)) {
63
- configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
63
+ configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${_configFiles.DEFAULT_CONFIG_DIR}/${_configFiles.ACTOR_DIR}/${_configFiles.INDEX_FILE}`));
64
64
  betaReference = "default";
65
65
  }
66
66
  if (betaFeature) {
67
- configFile = _path.default.join(uatDirectory, `conf/${betaReference}/actors/beta/${betaFeature}/index.js`);
67
+ configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${betaReference}/${_configFiles.ACTOR_DIR}/${_configFiles.BETA_DIR}/${betaFeature}/${_configFiles.INDEX_FILE}`));
68
68
  if (!(0, _fs.existsSync)(configFile)) {
69
69
  throw new Error(`There is no beta feature configured with the name "${betaFeature}"`);
70
70
  }
@@ -113,7 +113,6 @@ function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile,
113
113
  }
114
114
  return {
115
115
  ...editionData,
116
- ...selectedProfile,
117
- 'beta': betaFeature
116
+ ...selectedProfile
118
117
  };
119
118
  }
@@ -10,22 +10,29 @@ exports.getUATFileName = getUATFileName;
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  var _fs = _interopRequireDefault(require("fs"));
12
12
  var _auth = require("./auth");
13
- function getUATFileName(mode) {
13
+ var _ConfigurationHelper = require("./../configuration/ConfigurationHelper");
14
+ var _configPathResolver = require("./configPathResolver");
15
+ var _configFiles = require("../constants/configFiles");
16
+ function getUATFileName(stage, mode) {
17
+ stage = stage || (0, _ConfigurationHelper.getRunStage)();
14
18
  mode = mode || (0, _auth.getRunMode)();
15
- const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
19
+ const stagePath = (0, _configPathResolver.getConfigPath)(stage);
20
+ const uatConfFilePath = _path.default.resolve(process.cwd(), `${stagePath}/${mode}/${_configFiles.UAT_CONFIG_FILE}`);
16
21
  if (_fs.default.existsSync(uatConfFilePath)) {
17
22
  return uatConfFilePath;
18
23
  }
19
- return _path.default.resolve(process.cwd(), `uat/conf/default/uat.config.js`);
24
+ ;
25
+ return _path.default.resolve(process.cwd(), `${stagePath}/${_configFiles.DEFAULT_CONFIG_DIR}/${_configFiles.UAT_CONFIG_FILE}`);
20
26
  }
21
- function getEnvConfigFilePath(mode) {
22
- const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
27
+ function getEnvConfigFilePath(stage, mode) {
28
+ const stagePath = (0, _configPathResolver.getConfigPath)(stage);
29
+ const confFilePath = `${stagePath}/${mode}/${_configFiles.SETTINGS_FILE}`;
23
30
  // TODO: Actors Mode as config
24
31
  if (_fs.default.existsSync(confFilePath)) {
25
- return `uat/conf/${mode}/settings.json`;
32
+ return confFilePath;
26
33
  }
27
- return `uat/conf/default/settings.json`;
34
+ return `${stagePath}/${_configFiles.DEFAULT_CONFIG_DIR}/${_configFiles.SETTINGS_FILE}`;
28
35
  }
29
36
  function getReportFileName() {
30
- return `test-summary.json`;
37
+ return `${_configFiles.TEST_SUMMARY_FILE}`;
31
38
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getConfigPath = getConfigPath;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _path = _interopRequireDefault(require("path"));
10
+ var _propertiesReader = _interopRequireDefault(require("properties-reader"));
11
+ var _logger = require("../../../utils/logger");
12
+ var _configFiles = require("../constants/configFiles");
13
+ //This function reads a properties file and returns the entire properties
14
+
15
+ function readPropertiesFile(relativeFilePath) {
16
+ const filePath = _path.default.resolve(process.cwd(), relativeFilePath);
17
+ if (!_fs.default.existsSync(filePath)) {
18
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Properties file ${filePath} not found at path. Using default configurations.`);
19
+ return {
20
+ get: () => 'uat/conf'
21
+ };
22
+ }
23
+ const properties = (0, _propertiesReader.default)(filePath);
24
+ return properties;
25
+ }
26
+
27
+ // This function return the value for the passed arguments key
28
+
29
+ function getConfigPath(stage) {
30
+ const props = readPropertiesFile(_configFiles.STAGE_CONFIG_MAP_FILE);
31
+ const configPath = props.get(stage);
32
+ if (!configPath) {
33
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `No config mapping found for stage: "${stage}"`);
34
+ }
35
+ return configPath;
36
+ }
@@ -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'],
@@ -110,15 +111,16 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
110
111
  */
111
112
 
112
113
  function getConfigFilePath() {
113
- return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
114
+ return (0, _configFileNameProvider.getUATFileName)();
114
115
  }
115
116
  function generateConfigFromFile() {
116
117
  if (cachedConfig === null) {
117
118
  // Getting the default config's from framework
118
119
  const uatConfig = new _Configuration.default(getDefaultConfig());
119
120
  // overriding the application config's from project
120
- const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)());
121
121
  const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
122
+ const stage = userArgConfig.get("stage");
123
+ const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage));
122
124
  // overriding the user config's from CLI
123
125
  uatConfig.addAll(appConfig);
124
126
  uatConfig.addAll(userArgConfig);
@@ -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,80 @@
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.setupConfig = setupConfig;
9
+ exports.smokeTestConfig = smokeTestConfig;
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _Project = require("./Project");
12
+ var _configUtils = require("./config-utils");
13
+ var _readConfigFile = require("../readConfigFile");
14
+ const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
15
+ const {
16
+ isAuthMode,
17
+ isSmokeTest,
18
+ bddMode,
19
+ authFilePath,
20
+ trace,
21
+ video,
22
+ testIdAttribute,
23
+ viewport
24
+ } = uatConfig;
25
+ function setupConfig() {
26
+ const setupProject = new _Project.Project('setup');
27
+ setupProject.setTestMatch(/.*\.setup\.js/);
28
+ setupProject.setTestDir(_path.default.join(process.cwd(), 'uat'));
29
+ const isTearDown = JSON.parse(process.env.tearDown);
30
+ setupProject.setTearDown(isTearDown ? 'cleanup' : '');
31
+ const setupProjectConfig = [setupProject.getProperties()];
32
+ return setupProjectConfig;
33
+ }
34
+ function smokeTestConfig() {
35
+ const smokeTestProject = new _Project.Project('smokeTest');
36
+ const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
37
+ featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
38
+ stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
39
+ outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
40
+ uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
41
+ });
42
+ const commonConfig = {
43
+ storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
44
+ };
45
+ smokeTestProject.setTestDir(smokeTestDir);
46
+ smokeTestProject.setRetries(0);
47
+ smokeTestProject.setUse({
48
+ ...commonConfig
49
+ });
50
+ smokeTestProject.setDependencies(isAuthMode ? ['setup'] : []);
51
+ const smokeTestProjectConfig = [smokeTestProject.getProperties()];
52
+ return smokeTestProjectConfig;
53
+ }
54
+ function defaultConfig() {
55
+ const defaultProject = new _Project.Project('default');
56
+ const testDir = (0, _configUtils.getTestDir)(bddMode, {
57
+ featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
58
+ stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
59
+ outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
60
+ uatPath: _path.default.join(process.cwd(), 'uat')
61
+ });
62
+ const use = {
63
+ trace,
64
+ video,
65
+ viewport,
66
+ testIdAttribute
67
+ };
68
+ defaultProject.setUse(use);
69
+ defaultProject.setTestDir(testDir);
70
+ defaultProject.setDependencies(isSmokeTest ? ['smokeTest'] : []);
71
+ const defaultProjectConfig = [defaultProject.getProperties()];
72
+ return defaultProjectConfig;
73
+ }
74
+ function cleanupConfig() {
75
+ const cleanupProject = new _Project.Project('cleanup');
76
+ cleanupProject.setTestMatch(/.*\.teardown\.js/);
77
+ cleanupProject.setTestDir(_path.default.join(process.cwd(), 'uat'));
78
+ const cleanupProjectConfig = [cleanupProject.getProperties()];
79
+ return cleanupProjectConfig;
80
+ }
@@ -9,25 +9,24 @@ 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 {
15
+ bddMode,
14
16
  browsers,
15
17
  isSmokeTest,
16
- trace,
17
- video,
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,
@@ -38,18 +37,6 @@ const projects = (0, _configUtils.getProjects)({
38
37
  testTimeout,
39
38
  viewport
40
39
  });
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
40
  let reporter = [['html', {
54
41
  outputFolder: reportPath,
55
42
  open: openReportOn
@@ -66,29 +53,23 @@ if (customReporter) {
66
53
  * @returns {import('@playwright/test').PlaywrightTestConfig}
67
54
  */
68
55
 
56
+ const use = {
57
+ trace,
58
+ video,
59
+ viewport,
60
+ testIdAttribute
61
+ };
62
+ const testDir = (0, _configUtils.getTestDir)(bddMode, {
63
+ featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
64
+ stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
65
+ outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
66
+ uatPath: _path.default.join(process.cwd(), 'uat')
67
+ });
69
68
  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
- }
69
+ const smokeTestProject = isSmokeTest ? (0, _ProjectConfiguration.smokeTestConfig)() : [];
70
+ const setupProject = isAuthMode ? (0, _ProjectConfiguration.setupConfig)() : [];
71
+ const isTearDown = JSON.parse(process.env.tearDown);
72
+ const cleanupProject = isTearDown ? (0, _ProjectConfiguration.cleanupConfig)() : [];
92
73
  const playwrightConfig = {
93
74
  testDir,
94
75
  globalTimeout: globalTimeout || 3600000,
@@ -100,16 +81,7 @@ function getPlaywrightConfig() {
100
81
  timeout: expectTimeout
101
82
  },
102
83
  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],
84
+ projects: [...setupProject, ...smokeTestProject, ...projects, ...cleanupProject],
113
85
  ...uatConfig
114
86
  };
115
87
  return playwrightConfig;
@@ -86,13 +86,17 @@ function main() {
86
86
  // overriding the application config's from project
87
87
  const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
88
88
  const mode = userArgConfig.get("mode");
89
- uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
89
+ const stage = userArgConfig.get("stage");
90
+ uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage, mode)));
90
91
  // overriding the user config's from CLI
91
92
  uatConfig.addAll(userArgConfig);
92
93
  const modules = uatConfig.get('modules');
94
+ const tearDown = uatConfig.get('isTearDown');
93
95
 
94
96
  //We need to change this process.env variable to pass the module name in future.
95
97
  process.env.modules = modules;
98
+ process.env.tearDown = tearDown;
99
+ process.env.stage = stage;
96
100
  const {
97
101
  isAuthMode,
98
102
  editionOrder,
@@ -100,7 +104,7 @@ function main() {
100
104
  bddMode = false,
101
105
  headless = false
102
106
  } = uatConfig.getAll();
103
- (0, _envInitializer.initializeEnvConfig)(mode, isAuthMode);
107
+ (0, _envInitializer.initializeEnvConfig)(stage, mode, isAuthMode);
104
108
 
105
109
  //This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
106
110
  const userArgsObject = userArgConfig.getAll();