@zohodesk/testinglibrary 0.5.2-n18-experimental → 0.5.4-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
@@ -40,6 +40,14 @@
40
40
 
41
41
  - 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
42
42
 
43
+ ### Issue fix
44
+ - Custom teardown comment provided
45
+
46
+ ### v3.2.10 - 09-10-2025
47
+
48
+ #### Enhancement
49
+ - A teardown option has been introduced in the configuration to manage and clean up login sessions stored in the NFS environment.
50
+
43
51
 
44
52
  ### v3.2.9 - 26-09-2025
45
53
 
@@ -26,7 +26,8 @@ var _default = exports.default = {
26
26
  await context.clearCookies();
27
27
  return;
28
28
  }
29
- await (0, _loginDefaultStepsHelper.executeDefaultLoginSteps)(context, testInfo, testDetails, testPortalDetails);
29
+
30
+ // await executeDefaultLoginSteps(context, testInfo , testDetails, testPortalDetails);
30
31
  } catch (e) {
31
32
  console.error('Error during page', e);
32
33
  } finally {
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.combineConfiguration = combineConfiguration;
7
8
  exports.getApplicationConfig = getApplicationConfig;
8
- exports.getRunStage = getRunStage;
9
+ var _path = _interopRequireDefault(require("path"));
9
10
  var _logger = require("../../../utils/logger");
10
11
  var _configFileNameProvider = require("../helpers/configFileNameProvider");
11
12
  var _mergeObjects = require("../helpers/mergeObjects");
12
13
  var _fs = require("fs");
14
+ const Configuration = require("./Configuration");
13
15
  function combineConfiguration(defaultConfig, userConfiguration) {
14
16
  let configurationObj = {};
15
17
  Object.keys(userConfiguration).forEach(configKey => {
@@ -24,10 +26,10 @@ function combineConfiguration(defaultConfig, userConfiguration) {
24
26
  });
25
27
  return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
26
28
  }
27
- function getApplicationConfig(stage, mode) {
29
+ function getApplicationConfig(mode) {
28
30
  let filePath = "";
29
31
  try {
30
- filePath = (0, _configFileNameProvider.getUATFileName)(stage, mode);
32
+ filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)(mode));
31
33
  if (!(0, _fs.existsSync)(filePath)) {
32
34
  throw new Error("Exception while getting the uat file from the application - " + filePath);
33
35
  }
@@ -38,8 +40,4 @@ function getApplicationConfig(stage, mode) {
38
40
  _logger.Logger.error(err);
39
41
  return {};
40
42
  }
41
- }
42
- function getRunStage() {
43
- const stage = process.env.stage;
44
- return stage || 'uat';
45
43
  }
@@ -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 = ['stage', 'mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules', 'isTearDown'];
7
+ const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless', 'modules', 'isTearDown'];
@@ -17,20 +17,19 @@ 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/ci/cd/devautomation' while running ZDTestingFramework test`);
20
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Please specify --mode='dev/prod' 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(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)}`));
23
+ function initializeEnvConfig(mode, isAuthMode) {
29
24
  try {
30
- const configJSON = JSON.parse(configFilePath);
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);
31
31
  setEnvironmentVariables({
32
32
  ...configJSON,
33
- stage,
34
33
  mode
35
34
  });
36
35
  if (isAuthMode) {
@@ -39,6 +38,6 @@ function initializeEnvConfig(stage, mode, isAuthMode) {
39
38
  }
40
39
  } catch (err) {
41
40
  _logger.Logger.error(err);
42
- throw new Error(`Config File Not Exists. Please provide a ${configFilePath} to initialize the environment variables`);
41
+ throw new Error(`Config File Not Exists. Please provide a config file ${(0, _configFileNameProvider.getEnvConfigFilePath)(mode)} to intiailize the environment variables `);
43
42
  }
44
43
  }
@@ -13,9 +13,7 @@ exports.isCI = isCI;
13
13
  exports.isDevelopmentSetup = isDevelopmentSetup;
14
14
  var _path = _interopRequireDefault(require("path"));
15
15
  var _fs = require("fs");
16
- var _configPathResolver = require("../configPathResolver");
17
- var _ConfigurationHelper = require("./../../configuration/ConfigurationHelper");
18
- var _configConstants = _interopRequireDefault(require("../../constants/configConstants"));
16
+ var _readConfigFile = require("../../readConfigFile");
19
17
  /* eslint-disable global-require */
20
18
  function getRunMode() {
21
19
  let {
@@ -32,18 +30,19 @@ function isDevelopmentSetup() {
32
30
  return mode === 'DEV' || mode === 'dev';
33
31
  }
34
32
  function getDefaultActorConf() {
35
- const stage = (0, _ConfigurationHelper.getRunStage)();
36
- const stagePath = (0, _configPathResolver.getConfigPath)(stage);
37
- const modeSettingsFile = `${stagePath}/${getRunMode()}/${_configConstants.default.SETTINGS_FILE}`;
38
- const filePath = _path.default.join(_path.default.resolve(process.cwd(), modeSettingsFile));
33
+ const {
34
+ uatDirectory
35
+ } = (0, _readConfigFile.generateConfigFromFile)();
36
+ const modeSettingsFile = `conf/${getRunMode()}/settings.json`;
37
+ const filePath = _path.default.join(uatDirectory, modeSettingsFile);
39
38
  try {
40
39
  if (!(0, _fs.existsSync)(filePath)) {
41
- const defaultSettingsFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${_configConstants.default.DEFAULT_CONFIG_DIR}/${_configConstants.default.SETTINGS_FILE}`));
40
+ const defaultSettingsFile = _path.default.join(uatDirectory, `conf/default/settings.json`);
42
41
  return require(defaultSettingsFile);
43
42
  }
44
43
  return require(filePath);
45
44
  } catch (error) {
46
- throw new Error(`${filePath} file missing.`);
45
+ throw new Error(`${defaultSettingFile} ${filePath} both files are missing.`);
47
46
  }
48
47
  }
49
48
  function getDefaultActor() {
@@ -54,17 +53,18 @@ function getDefaultActor() {
54
53
  return getUserForSelectedEditionAndProfile(edition, profile);
55
54
  }
56
55
  function getListOfActors(betaFeature) {
56
+ const {
57
+ uatDirectory
58
+ } = (0, _readConfigFile.generateConfigFromFile)();
57
59
  const mode = getRunMode();
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}/${_configConstants.default.ACTOR_DIR}/${_configConstants.default.INDEX_FILE}`));
60
+ let configFile = _path.default.join(uatDirectory, `conf/${mode}/actors/index.js`);
61
61
  let betaReference = mode;
62
62
  if (!(0, _fs.existsSync)(configFile)) {
63
- configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${_configConstants.default.DEFAULT_CONFIG_DIR}/${_configConstants.default.ACTOR_DIR}/${_configConstants.default.INDEX_FILE}`));
63
+ configFile = _path.default.join(uatDirectory, `conf/default/actors/index.js`);
64
64
  betaReference = "default";
65
65
  }
66
66
  if (betaFeature) {
67
- configFile = _path.default.join(_path.default.resolve(process.cwd(), `${stagePath}/${betaReference}/${_configConstants.default.ACTOR_DIR}/${_configConstants.default.BETA_DIR}/${betaFeature}/${_configConstants.default.INDEX_FILE}`));
67
+ configFile = _path.default.join(uatDirectory, `conf/${betaReference}/actors/beta/${betaFeature}/index.js`);
68
68
  if (!(0, _fs.existsSync)(configFile)) {
69
69
  throw new Error(`There is no beta feature configured with the name "${betaFeature}"`);
70
70
  }
@@ -18,14 +18,15 @@ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
18
18
  authFilePrefix,
19
19
  email
20
20
  } = testInfo;
21
- authFilePrefix = authFilePrefix || email;
21
+ authFilePrefix = authFilePrefix ? authFilePrefix + email : email;
22
+ process.env.authFilePrefix = authFilePrefix;
22
23
  const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
23
- const lockFileName = email.replace(/[@.]/g, '_');
24
+ const lockFileName = authFilePrefix.replace(/[@.]/g, '_');
24
25
  const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.fileDeletionTimeoutConfig);
25
26
  let loginUsingCookie = false;
26
27
  try {
27
28
  if ((0, _checkAuthCookies.verifyIfCookieFileExists)(authFile)) {
28
- console.log(`${email} Cookie file exists. Loading cookies, worker index - ${process.env.TEST_WORKER_INDEX}`);
29
+ console.log(`${authFilePrefix} Cookie file exists. Loading cookies, worker index - ${process.env.TEST_WORKER_INDEX}`);
29
30
  loginUsingCookie = true;
30
31
  } else {
31
32
  await fileMutex.acquire();
@@ -40,7 +41,7 @@ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
40
41
  });
41
42
  }
42
43
  } catch (error) {
43
- console.error(`Error during login for ${email}:`, error);
44
+ console.error(`Error during login for ${authFilePrefix}:`, error);
44
45
  } finally {
45
46
  if (!loginUsingCookie) {
46
47
  await fileMutex.release();
@@ -10,29 +10,22 @@ exports.getUATFileName = getUATFileName;
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  var _fs = _interopRequireDefault(require("fs"));
12
12
  var _auth = require("./auth");
13
- var _ConfigurationHelper = require("./../configuration/ConfigurationHelper");
14
- var _configPathResolver = require("./configPathResolver");
15
- var _configConstants = _interopRequireDefault(require("../constants/configConstants"));
16
- function getUATFileName(stage, mode) {
17
- stage = stage || (0, _ConfigurationHelper.getRunStage)();
13
+ function getUATFileName(mode) {
18
14
  mode = mode || (0, _auth.getRunMode)();
19
- const stagePath = (0, _configPathResolver.getConfigPath)(stage);
20
- const uatConfFilePath = _path.default.resolve(process.cwd(), `${stagePath}/${mode}/${_configConstants.default.UAT_CONFIG_FILE}`);
15
+ const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
21
16
  if (_fs.default.existsSync(uatConfFilePath)) {
22
17
  return uatConfFilePath;
23
18
  }
24
- ;
25
- return _path.default.resolve(process.cwd(), `${stagePath}/${_configConstants.default.DEFAULT_CONFIG_DIR}/${_configConstants.default.UAT_CONFIG_FILE}`);
19
+ return _path.default.resolve(process.cwd(), `uat/conf/default/uat.config.js`);
26
20
  }
27
- function getEnvConfigFilePath(stage, mode) {
28
- const stagePath = (0, _configPathResolver.getConfigPath)(stage);
29
- const confFilePath = `${stagePath}/${mode}/${_configConstants.default.SETTINGS_FILE}`;
21
+ function getEnvConfigFilePath(mode) {
22
+ const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
30
23
  // TODO: Actors Mode as config
31
24
  if (_fs.default.existsSync(confFilePath)) {
32
- return confFilePath;
25
+ return `uat/conf/${mode}/settings.json`;
33
26
  }
34
- return `${stagePath}/${_configConstants.default.DEFAULT_CONFIG_DIR}/${_configConstants.default.SETTINGS_FILE}`;
27
+ return `uat/conf/default/settings.json`;
35
28
  }
36
29
  function getReportFileName() {
37
- return `${_configConstants.default.TEST_SUMMARY_FILE}`;
30
+ return `test-summary.json`;
38
31
  }
@@ -17,6 +17,10 @@ var _Configuration = _interopRequireDefault(require("./configuration/Configurati
17
17
  var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
18
18
  var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
19
19
  let cachedConfig = null;
20
+ function getPrimaryCookiePath() {
21
+ const authFilePrefix = process.env.authFilePrefix;
22
+ return `uat/playwright/.auth/${authFilePrefix}-cookies.json`;
23
+ }
20
24
  function getDefaultConfig() {
21
25
  return {
22
26
  isTearDown: true,
@@ -33,7 +37,7 @@ function getDefaultConfig() {
33
37
  bddMode: false,
34
38
  expectTimeout: 5 * 1000,
35
39
  testTimeout: 60 * 1000,
36
- authFilePath: 'uat/playwright/.auth/user.json',
40
+ authFilePath: getPrimaryCookiePath(),
37
41
  viewport: {
38
42
  width: 1280,
39
43
  height: 720
@@ -111,16 +115,15 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
111
115
  */
112
116
 
113
117
  function getConfigFilePath() {
114
- return (0, _configFileNameProvider.getUATFileName)();
118
+ return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
115
119
  }
116
120
  function generateConfigFromFile() {
117
121
  if (cachedConfig === null) {
118
122
  // Getting the default config's from framework
119
123
  const uatConfig = new _Configuration.default(getDefaultConfig());
120
124
  // overriding the application config's from project
125
+ const appConfig = new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)());
121
126
  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));
124
127
  // overriding the user config's from CLI
125
128
  uatConfig.addAll(appConfig);
126
129
  uatConfig.addAll(userArgConfig);
@@ -86,8 +86,7 @@ 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
- const stage = userArgConfig.get("stage");
90
- uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage, mode)));
89
+ uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
91
90
  // overriding the user config's from CLI
92
91
  uatConfig.addAll(userArgConfig);
93
92
  const modules = uatConfig.get('modules');
@@ -96,7 +95,6 @@ function main() {
96
95
  //We need to change this process.env variable to pass the module name in future.
97
96
  process.env.modules = modules;
98
97
  process.env.tearDown = tearDown;
99
- process.env.stage = stage;
100
98
  const {
101
99
  isAuthMode,
102
100
  editionOrder,
@@ -104,7 +102,7 @@ function main() {
104
102
  bddMode = false,
105
103
  headless = false
106
104
  } = uatConfig.getAll();
107
- (0, _envInitializer.initializeEnvConfig)(stage, mode, isAuthMode);
105
+ (0, _envInitializer.initializeEnvConfig)(mode, isAuthMode);
108
106
 
109
107
  //This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
110
108
  const userArgsObject = userArgConfig.getAll();
@@ -4,72 +4,31 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  var _fs = require("fs");
5
5
  var _path = _interopRequireDefault(require("path"));
6
6
  var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
7
- var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
8
7
  jest.mock('fs');
9
- jest.mock('path', () => ({
10
- resolve: jest.fn()
11
- }));
12
- jest.mock("../../../../../core/playwright/helpers/configPathResolver", () => ({
13
- getConfigPath: jest.fn()
14
- }));
8
+ jest.mock('path');
15
9
  const mockCwd = '/mock/current/directory';
16
10
  _path.default.resolve = jest.fn();
17
11
  process.cwd = jest.fn(() => mockCwd);
18
12
  describe('getUATFileName', () => {
19
13
  beforeEach(() => {
20
14
  jest.clearAllMocks();
21
- _path.default.resolve.mockImplementation((...segments) => segments.join('/'));
22
15
  });
23
- test('should return pipeline-matched config path when file exists', () => {
24
- const stage = 'uat';
16
+ test('return the pipeline matched config files for pipeline matched files exists', () => {
25
17
  const mode = 'cd';
26
- _configPathResolver.getConfigPath.mockReturnValue(`${stage}/conf`);
27
- _fs.existsSync.mockReturnValue(true);
28
- const expected = `${process.cwd()}/${stage}/conf/${mode}/uat.config.js`;
29
- const result = (0, _configFileNameProvider.getUATFileName)(stage, mode);
30
- expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith(stage);
31
- expect(_fs.existsSync).toHaveBeenCalledWith(expected);
32
- expect(result).toBe(expected);
33
- });
34
- test('should use default stage and mode when not provided', () => {
35
- const mode = 'dev';
36
- const stageConfigPath = 'uat/conf';
37
- const expectedPath = `${mockCwd}/${stageConfigPath}/${mode}/uat.config.js`;
18
+ const mockPath = `${mockCwd}/uat/conf/${mode}/uat.config.js`;
38
19
  _fs.existsSync.mockReturnValue(true);
20
+ _path.default.resolve.mockImplementation((...args) => args.join('/'));
39
21
  const result = (0, _configFileNameProvider.getUATFileName)(mode);
40
- expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
41
- expect(result).toBe(expectedPath);
42
- });
43
- test('should return the default config files for pipeline matched files not exists', () => {
44
- const mockStage = 'uat';
45
- const mockMode = 'ci';
46
- const stageConfigPath = 'uat/conf';
47
- const nonExistingPath = `${mockCwd}/${stageConfigPath}/${mockMode}/uat.config.js`;
48
- const expectedDefaultPath = `${mockCwd}/${mockStage}/conf/default/uat.config.js`;
49
- _configPathResolver.getConfigPath.mockReturnValue(stageConfigPath);
50
- _fs.existsSync.mockReturnValue(false);
51
- const result = (0, _configFileNameProvider.getUATFileName)(mockStage, mockMode);
52
- expect(_fs.existsSync).toHaveBeenCalledWith(nonExistingPath);
53
- expect(result).toBe(expectedDefaultPath);
54
- });
55
- });
56
- describe('getEnvConfigFilePath', () => {
57
- beforeEach(() => {
58
- jest.clearAllMocks();
59
- _path.default.resolve.mockImplementation((...segments) => segments.join('/'));
60
- });
61
- test('should return conf file path when file exists', () => {
62
- _configPathResolver.getConfigPath.mockReturnValue('uat/conf');
63
- _fs.existsSync.mockReturnValue(true);
64
- const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'cd');
65
- expect(_configPathResolver.getConfigPath).toHaveBeenCalledWith('uat');
66
- expect(_fs.existsSync).toHaveBeenCalled();
67
- expect(result).toBe('uat/conf/cd/settings.json');
22
+ expect(_fs.existsSync).toHaveBeenCalledWith(mockPath);
23
+ expect(result).toBe(mockPath);
68
24
  });
69
- test('should return default path when file does not exist', () => {
70
- _configPathResolver.getConfigPath.mockReturnValue('uat/conf');
25
+ test('return the default config files for pipeline matched files not exists', () => {
26
+ const mode = 'ci';
27
+ const defaultPath = `${mockCwd}/uat/conf/default/uat.config.js`;
71
28
  _fs.existsSync.mockReturnValue(false);
72
- const result = (0, _configFileNameProvider.getEnvConfigFilePath)('uat', 'ci');
73
- expect(result).toBe('uat/conf/default/settings.json');
29
+ _path.default.resolve.mockImplementation((...args) => args.join('/'));
30
+ const result = (0, _configFileNameProvider.getUATFileName)(mode);
31
+ expect(_fs.existsSync).toHaveBeenCalledWith(`${mockCwd}/uat/conf/${mode}/uat.config.js`);
32
+ expect(result).toBe(defaultPath);
74
33
  });
75
34
  });
@@ -1,83 +1,80 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _fs = _interopRequireDefault(require("fs"));
4
+ var _fs = require("fs");
5
5
  var _path = _interopRequireDefault(require("path"));
6
- var _getUsers = require("../../../../../core/playwright/helpers/auth/getUsers");
7
- var _configPathResolver = require("../../../../../core/playwright/helpers/configPathResolver");
8
6
  jest.mock('fs');
9
7
  jest.mock('path');
10
- jest.mock('../../../../../core/playwright/helpers/configPathResolver', () => ({
11
- getConfigPath: jest.fn()
8
+ jest.mock('../../../../../core/playwright/readConfigFile', () => ({
9
+ generateConfigFromFile: jest.fn(() => ({
10
+ uatDirectory: '/test/directory'
11
+ })),
12
+ getRunMode: jest.fn(() => 'dev')
12
13
  }));
14
+ const {
15
+ getListOfActors
16
+ } = require('../../../../../core/playwright/helpers/auth/getUsers');
13
17
  describe('getListOfActors', () => {
14
- const stageConfig = 'uat/conf';
15
- const mode = 'dev';
16
- const stage = 'uat';
17
18
  beforeEach(() => {
18
19
  jest.clearAllMocks();
19
20
  _path.default.join.mockImplementation((...args) => args.join('/'));
20
- _path.default.resolve.mockImplementation((...args) => args.join('/'));
21
- _configPathResolver.getConfigPath.mockReturnValue('uat/conf');
22
21
  });
23
22
  test('throws an error when config file cannot be loaded', () => {
24
- _fs.default.existsSync.mockReturnValueOnce(true);
25
- jest.mock('/uat/conf/dev/actors/index.js', () => {
23
+ _fs.existsSync.mockReturnValueOnce(true); // Main config file exists
24
+
25
+ jest.mock('/test/directory/conf/dev/actors/index.js', () => {
26
26
  throw new Error('Loading error');
27
27
  }, {
28
28
  virtual: true
29
29
  });
30
- expect(() => (0, _getUsers.getListOfActors)()).toThrow(`Error loading actor configuration from ${_path.default.join(_path.default.resolve(process.cwd(), 'uat/conf/dev/actors/index.js'))}`);
30
+ expect(() => getListOfActors()).toThrow('Error loading actor configuration from /test/directory/conf/dev/actors/index.js');
31
31
  });
32
32
  test('throws an error when beta feature config does not exist', () => {
33
- _fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
33
+ _fs.existsSync.mockReturnValueOnce(true) // Main config file exists
34
34
  .mockReturnValueOnce(false); // Beta feature config does not exist in either path
35
35
 
36
36
  const betaFeature = 'nonExistentFeature';
37
- expect(() => (0, _getUsers.getListOfActors)(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
37
+ expect(() => getListOfActors(betaFeature)).toThrow(`There is no beta feature configured with the name "${betaFeature}"`);
38
38
  });
39
- test('loads main configuration when betaFeature is not provided and main config exists', () => {
40
- _fs.default.existsSync.mockReturnValueOnce(true);
41
- const file = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/index.js`));
42
- jest.doMock(file, () => ({
39
+ test('loads main configuration when betaFeature is not provided and main config file exists', () => {
40
+ _fs.existsSync.mockReturnValueOnce(true);
41
+ jest.doMock('/test/directory/conf/dev/actors/index.js', () => ({
43
42
  actors: []
44
43
  }), {
45
44
  virtual: true
46
45
  });
47
- const result = (0, _getUsers.getListOfActors)();
46
+ const result = getListOfActors();
48
47
  expect(result).toEqual({
49
48
  actors: []
50
49
  });
51
50
  });
52
51
  test('falls back to default configuration if main config file does not exist', () => {
53
- _fs.default.existsSync.mockReturnValueOnce(false) // Main config file missing
54
- .mockReturnValueOnce(true); // Beta feature config exists
55
-
56
- const defaultConfigFile = _path.default.join(_path.default.resolve(process.cwd(), `${stage}/conf/default/actors/index.js`));
57
- jest.doMock(defaultConfigFile, () => ({
52
+ _fs.existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
53
+ jest.doMock('/test/directory/conf/default/actors/index.js', () => ({
58
54
  actors: []
59
55
  }), {
60
56
  virtual: true
61
57
  });
62
- const result = (0, _getUsers.getListOfActors)();
58
+ const result = getListOfActors();
63
59
  expect(result).toEqual({
64
60
  actors: []
65
61
  });
66
62
  });
67
63
  test('loads beta feature configuration when betaFeature is provided', () => {
68
- _fs.default.existsSync.mockReturnValueOnce(true) // Main config file exists
64
+ _fs.existsSync.mockReturnValueOnce(true) // Main config file exists
69
65
  .mockReturnValueOnce(true); // Beta feature config exists
70
66
 
71
67
  const betaFeature = 'parentchild';
72
- const betaFeaturePath = _path.default.join(_path.default.resolve(process.cwd(), `${stageConfig}/${mode}/actors/beta/${betaFeature}/index.js`));
68
+ const betaFeaturePath = `/test/directory/conf/dev/actors/beta/${betaFeature}/index.js`;
73
69
  jest.doMock(betaFeaturePath, () => ({
74
70
  betaActors: []
75
71
  }), {
76
72
  virtual: true
77
73
  });
78
- const result = (0, _getUsers.getListOfActors)(betaFeature);
74
+ const result = getListOfActors(betaFeature);
79
75
  expect(result).toEqual({
80
76
  betaActors: []
81
77
  });
78
+ expect(_path.default.join).toHaveBeenCalledWith('/test/directory', `conf/dev/actors/beta/${betaFeature}/index.js`);
82
79
  });
83
80
  });