@zohodesk/testinglibrary 0.4.2-experimental → 0.4.3-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 +10 -14
- package/build/core/playwright/configuration/Configuration.js +0 -3
- package/build/core/playwright/configuration/ConfigurationHelper.js +9 -2
- package/build/core/playwright/env-initializer.js +1 -0
- package/build/core/playwright/helpers/auth/getUsers.js +11 -23
- package/build/core/playwright/helpers/configFileNameProvider.js +3 -9
- package/build/core/playwright/readConfigFile.js +22 -22
- package/build/core/playwright/setup/config-creator.js +5 -6
- package/build/core/playwright/test-runner.js +4 -6
- package/build/lib/cli.js +0 -6
- package/build/setup-folder-structure/samples/auth-setup-sample.js +66 -14
- package/build/setup-folder-structure/samples/authUsers-sample.json +9 -0
- package/build/setup-folder-structure/samples/env-config-sample.json +21 -0
- package/build/setup-folder-structure/setupProject.js +5 -18
- package/build/utils/cliArgsToObject.js +0 -3
- package/jest.config.js +8 -8
- package/npm-shrinkwrap.json +30 -29
- package/package.json +1 -1
- package/playwright.config.js +1 -1
- package/.gitlab-ci.yml +0 -44
- package/build/core/playwright/validateFeature.js +0 -58
- package/build/setup-folder-structure/samples/actors-index.js +0 -3
- package/build/setup-folder-structure/samples/editions-index.js +0 -3
- package/build/setup-folder-structure/samples/free-sample.json +0 -25
- package/build/setup-folder-structure/samples/settings.json +0 -7
- package/build/test/core/playwright/__tests__/validateFeature.test.js +0 -64
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +0 -34
package/README.md
CHANGED
|
@@ -29,27 +29,23 @@
|
|
|
29
29
|
|
|
30
30
|
## Version History
|
|
31
31
|
|
|
32
|
-
### v0.2.9 -
|
|
33
|
-
|
|
34
|
-
#### Feature
|
|
35
|
-
- Added support for scenario level tag support
|
|
36
|
-
- Added a new cli optin like uat-validate to validate the feature files using playwright-bdd
|
|
37
|
-
- Mode based configuration implementations
|
|
38
|
-
- @only option enabled in dev pipeline
|
|
39
|
-
- Latest setup related configuration changed for init option
|
|
40
|
-
|
|
41
|
-
### v0.3.0 - 25-10-2024
|
|
32
|
+
### v0.2.9 - 30-09-2024
|
|
42
33
|
|
|
43
34
|
#### Features
|
|
44
35
|
- Added support for scenario level tag support
|
|
45
36
|
- Updated the configuration for `video` and `trace` to accept Playwright-specific values instead of boolean values.
|
|
46
37
|
- Below package versions are updated in this release.
|
|
47
|
-
- playwright - 1.
|
|
48
|
-
- playwright-bdd - 7.
|
|
49
|
-
- @playwright/test - 1.
|
|
38
|
+
- playwright - 1.47.2,
|
|
39
|
+
- playwright-bdd - 7.4.2,
|
|
40
|
+
- @playwright/test - 1.47.2,
|
|
50
41
|
- @cucumber/cucumber - 11.0.1
|
|
51
42
|
- From this version, We adopt the playwright-bdd as library instead of modified source
|
|
52
43
|
|
|
53
44
|
#### Deprecations
|
|
54
45
|
- **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
|
|
55
|
-
- **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
|
|
46
|
+
- **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
|
|
47
|
+
|
|
48
|
+
### v0.2.9 - 08-10-2024
|
|
49
|
+
|
|
50
|
+
#### Feature
|
|
51
|
+
- Added support for scenario level tag support
|
|
@@ -12,9 +12,16 @@ var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
|
12
12
|
var _mergeObjects = require("../helpers/mergeObjects");
|
|
13
13
|
var _fs = require("fs");
|
|
14
14
|
const Configuration = require("./Configuration");
|
|
15
|
+
function checkForDeprecatedKeys(configKey) {
|
|
16
|
+
let deprecatedConfigInUatConfigFile = ['mode'];
|
|
17
|
+
if (deprecatedConfigInUatConfigFile.includes(configKey)) {
|
|
18
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key ${configKey} is deprecated. Please use other options`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
function combineConfiguration(defaultConfig, userConfiguration) {
|
|
16
22
|
let configurationObj = {};
|
|
17
23
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
24
|
+
checkForDeprecatedKeys(configKey);
|
|
18
25
|
let configValue = userConfiguration[configKey];
|
|
19
26
|
if (configValue !== null && configValue !== undefined) {
|
|
20
27
|
configurationObj[configKey] = configValue;
|
|
@@ -26,10 +33,10 @@ function combineConfiguration(defaultConfig, userConfiguration) {
|
|
|
26
33
|
});
|
|
27
34
|
return (0, _mergeObjects.mergeObjects)(defaultConfig, configurationObj);
|
|
28
35
|
}
|
|
29
|
-
function getApplicationConfig(
|
|
36
|
+
function getApplicationConfig() {
|
|
30
37
|
let filePath = "";
|
|
31
38
|
try {
|
|
32
|
-
filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)(
|
|
39
|
+
filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
33
40
|
if (!(0, _fs.existsSync)(filePath)) {
|
|
34
41
|
throw new Error("Exception while getting the uat file from the application - " + filePath);
|
|
35
42
|
}
|
|
@@ -10,6 +10,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _configFileNameProvider = require("./helpers/configFileNameProvider");
|
|
11
11
|
var _logger = require("../../utils/logger");
|
|
12
12
|
var _getUsers = require("./helpers/auth/getUsers");
|
|
13
|
+
var _readConfigFile = require("./readConfigFile");
|
|
13
14
|
function setEnvironmentVariables(configJSON) {
|
|
14
15
|
for (const key in configJSON) {
|
|
15
16
|
process.env[key] = configJSON[key];
|
|
@@ -33,17 +33,12 @@ function getDefaultActorConf() {
|
|
|
33
33
|
const {
|
|
34
34
|
uatDirectory
|
|
35
35
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
36
|
-
const
|
|
37
|
-
const filePath = _path.default.join(uatDirectory,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const defaultSettingsFile = _path.default.join(uatDirectory, `conf/default/settings.json`);
|
|
41
|
-
return require(defaultSettingsFile);
|
|
42
|
-
}
|
|
43
|
-
return require(filePath);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw new Error(`${defaultSettingFile} ${filePath} both files are missing.`);
|
|
36
|
+
const defaultSettingFile = `conf/${getRunMode()}/settings.json`;
|
|
37
|
+
const filePath = _path.default.join(uatDirectory, defaultSettingFile);
|
|
38
|
+
if (!(0, _fs.existsSync)(filePath)) {
|
|
39
|
+
throw new Error(`${defaultSettingFile} is missing.`);
|
|
46
40
|
}
|
|
41
|
+
return require(filePath);
|
|
47
42
|
}
|
|
48
43
|
function getDefaultActor() {
|
|
49
44
|
const {
|
|
@@ -57,25 +52,18 @@ function getListOfActors() {
|
|
|
57
52
|
uatDirectory
|
|
58
53
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
59
54
|
const mode = getRunMode();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
return require(configFile);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
throw new Error(`Error loading actor configuration from ${configFile}`);
|
|
55
|
+
const configFile = `conf/${mode}/actors/index`;
|
|
56
|
+
const filePath = _path.default.join(uatDirectory, configFile);
|
|
57
|
+
if (!(0, _fs.existsSync)(filePath + '.js')) {
|
|
58
|
+
throw new Error(`${configFile}.js is missing.`);
|
|
68
59
|
}
|
|
60
|
+
return require(filePath);
|
|
69
61
|
}
|
|
70
62
|
function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile, betaFeature, testDataPortal = null) {
|
|
71
|
-
const actorsData = getListOfActors();
|
|
72
|
-
if (!actorsData || !actorsData.editions) {
|
|
73
|
-
throw new Error("The actors data is missing.");
|
|
74
|
-
}
|
|
75
63
|
const {
|
|
76
64
|
editions: userdata,
|
|
77
65
|
beta: betaPortals
|
|
78
|
-
} =
|
|
66
|
+
} = getListOfActors();
|
|
79
67
|
const defaultConf = getDefaultActorConf();
|
|
80
68
|
const edition = preferedEdition || defaultConf.edition;
|
|
81
69
|
const profile = preferredProfile || defaultConf.profile;
|
|
@@ -9,14 +9,8 @@ exports.getReportFileName = getReportFileName;
|
|
|
9
9
|
exports.getUATFileName = getUATFileName;
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
mode = mode || (0, _auth.getRunMode)();
|
|
15
|
-
const uatConfFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/uat.config.js`);
|
|
16
|
-
if (_fs.default.existsSync(uatConfFilePath)) {
|
|
17
|
-
return uatConfFilePath;
|
|
18
|
-
}
|
|
19
|
-
return _path.default.resolve(process.cwd(), `uat.config.js`);
|
|
12
|
+
function getUATFileName() {
|
|
13
|
+
return 'uat.config.js';
|
|
20
14
|
}
|
|
21
15
|
function getEnvConfigFilePath(mode) {
|
|
22
16
|
const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
|
|
@@ -24,7 +18,7 @@ function getEnvConfigFilePath(mode) {
|
|
|
24
18
|
if (_fs.default.existsSync(confFilePath)) {
|
|
25
19
|
return `uat/conf/${mode}/settings.json`;
|
|
26
20
|
}
|
|
27
|
-
return `uat/
|
|
21
|
+
return `uat/env-config.json`;
|
|
28
22
|
}
|
|
29
23
|
function getReportFileName() {
|
|
30
24
|
return `test-summary.json`;
|
|
@@ -13,17 +13,13 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
var _configFileNameProvider = require("./helpers/configFileNameProvider");
|
|
15
15
|
var _mergeObjects = require("./helpers/mergeObjects");
|
|
16
|
-
var _Configuration =
|
|
17
|
-
var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
|
|
18
|
-
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
16
|
+
var _Configuration = require("./configuration/Configuration");
|
|
19
17
|
let cachedConfig = null;
|
|
20
18
|
function getDefaultConfig() {
|
|
21
19
|
return {
|
|
22
20
|
uatDirectory: _path.default.join(process.cwd(), 'uat'),
|
|
23
21
|
headless: false,
|
|
24
22
|
browsers: ['Chrome'],
|
|
25
|
-
forbidOnly: false,
|
|
26
|
-
retries: 0,
|
|
27
23
|
trace: false,
|
|
28
24
|
video: false,
|
|
29
25
|
isAuthMode: false,
|
|
@@ -38,18 +34,26 @@ function getDefaultConfig() {
|
|
|
38
34
|
height: 720
|
|
39
35
|
},
|
|
40
36
|
debug: false,
|
|
41
|
-
|
|
37
|
+
mode: process.env.mode || 'dev',
|
|
42
38
|
additionalPages: {},
|
|
43
39
|
featureFilesFolder: 'feature-files',
|
|
44
40
|
stepDefinitionsFolder: 'steps',
|
|
41
|
+
testIdAttribute: 'data-testid',
|
|
45
42
|
testSetup: {},
|
|
46
43
|
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
47
44
|
};
|
|
48
45
|
}
|
|
46
|
+
function checkForDeprecatedKeys(configKey) {
|
|
47
|
+
let deprecatedConfigInUatConfigFile = ['mode'];
|
|
48
|
+
if (deprecatedConfigInUatConfigFile.includes(configKey)) {
|
|
49
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key ${configKey} is deprecated. Please use other options`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
49
52
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
50
53
|
let defaultConfig = getDefaultConfig();
|
|
51
54
|
let configurationObj = {};
|
|
52
55
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
56
|
+
checkForDeprecatedKeys(configKey);
|
|
53
57
|
let configValue = userConfiguration[configKey];
|
|
54
58
|
if (configValue !== null && configValue !== undefined) {
|
|
55
59
|
configurationObj[configKey] = configValue;
|
|
@@ -108,26 +112,22 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
108
112
|
*
|
|
109
113
|
* @returns {UserConfig}
|
|
110
114
|
*/
|
|
111
|
-
|
|
112
|
-
function getConfigFilePath() {
|
|
113
|
-
return _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
114
|
-
}
|
|
115
115
|
function generateConfigFromFile() {
|
|
116
|
-
if (cachedConfig
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
if (cachedConfig !== null) {
|
|
117
|
+
return cachedConfig; // If cached, return the cached configuration
|
|
118
|
+
}
|
|
119
|
+
const filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
120
|
+
if ((0, _fs.existsSync)(filePath)) {
|
|
121
|
+
/** @type {UserConfig} */
|
|
122
|
+
const config = require(filePath);
|
|
123
|
+
const modifiedConfiguration = combineDefaultConfigWithUserConfig(config);
|
|
124
|
+
cachedConfig = modifiedConfiguration;
|
|
125
|
+
return modifiedConfiguration;
|
|
126
126
|
}
|
|
127
|
-
return
|
|
127
|
+
return {};
|
|
128
128
|
}
|
|
129
129
|
function isUserConfigFileAvailable() {
|
|
130
|
-
const filePath =
|
|
130
|
+
const filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
131
131
|
if ((0, _fs.existsSync)(filePath)) {
|
|
132
132
|
return true;
|
|
133
133
|
}
|
|
@@ -9,7 +9,6 @@ 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
|
-
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
13
12
|
const {
|
|
14
13
|
browsers,
|
|
15
14
|
trace,
|
|
@@ -26,7 +25,7 @@ const {
|
|
|
26
25
|
stepDefinitionsFolder,
|
|
27
26
|
testIdAttribute,
|
|
28
27
|
globalTimeout
|
|
29
|
-
} =
|
|
28
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
30
29
|
const projects = (0, _configUtils.getProjects)({
|
|
31
30
|
browsers,
|
|
32
31
|
isAuthMode,
|
|
@@ -52,11 +51,13 @@ const use = {
|
|
|
52
51
|
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
53
52
|
*/
|
|
54
53
|
function getPlaywrightConfig() {
|
|
55
|
-
|
|
54
|
+
return {
|
|
56
55
|
testDir,
|
|
57
56
|
globalTimeout: globalTimeout || 3600000,
|
|
58
57
|
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
59
58
|
fullyParallel: true,
|
|
59
|
+
forbidOnly: !!process.env.CI,
|
|
60
|
+
retries: process.env.CI ? 2 : 0,
|
|
60
61
|
reporter: [['html', {
|
|
61
62
|
outputFolder: reportPath,
|
|
62
63
|
open: openReportOn
|
|
@@ -75,9 +76,7 @@ function getPlaywrightConfig() {
|
|
|
75
76
|
name: 'cleanup',
|
|
76
77
|
testMatch: /.*\.teardown\.js/,
|
|
77
78
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
78
|
-
}, ...projects] : [...projects]
|
|
79
|
-
...uatConfig
|
|
79
|
+
}, ...projects] : [...projects]
|
|
80
80
|
};
|
|
81
|
-
return playwrightConfig;
|
|
82
81
|
}
|
|
83
82
|
var _default = exports.default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
exports.runPreprocessing = runPreprocessing;
|
|
9
8
|
var _child_process = require("child_process");
|
|
10
9
|
var _path = _interopRequireDefault(require("path"));
|
|
11
10
|
var _customCommands = require("./custom-commands");
|
|
@@ -58,7 +57,7 @@ function runPreprocessing(tagArgs, configPath) {
|
|
|
58
57
|
});
|
|
59
58
|
childProcessForPreprocessing.on('error', data => {
|
|
60
59
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
61
|
-
reject(
|
|
60
|
+
reject();
|
|
62
61
|
});
|
|
63
62
|
childProcessForPreprocessing.on('exit', code => {
|
|
64
63
|
if (code === 0) {
|
|
@@ -104,16 +103,15 @@ function main() {
|
|
|
104
103
|
const uatConfig = new _Configuration.default((0, _readConfigFile.getDefaultConfig)());
|
|
105
104
|
|
|
106
105
|
// overriding the application config's from project
|
|
107
|
-
|
|
108
|
-
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
109
|
-
const mode = userArgConfig.get("mode");
|
|
110
|
-
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(mode)));
|
|
106
|
+
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)()));
|
|
111
107
|
|
|
112
108
|
// overriding the user config's from CLI
|
|
109
|
+
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
113
110
|
uatConfig.addAll(userArgConfig);
|
|
114
111
|
const {
|
|
115
112
|
isAuthMode,
|
|
116
113
|
editionOrder,
|
|
114
|
+
mode,
|
|
117
115
|
debug,
|
|
118
116
|
bddMode = false,
|
|
119
117
|
headless = false
|
package/build/lib/cli.js
CHANGED
|
@@ -10,7 +10,6 @@ var _parser = require("../parser/parser");
|
|
|
10
10
|
var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
|
|
11
11
|
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
12
12
|
var _parseUserArgs = _interopRequireDefault(require("../core/playwright/helpers/parseUserArgs"));
|
|
13
|
-
var _validateFeature = _interopRequireDefault(require("../core/playwright/validateFeature"));
|
|
14
13
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
15
14
|
|
|
16
15
|
const [,, option, ...otherOptions] = process.argv;
|
|
@@ -22,11 +21,6 @@ switch (option) {
|
|
|
22
21
|
//createJestRunner();
|
|
23
22
|
break;
|
|
24
23
|
}
|
|
25
|
-
case 'validate':
|
|
26
|
-
{
|
|
27
|
-
(0, _validateFeature.default)();
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
24
|
case 're-run-failed':
|
|
31
25
|
{
|
|
32
26
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Failed Tests..');
|
|
@@ -1,21 +1,73 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { test as setup, expect } from '@zohodesk/testinglibrary';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from '
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
import { getAuthFileDirectory } from '../../core/playwright';
|
|
6
|
+
import { Logger } from '../../utils/logger';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const userdata = require('./authUsers.json');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const authContent = { cookies: [] };
|
|
11
|
+
|
|
12
|
+
const LOGIN_ERR_MESSAGE = 'Need go be logged in';
|
|
13
|
+
// const AUTH_ERR_MESSAGE = `Founded Path - ${path.resolve(process.cwd(),'uat','playwright','.auth')} \n Find if file is Properly Created. Cookies Cannot Be Read .. `
|
|
14
|
+
|
|
15
|
+
function convertCookiesToParse(cookies, authFilePath) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(cookies);
|
|
18
|
+
} catch (err) {
|
|
19
|
+
Logger.error(err);
|
|
20
|
+
throw new Error(
|
|
21
|
+
` Error while parsing cookies ${err} \n${path.resolve(
|
|
22
|
+
process.cwd(),
|
|
23
|
+
authFilePath
|
|
24
|
+
)} File is Empty`
|
|
25
|
+
);
|
|
26
|
+
// process.exit()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const authDirectory = getAuthFileDirectory(); //path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
|
|
30
|
+
if (!existsSync(authDirectory)) {
|
|
31
|
+
console.log('Creating auth directory for the first time setup...');
|
|
32
|
+
mkdirSync(authDirectory, { recursive: true });
|
|
14
33
|
}
|
|
15
34
|
|
|
16
|
-
|
|
35
|
+
userdata.forEach(data => {
|
|
36
|
+
const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
|
|
37
|
+
if (!existsSync(authFile)) {
|
|
38
|
+
console.log('creating auth file..');
|
|
39
|
+
writeFileSync(authFile, JSON.stringify(authContent, null, 2));
|
|
40
|
+
}
|
|
41
|
+
setup(data.description, async ({ page }) => {
|
|
42
|
+
try {
|
|
43
|
+
const cookies = readFileSync(authFile);
|
|
44
|
+
const parsedCookies = convertCookiesToParse(cookies, authFile);
|
|
45
|
+
await page
|
|
46
|
+
.context()
|
|
47
|
+
.addCookies(
|
|
48
|
+
parsedCookies.cookies === undefined ? [] : parsedCookies.cookies
|
|
49
|
+
);
|
|
50
|
+
await page.goto(page.getBaseUrl());
|
|
51
|
+
await page.waitForLoadState();
|
|
52
|
+
if (await page.url().includes(process.env.domain)) {
|
|
53
|
+
await page.waitForSelector(data.locator);
|
|
54
|
+
} else {
|
|
55
|
+
throw new Error(LOGIN_ERR_MESSAGE);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
if (err.message === LOGIN_ERR_MESSAGE) {
|
|
59
|
+
await expect(page.locator('.load-bg')).toBeHidden();
|
|
60
|
+
await page.locator('#login_id').type(data.useremail);
|
|
61
|
+
await page.locator('#nextbtn').click();
|
|
62
|
+
await page.locator('#password').type(data.password);
|
|
63
|
+
await page.locator('#nextbtn').click();
|
|
64
|
+
|
|
65
|
+
await page.waitForLoadState('networkidle');
|
|
66
|
+
|
|
67
|
+
await page.waitForSelector(data.locator);
|
|
17
68
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
69
|
+
await page.context().storageState({ path: authFile });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dev": {
|
|
3
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
4
|
+
"orgName": "org-name",
|
|
5
|
+
"deptName": "dept-name",
|
|
6
|
+
"moduleName": "module-name",
|
|
7
|
+
"devURL": "Provide your devURL here"
|
|
8
|
+
},
|
|
9
|
+
"prod": {
|
|
10
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
11
|
+
"orgName": "org-name",
|
|
12
|
+
"deptName": "dept-name",
|
|
13
|
+
"moduleName": "module-name"
|
|
14
|
+
},
|
|
15
|
+
"k8test": {
|
|
16
|
+
"domain": "https://desk.localzoho.com/agent",
|
|
17
|
+
"orgName": "org-name",
|
|
18
|
+
"deptName": "dept-name",
|
|
19
|
+
"moduleName": "module-name"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -10,9 +10,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _logger = require("../utils/logger");
|
|
11
11
|
function getScriptsToBeAdded() {
|
|
12
12
|
return {
|
|
13
|
-
"uat": "ZDTestingFramework test --mode=
|
|
14
|
-
"uat-debug": "ZDTestingFramework test --mode=
|
|
15
|
-
"uat-validate": "ZDTestingFramework validate",
|
|
13
|
+
"uat": "ZDTestingFramework test --mode=prod --headed",
|
|
14
|
+
"uat-debug": "ZDTestingFramework test --mode=prod --debug",
|
|
16
15
|
"uat-report": "ZDTestingFramework report --port=9009",
|
|
17
16
|
"codegen": "ZDTestingFramework codegen deskclientapp.localzoho.com/agent"
|
|
18
17
|
};
|
|
@@ -72,6 +71,7 @@ function createAuthenticationFile() {
|
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
73
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
|
|
74
|
+
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'authUsers.json'), getSetupFileAsString('authUsers-sample.json'), null, 2);
|
|
75
75
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
76
76
|
} catch (err) {
|
|
77
77
|
_logger.Logger.error(err);
|
|
@@ -84,21 +84,8 @@ function createAuthenticationFile() {
|
|
|
84
84
|
function createConfigJson() {
|
|
85
85
|
const uatFolder = _path.default.resolve(process.cwd(), 'uat');
|
|
86
86
|
if ((0, _fs.existsSync)(uatFolder)) {
|
|
87
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating
|
|
88
|
-
|
|
89
|
-
(0, _fs.mkdirSync)(_path.default.resolve(uatFolder, 'conf', 'default'), {
|
|
90
|
-
recursive: true
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', './settings.json'), getSetupFileAsString('settings.json'), null, 2);
|
|
94
|
-
if (!(0, _fs.existsSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions'))) {
|
|
95
|
-
(0, _fs.mkdirSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions'), {
|
|
96
|
-
recursive: true
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions', 'free.json'), getSetupFileAsString('free-sample.json'), null, 2);
|
|
100
|
-
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'editions', 'index.js'), getSetupFileAsString('editions-index.js'), null, 2);
|
|
101
|
-
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, 'conf', 'default', 'actors', 'index.js'), getSetupFileAsString('actors-index.js'), null, 2);
|
|
87
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating env-config file inside UAT Folder');
|
|
88
|
+
(0, _fs.writeFileSync)(_path.default.resolve(uatFolder, './env-config.json'), getSetupFileAsString('env-config-sample.json'), null, 2);
|
|
102
89
|
} else {
|
|
103
90
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Something went wrong. Please re-initialize the @zohodesk/testinglibrary');
|
|
104
91
|
}
|
package/jest.config.js
CHANGED
|
@@ -56,14 +56,14 @@ module.exports = {
|
|
|
56
56
|
collectCoverageFrom: ['src/**/*.js'],
|
|
57
57
|
coverageDirectory: './build/cov',
|
|
58
58
|
coverageReporters: ['lcov', 'json', 'html', 'json-summary', 'text'],
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
coverageThreshold: {
|
|
60
|
+
global: {
|
|
61
|
+
branches: 100,
|
|
62
|
+
functions: 100,
|
|
63
|
+
lines: 100,
|
|
64
|
+
statements: 100
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
67
|
globals: {
|
|
68
68
|
__DEVELOPMENT__: true,
|
|
69
69
|
__DOCS__: false,
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.3-experimental",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@zohodesk/testinglibrary",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.4.3-experimental",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@babel/preset-react": "7.22.5",
|
|
14
14
|
"@cucumber/cucumber": "11.0.1",
|
|
15
|
-
"@playwright/test": "1.
|
|
15
|
+
"@playwright/test": "1.48.0",
|
|
16
16
|
"@testing-library/jest-dom": "5.11.9",
|
|
17
17
|
"@testing-library/react": "11.2.7",
|
|
18
18
|
"@testing-library/react-hooks": "7.0.2",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"jest": "29.6.2",
|
|
23
23
|
"jest-environment-jsdom": "29.6.2",
|
|
24
24
|
"msw": "1.2.3",
|
|
25
|
-
"playwright": "1.
|
|
26
|
-
"playwright-bdd": "7.
|
|
25
|
+
"playwright": "1.48.0",
|
|
26
|
+
"playwright-bdd": "7.5.0",
|
|
27
27
|
"supports-color": "8.1.1"
|
|
28
28
|
},
|
|
29
29
|
"bin": {
|
|
@@ -37,8 +37,7 @@
|
|
|
37
37
|
"@babel/polyfill": "7.12.1",
|
|
38
38
|
"@babel/preset-env": "7.22.15",
|
|
39
39
|
"@babel/runtime": "7.22.15",
|
|
40
|
-
"commander": "^11.0.0"
|
|
41
|
-
"typescript": "^5.4.2"
|
|
40
|
+
"commander": "^11.0.0"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"eslint": "*",
|
|
@@ -3271,11 +3270,11 @@
|
|
|
3271
3270
|
}
|
|
3272
3271
|
},
|
|
3273
3272
|
"node_modules/@playwright/test": {
|
|
3274
|
-
"version": "1.
|
|
3275
|
-
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.
|
|
3276
|
-
"integrity": "sha512-
|
|
3273
|
+
"version": "1.48.0",
|
|
3274
|
+
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.48.0.tgz",
|
|
3275
|
+
"integrity": "sha512-W5lhqPUVPqhtc/ySvZI5Q8X2ztBOUgZ8LbAFy0JQgrXZs2xaILrUcNO3rQjwbLPfGK13+rZsDa1FpG+tqYkT5w==",
|
|
3277
3276
|
"dependencies": {
|
|
3278
|
-
"playwright": "1.
|
|
3277
|
+
"playwright": "1.48.0"
|
|
3279
3278
|
},
|
|
3280
3279
|
"bin": {
|
|
3281
3280
|
"playwright": "cli.js"
|
|
@@ -8310,11 +8309,11 @@
|
|
|
8310
8309
|
}
|
|
8311
8310
|
},
|
|
8312
8311
|
"node_modules/playwright": {
|
|
8313
|
-
"version": "1.
|
|
8314
|
-
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.
|
|
8315
|
-
"integrity": "sha512-
|
|
8312
|
+
"version": "1.48.0",
|
|
8313
|
+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.48.0.tgz",
|
|
8314
|
+
"integrity": "sha512-qPqFaMEHuY/ug8o0uteYJSRfMGFikhUysk8ZvAtfKmUK3kc/6oNl/y3EczF8OFGYIi/Ex2HspMfzYArk6+XQSA==",
|
|
8316
8315
|
"dependencies": {
|
|
8317
|
-
"playwright-core": "1.
|
|
8316
|
+
"playwright-core": "1.48.0"
|
|
8318
8317
|
},
|
|
8319
8318
|
"bin": {
|
|
8320
8319
|
"playwright": "cli.js"
|
|
@@ -8327,20 +8326,21 @@
|
|
|
8327
8326
|
}
|
|
8328
8327
|
},
|
|
8329
8328
|
"node_modules/playwright-bdd": {
|
|
8330
|
-
"version": "7.
|
|
8331
|
-
"resolved": "https://registry.npmjs.org/playwright-bdd/-/playwright-bdd-7.
|
|
8332
|
-
"integrity": "sha512-
|
|
8329
|
+
"version": "7.5.0",
|
|
8330
|
+
"resolved": "https://registry.npmjs.org/playwright-bdd/-/playwright-bdd-7.5.0.tgz",
|
|
8331
|
+
"integrity": "sha512-z6rBqVqlvkaGCR6hS5yuLmNg2dn/AaQlguc96U7Xl2OvHgeiP6wZMU8CEdnp2VYU35qnYSW1xngH0EHI9/ZF2A==",
|
|
8333
8332
|
"dependencies": {
|
|
8334
8333
|
"@cucumber/cucumber-expressions": "17.1.0",
|
|
8335
8334
|
"@cucumber/gherkin": "29.0.0",
|
|
8336
8335
|
"@cucumber/gherkin-streams": "5.0.1",
|
|
8337
8336
|
"@cucumber/gherkin-utils": "9.0.0",
|
|
8338
8337
|
"@cucumber/html-formatter": "21.7.0",
|
|
8339
|
-
"@cucumber/messages": "26.0.
|
|
8338
|
+
"@cucumber/messages": "26.0.1",
|
|
8340
8339
|
"@cucumber/tag-expressions": "6.1.0",
|
|
8341
8340
|
"cli-table3": "0.6.5",
|
|
8342
8341
|
"commander": "12.1.0",
|
|
8343
8342
|
"fast-glob": "^3.3.2",
|
|
8343
|
+
"mime-types": "2.1.35",
|
|
8344
8344
|
"xmlbuilder": "15.1.1"
|
|
8345
8345
|
},
|
|
8346
8346
|
"bin": {
|
|
@@ -8365,9 +8365,9 @@
|
|
|
8365
8365
|
}
|
|
8366
8366
|
},
|
|
8367
8367
|
"node_modules/playwright-bdd/node_modules/@cucumber/messages": {
|
|
8368
|
-
"version": "26.0.
|
|
8369
|
-
"resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-26.0.
|
|
8370
|
-
"integrity": "sha512-
|
|
8368
|
+
"version": "26.0.1",
|
|
8369
|
+
"resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-26.0.1.tgz",
|
|
8370
|
+
"integrity": "sha512-DIxSg+ZGariumO+Lq6bn4kOUIUET83A4umrnWmidjGFl8XxkBieUZtsmNbLYgH/gnsmP07EfxxdTr0hOchV1Sg==",
|
|
8371
8371
|
"dependencies": {
|
|
8372
8372
|
"@types/uuid": "10.0.0",
|
|
8373
8373
|
"class-transformer": "0.5.1",
|
|
@@ -8435,9 +8435,9 @@
|
|
|
8435
8435
|
}
|
|
8436
8436
|
},
|
|
8437
8437
|
"node_modules/playwright-core": {
|
|
8438
|
-
"version": "1.
|
|
8439
|
-
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.
|
|
8440
|
-
"integrity": "sha512-
|
|
8438
|
+
"version": "1.48.0",
|
|
8439
|
+
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.0.tgz",
|
|
8440
|
+
"integrity": "sha512-RBvzjM9rdpP7UUFrQzRwR8L/xR4HyC1QXMzGYTbf1vjw25/ya9NRAVnXi/0fvFopjebvyPzsmoK58xxeEOaVvA==",
|
|
8441
8441
|
"bin": {
|
|
8442
8442
|
"playwright-core": "cli.js"
|
|
8443
8443
|
},
|
|
@@ -9618,10 +9618,11 @@
|
|
|
9618
9618
|
}
|
|
9619
9619
|
},
|
|
9620
9620
|
"node_modules/typescript": {
|
|
9621
|
-
"version": "5.
|
|
9622
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.
|
|
9623
|
-
"integrity": "sha512
|
|
9624
|
-
"
|
|
9621
|
+
"version": "5.1.6",
|
|
9622
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz",
|
|
9623
|
+
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==",
|
|
9624
|
+
"optional": true,
|
|
9625
|
+
"peer": true,
|
|
9625
9626
|
"bin": {
|
|
9626
9627
|
"tsc": "bin/tsc",
|
|
9627
9628
|
"tsserver": "bin/tsserver"
|
package/package.json
CHANGED
package/playwright.config.js
CHANGED
|
@@ -18,7 +18,7 @@ export default defineConfig({
|
|
|
18
18
|
/* Run tests in files in parallel */
|
|
19
19
|
fullyParallel: true,
|
|
20
20
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
21
|
-
|
|
21
|
+
forbidOnly: !!process.env.CI,
|
|
22
22
|
/* Retry on CI only */
|
|
23
23
|
retries: process.env.CI ? 2 : 0,
|
|
24
24
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
package/.gitlab-ci.yml
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
image: node:14.17.3
|
|
2
|
-
|
|
3
|
-
workflow:
|
|
4
|
-
rules:
|
|
5
|
-
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
6
|
-
|
|
7
|
-
stages:
|
|
8
|
-
- build
|
|
9
|
-
- unit
|
|
10
|
-
- uat
|
|
11
|
-
|
|
12
|
-
# Install dependencies stage
|
|
13
|
-
build:
|
|
14
|
-
stage: build
|
|
15
|
-
image: node:14.17.3
|
|
16
|
-
script:
|
|
17
|
-
- npm install
|
|
18
|
-
artifacts:
|
|
19
|
-
paths:
|
|
20
|
-
- node_modules/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# Unit tests stage
|
|
24
|
-
unit:
|
|
25
|
-
stage: unit
|
|
26
|
-
image: node:14.17.3
|
|
27
|
-
script:
|
|
28
|
-
- npm test
|
|
29
|
-
artifacts:
|
|
30
|
-
when: always
|
|
31
|
-
paths:
|
|
32
|
-
- test-reports
|
|
33
|
-
|
|
34
|
-
uat:
|
|
35
|
-
stage: uat
|
|
36
|
-
image: node:14.17.3
|
|
37
|
-
script:
|
|
38
|
-
- cd examples
|
|
39
|
-
- npm i
|
|
40
|
-
- npm run uat
|
|
41
|
-
artifacts:
|
|
42
|
-
when: always
|
|
43
|
-
paths:
|
|
44
|
-
- uat-reports
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _parseUserArgs = _interopRequireDefault(require("./helpers/parseUserArgs"));
|
|
9
|
-
var _readConfigFile = require("./readConfigFile");
|
|
10
|
-
var _tagProcessor = require("./tag-processor");
|
|
11
|
-
var _testRunner = require("./test-runner");
|
|
12
|
-
var _logger = require("../../utils/logger");
|
|
13
|
-
// @cucumber/gherkins need to be includ in package.json
|
|
14
|
-
|
|
15
|
-
// const getFeatureFiles = (dir) => {
|
|
16
|
-
// let featureFiles = [];
|
|
17
|
-
// const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
18
|
-
// files.forEach(file => {
|
|
19
|
-
// const fullPath = path.join(dir, file.name);
|
|
20
|
-
// if (file.isDirectory()) {
|
|
21
|
-
// featureFiles = featureFiles.concat(getFeatureFiles(fullPath));
|
|
22
|
-
// } else if (file.isFile() && fullPath.endsWith('.feature')) {
|
|
23
|
-
// featureFiles.push(fullPath);
|
|
24
|
-
// }
|
|
25
|
-
// });
|
|
26
|
-
// return featureFiles;
|
|
27
|
-
// };
|
|
28
|
-
|
|
29
|
-
//const validateFeatureFiles = () => {
|
|
30
|
-
// const featuresDir = path.join(process.cwd(), 'uat/modules');
|
|
31
|
-
// const parser = new Parser();
|
|
32
|
-
// const featureFiles = getFeatureFiles(featuresDir);
|
|
33
|
-
// featureFiles.forEach( filePath => {
|
|
34
|
-
// const featureFileContent = fs.readFileSync(filePath, 'utf-8');
|
|
35
|
-
// try {
|
|
36
|
-
// parser.parse(featureFileContent);
|
|
37
|
-
// console.log(`${filePath}: Feature file is valid!`);
|
|
38
|
-
// } catch (error) {
|
|
39
|
-
// console.error(`${filePath}: Feature file is invalid - ${error.message}`);
|
|
40
|
-
// }
|
|
41
|
-
// })
|
|
42
|
-
//}
|
|
43
|
-
|
|
44
|
-
const validateFeatureFiles = () => {
|
|
45
|
-
const userArgsObject = (0, _parseUserArgs.default)();
|
|
46
|
-
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
47
|
-
const {
|
|
48
|
-
editionOrder
|
|
49
|
-
} = uatConfig;
|
|
50
|
-
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
51
|
-
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
52
|
-
(0, _testRunner.runPreprocessing)(tagArgs, configPath).then(() => {
|
|
53
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
|
|
54
|
-
}).catch(error => {
|
|
55
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error while validating the feature files - ${error}`);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
var _default = exports.default = validateFeatureFiles;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "1",
|
|
4
|
-
"edition": "free",
|
|
5
|
-
"orgName": "orgFree",
|
|
6
|
-
"profiles": [
|
|
7
|
-
{
|
|
8
|
-
"profile": "admin",
|
|
9
|
-
"email": "admin+free@zohotest.com",
|
|
10
|
-
"password": "password@0987"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"profile": "agent",
|
|
14
|
-
"email": "agent@zohotest.com",
|
|
15
|
-
"password": "password@12345"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"profile": "lightagent",
|
|
19
|
-
"email": "lightagent@zohotest.com",
|
|
20
|
-
"password": "password@12345"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _validateFeature = _interopRequireDefault(require("../../../../core/playwright/validateFeature"));
|
|
5
|
-
var _parseUserArgs = _interopRequireDefault(require("../../../../core/playwright/helpers/parseUserArgs"));
|
|
6
|
-
var _readConfigFile = require("../../../../core/playwright/readConfigFile");
|
|
7
|
-
var _tagProcessor = require("../../../../core/playwright/tag-processor");
|
|
8
|
-
var _testRunner = require("../../../../core/playwright/test-runner");
|
|
9
|
-
var _logger = require("../../../../utils/logger");
|
|
10
|
-
jest.mock('../../../../core/playwright/helpers/parseUserArgs', () => ({
|
|
11
|
-
__esModule: true,
|
|
12
|
-
default: jest.fn()
|
|
13
|
-
}));
|
|
14
|
-
jest.mock('../../../../core/playwright/readConfigFile');
|
|
15
|
-
jest.mock('../../../../core/playwright/tag-processor');
|
|
16
|
-
jest.mock('../../../../core/playwright/test-runner');
|
|
17
|
-
jest.mock('../../../../utils/logger', () => ({
|
|
18
|
-
__esModule: true,
|
|
19
|
-
Logger: {
|
|
20
|
-
log: jest.fn(),
|
|
21
|
-
SUCCESS_TYPE: 'success',
|
|
22
|
-
FAILURE_TYPE: 'failure'
|
|
23
|
-
}
|
|
24
|
-
}));
|
|
25
|
-
describe('validateFeatureFiles', () => {
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
jest.clearAllMocks();
|
|
28
|
-
});
|
|
29
|
-
test('runPreprocessing with correct arguments and log success', async () => {
|
|
30
|
-
const mockUserArgs = {
|
|
31
|
-
mode: 'dev'
|
|
32
|
-
};
|
|
33
|
-
_parseUserArgs.default.mockReturnValue(mockUserArgs);
|
|
34
|
-
const mockConfig = {
|
|
35
|
-
editionOrder: ["beta", "enterprice"]
|
|
36
|
-
};
|
|
37
|
-
_readConfigFile.generateConfigFromFile.mockReturnValue(mockConfig);
|
|
38
|
-
_readConfigFile.isUserConfigFileAvailable.mockReturnValue(true);
|
|
39
|
-
const mockTagArgs = ['@beta_admin'];
|
|
40
|
-
_tagProcessor.tagProcessor.mockReturnValue(mockTagArgs);
|
|
41
|
-
_testRunner.runPreprocessing.mockResolvedValueOnce();
|
|
42
|
-
await (0, _validateFeature.default)();
|
|
43
|
-
expect(_parseUserArgs.default).toHaveBeenCalled();
|
|
44
|
-
expect(_readConfigFile.generateConfigFromFile).toHaveBeenCalled();
|
|
45
|
-
expect(_readConfigFile.isUserConfigFileAvailable).toHaveBeenCalled();
|
|
46
|
-
expect(_tagProcessor.tagProcessor).toHaveBeenCalledWith(mockUserArgs, ["beta", "enterprice"]);
|
|
47
|
-
expect(_testRunner.runPreprocessing).toHaveBeenCalledWith(mockTagArgs, expect.stringContaining('config-creator.js'));
|
|
48
|
-
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
|
|
49
|
-
});
|
|
50
|
-
test('runPreprocessing with playwright conf', async () => {
|
|
51
|
-
const mockTagArgs = ['@beta_admin'];
|
|
52
|
-
_tagProcessor.tagProcessor.mockReturnValue(mockTagArgs);
|
|
53
|
-
_readConfigFile.isUserConfigFileAvailable.mockReturnValue(false);
|
|
54
|
-
_testRunner.runPreprocessing.mockResolvedValueOnce();
|
|
55
|
-
await (0, _validateFeature.default)();
|
|
56
|
-
expect(_testRunner.runPreprocessing).toHaveBeenCalledWith(mockTagArgs, expect.stringContaining('playwright.config.js'));
|
|
57
|
-
});
|
|
58
|
-
test('error when runPreprocessing fails', async () => {
|
|
59
|
-
const mockError = new Error('Test error');
|
|
60
|
-
_testRunner.runPreprocessing.mockRejectedValueOnce(mockError);
|
|
61
|
-
await await (0, _validateFeature.default)();
|
|
62
|
-
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.FAILURE_TYPE, `Error while validating the feature files - ${mockError}`);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _fs = require("fs");
|
|
5
|
-
var _path = _interopRequireDefault(require("path"));
|
|
6
|
-
var _configFileNameProvider = require("../../../../../core/playwright/helpers/configFileNameProvider");
|
|
7
|
-
jest.mock('fs');
|
|
8
|
-
jest.mock('path');
|
|
9
|
-
const mockCwd = '/mock/current/directory';
|
|
10
|
-
_path.default.resolve = jest.fn();
|
|
11
|
-
process.cwd = jest.fn(() => mockCwd);
|
|
12
|
-
describe('getUATFileName', () => {
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.clearAllMocks();
|
|
15
|
-
});
|
|
16
|
-
test('return the pipeline matched config files for pipeline matched files exists', () => {
|
|
17
|
-
const mode = 'cd';
|
|
18
|
-
const mockPath = `${mockCwd}/uat/conf/${mode}/uat.config.js`;
|
|
19
|
-
_fs.existsSync.mockReturnValue(true);
|
|
20
|
-
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
21
|
-
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|
|
22
|
-
expect(_fs.existsSync).toHaveBeenCalledWith(mockPath);
|
|
23
|
-
expect(result).toBe(mockPath);
|
|
24
|
-
});
|
|
25
|
-
test('return the default config files for pipeline matched files not exists', () => {
|
|
26
|
-
const mode = 'ci';
|
|
27
|
-
const defaultPath = `${mockCwd}/uat.config.js`;
|
|
28
|
-
_fs.existsSync.mockReturnValue(false);
|
|
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);
|
|
33
|
-
});
|
|
34
|
-
});
|