@zohodesk/testinglibrary 0.1.9 → 0.2.1
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/build/bdd-framework/cli/commands/env.js +1 -1
- package/build/bdd-framework/cli/commands/export.js +18 -3
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/formatter.js +57 -13
- package/build/bdd-framework/gen/index.js +21 -9
- package/build/bdd-framework/gen/specialTags.js +70 -0
- package/build/bdd-framework/gen/testFile.js +10 -5
- package/build/bdd-framework/gen/testNode.js +4 -29
- package/build/bdd-framework/gen/testPoms.js +1 -1
- package/build/bdd-framework/index.js +1 -1
- package/build/bdd-framework/playwright/testTypeImpl.js +28 -10
- package/build/bdd-framework/playwright/types.js +8 -1
- package/build/bdd-framework/playwright/utils.js +22 -0
- package/build/bdd-framework/reporter/cucumber/base.js +2 -7
- package/build/bdd-framework/reporter/cucumber/html.js +9 -4
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +28 -10
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +21 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +3 -3
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +46 -18
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +41 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +19 -2
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +42 -16
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/{pwUtils.js → pwStepUtils.js} +33 -14
- package/build/bdd-framework/run/StepInvoker.js +8 -7
- package/build/bdd-framework/run/bddData/index.js +59 -0
- package/build/bdd-framework/run/bddData/types.js +5 -0
- package/build/bdd-framework/run/bddFixtures.js +5 -4
- package/build/bdd-framework/run/bddWorld.js +3 -3
- package/build/bdd-framework/run/bddWorldInternal.js +1 -5
- package/build/bdd-framework/snippets/index.js +1 -1
- package/build/bdd-framework/steps/createBdd.js +78 -0
- package/build/bdd-framework/steps/decorators/class.js +68 -0
- package/build/bdd-framework/steps/decorators/steps.js +98 -0
- package/build/bdd-framework/steps/defineStep.js +62 -0
- package/build/bdd-framework/steps/stepConfig.js +24 -0
- package/build/core/playwright/builtInFixtures/page.js +21 -14
- package/build/core/playwright/clear-caches.js +5 -3
- package/build/core/playwright/env-initializer.js +22 -6
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +10 -5
- package/build/core/playwright/helpers/auth/getUsers.js +79 -32
- package/build/core/playwright/helpers/auth/index.js +22 -4
- package/build/core/playwright/helpers/auth/loginSteps.js +2 -2
- package/build/core/playwright/helpers/configFileNameProvider.js +9 -1
- package/build/core/playwright/index.js +14 -59
- package/build/core/playwright/readConfigFile.js +14 -2
- package/build/core/playwright/test-runner.js +2 -3
- package/build/index.d.ts +17 -18
- package/build/index.js +16 -4
- package/build/setup-folder-structure/samples/auth-setup-sample.js +22 -21
- package/build/setup-folder-structure/setupProject.js +1 -0
- package/build/utils/fileUtils.js +5 -0
- package/changelog.md +18 -0
- package/npm-shrinkwrap.json +1 -1
- package/package.json +3 -2
- package/build/bdd-framework/run/bddDataAttachment.js +0 -46
|
@@ -4,67 +4,114 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
7
|
+
exports.getDefaultActor = getDefaultActor;
|
|
8
|
+
exports.getDefaultActorConf = getDefaultActorConf;
|
|
9
|
+
exports.getListOfActors = getListOfActors;
|
|
10
|
+
exports.getRunMode = getRunMode;
|
|
9
11
|
exports.getUserForSelectedEditionAndProfile = getUserForSelectedEditionAndProfile;
|
|
10
12
|
exports.isCI = isCI;
|
|
13
|
+
exports.isDevelopmentSetup = isDevelopmentSetup;
|
|
11
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
|
+
var _fs = require("fs");
|
|
12
16
|
var _readConfigFile = require("../../readConfigFile");
|
|
13
17
|
/* eslint-disable global-require */
|
|
18
|
+
function getRunMode() {
|
|
19
|
+
let {
|
|
20
|
+
mode
|
|
21
|
+
} = process.env;
|
|
22
|
+
return mode || 'dev';
|
|
23
|
+
}
|
|
14
24
|
function isCI() {
|
|
15
|
-
|
|
25
|
+
const mode = getRunMode();
|
|
26
|
+
return mode === 'CI' || mode === 'ci';
|
|
27
|
+
}
|
|
28
|
+
function isDevelopmentSetup() {
|
|
29
|
+
const mode = getRunMode();
|
|
30
|
+
return mode === 'DEV' || mode === 'dev';
|
|
16
31
|
}
|
|
17
|
-
function
|
|
18
|
-
let users;
|
|
32
|
+
function getDefaultActorConf() {
|
|
19
33
|
const {
|
|
20
34
|
uatDirectory
|
|
21
35
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.`);
|
|
26
40
|
}
|
|
27
|
-
return
|
|
41
|
+
return require(filePath);
|
|
28
42
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
43
|
+
function getDefaultActor() {
|
|
44
|
+
const {
|
|
45
|
+
edition,
|
|
46
|
+
profile
|
|
47
|
+
} = getDefaultActorConf();
|
|
48
|
+
return getUserForSelectedEditionAndProfile(edition, profile);
|
|
49
|
+
}
|
|
50
|
+
function getListOfActors() {
|
|
31
51
|
const {
|
|
32
52
|
uatDirectory
|
|
33
53
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
const mode = getRunMode();
|
|
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.`);
|
|
38
59
|
}
|
|
39
|
-
return
|
|
60
|
+
return require(filePath);
|
|
40
61
|
}
|
|
41
|
-
function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile,
|
|
62
|
+
function getUserForSelectedEditionAndProfile(preferedEdition, preferredProfile, betaFeature, testDataPortal = null) {
|
|
42
63
|
const {
|
|
43
64
|
editions: userdata,
|
|
44
|
-
|
|
45
|
-
} =
|
|
46
|
-
const
|
|
47
|
-
const edition = preferedEdition ||
|
|
48
|
-
const profile = preferredProfile ||
|
|
65
|
+
beta: betaPortals
|
|
66
|
+
} = getListOfActors();
|
|
67
|
+
const defaultConf = getDefaultActorConf();
|
|
68
|
+
const edition = preferedEdition || defaultConf.edition;
|
|
69
|
+
const profile = preferredProfile || defaultConf.profile;
|
|
49
70
|
let selectedProfile = {};
|
|
50
|
-
if (
|
|
71
|
+
if (betaFeature && betaFeature !== null) {
|
|
72
|
+
if (!betaPortals.hasOwnProperty(betaFeature)) {
|
|
73
|
+
throw new Error(`There is no "${betaFeature}" beta feature configured.`);
|
|
74
|
+
}
|
|
75
|
+
const betaEdition = betaPortals[betaFeature].find(portal => portal.edition === edition);
|
|
76
|
+
if (!betaEdition) {
|
|
77
|
+
throw new Error(`There is no "${edition}" edition configured in "${betaFeature}" beta feature.`);
|
|
78
|
+
}
|
|
51
79
|
const {
|
|
52
|
-
profiles:
|
|
53
|
-
...
|
|
54
|
-
} =
|
|
55
|
-
selectedProfile =
|
|
80
|
+
profiles: betaProfiles,
|
|
81
|
+
...betaEditionData
|
|
82
|
+
} = betaEdition;
|
|
83
|
+
selectedProfile = betaProfiles.find(user => user.profile === profile);
|
|
84
|
+
if (!selectedProfile) {
|
|
85
|
+
throw new Error(`There is no "${profile}" configured in edition of "${edition}" in "${betaFeature}" beta features.`);
|
|
86
|
+
}
|
|
56
87
|
return {
|
|
57
|
-
...
|
|
88
|
+
...betaEditionData,
|
|
58
89
|
...selectedProfile
|
|
59
90
|
};
|
|
60
91
|
}
|
|
61
|
-
|
|
92
|
+
|
|
93
|
+
// TODO: We are returning the first data from array. We need to check the possiblity of having multiple users for same profile and possibly round robin
|
|
62
94
|
// For this we need to get the data from ci environment.
|
|
95
|
+
let testingPortal = null;
|
|
96
|
+
if (!userdata.hasOwnProperty(edition)) {
|
|
97
|
+
throw new Error(`There is no "${edition}" edition configured.`);
|
|
98
|
+
}
|
|
99
|
+
if (testDataPortal !== null) {
|
|
100
|
+
testingPortal = userdata[edition].find(editionData => editionData.orgName === testDataPortal);
|
|
101
|
+
if (!testingPortal) {
|
|
102
|
+
throw new Error(`There is no "${testDataPortal}" portal configured in "${edition}" edition.`);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
testingPortal = userdata[edition] ? userdata[edition][0] : {};
|
|
106
|
+
}
|
|
63
107
|
const {
|
|
64
108
|
profiles,
|
|
65
109
|
...editionData
|
|
66
|
-
} =
|
|
67
|
-
selectedProfile = profiles.find(user => user.
|
|
110
|
+
} = testingPortal;
|
|
111
|
+
selectedProfile = profiles.find(user => user.profile === profile);
|
|
112
|
+
if (!selectedProfile) {
|
|
113
|
+
throw new Error(`There is no "${profile}" profile configured in "${edition}" edition.`);
|
|
114
|
+
}
|
|
68
115
|
return {
|
|
69
116
|
...editionData,
|
|
70
117
|
...selectedProfile
|
|
@@ -10,16 +10,28 @@ Object.defineProperty(exports, "accountLogin", {
|
|
|
10
10
|
return _accountLogin.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "getDefaultActor", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function () {
|
|
16
|
-
return _getUsers.
|
|
16
|
+
return _getUsers.getDefaultActor;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
Object.defineProperty(exports, "
|
|
19
|
+
Object.defineProperty(exports, "getDefaultActorConf", {
|
|
20
20
|
enumerable: true,
|
|
21
21
|
get: function () {
|
|
22
|
-
return _getUsers.
|
|
22
|
+
return _getUsers.getDefaultActorConf;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "getListOfActors", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _getUsers.getListOfActors;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "getRunMode", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _getUsers.getRunMode;
|
|
23
35
|
}
|
|
24
36
|
});
|
|
25
37
|
Object.defineProperty(exports, "getUserForSelectedEditionAndProfile", {
|
|
@@ -34,6 +46,12 @@ Object.defineProperty(exports, "isCI", {
|
|
|
34
46
|
return _getUsers.isCI;
|
|
35
47
|
}
|
|
36
48
|
});
|
|
49
|
+
Object.defineProperty(exports, "isDevelopmentSetup", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _getUsers.isDevelopmentSetup;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
37
55
|
Object.defineProperty(exports, "loadCookiesIfPresent", {
|
|
38
56
|
enumerable: true,
|
|
39
57
|
get: function () {
|
|
@@ -12,11 +12,11 @@ var _checkAuthCookies = require("./checkAuthCookies");
|
|
|
12
12
|
|
|
13
13
|
async function performLoginSteps({
|
|
14
14
|
page,
|
|
15
|
-
|
|
15
|
+
authFilePrefix,
|
|
16
16
|
useremail,
|
|
17
17
|
password
|
|
18
18
|
}, isLoggedIn) {
|
|
19
|
-
const authFile = _path.default.resolve(_path.default.join(_checkAuthCookies.
|
|
19
|
+
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
20
20
|
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
21
21
|
await page.goto(process.env.domain);
|
|
22
22
|
await page.waitForNavigation();
|
|
@@ -1,15 +1,23 @@
|
|
|
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.getEnvConfigFilePath = getEnvConfigFilePath;
|
|
7
8
|
exports.getReportFileName = getReportFileName;
|
|
8
9
|
exports.getUATFileName = getUATFileName;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
12
|
function getUATFileName() {
|
|
10
13
|
return 'uat.config.js';
|
|
11
14
|
}
|
|
12
|
-
function getEnvConfigFilePath() {
|
|
15
|
+
function getEnvConfigFilePath(mode) {
|
|
16
|
+
const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
|
|
17
|
+
// TODO: Actors Mode as config
|
|
18
|
+
if (_fs.default.existsSync(confFilePath)) {
|
|
19
|
+
return `uat/conf/${mode}/settings.json`;
|
|
20
|
+
}
|
|
13
21
|
return `uat/env-config.json`;
|
|
14
22
|
}
|
|
15
23
|
function getReportFileName() {
|
|
@@ -4,13 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.When = exports.Then = exports.Given = void 0;
|
|
8
|
-
Object.defineProperty(exports, "accountLogin", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return _index.accountLogin;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
7
|
Object.defineProperty(exports, "createBdd", {
|
|
15
8
|
enumerable: true,
|
|
16
9
|
get: function () {
|
|
@@ -23,55 +16,25 @@ Object.defineProperty(exports, "expect", {
|
|
|
23
16
|
return _test.expect;
|
|
24
17
|
}
|
|
25
18
|
});
|
|
26
|
-
Object.defineProperty(exports, "getListOfUsers", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () {
|
|
29
|
-
return _index.getListOfUsers;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, "getPrimaryUser", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _index.getPrimaryUser;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports, "getUserForSelectedEditionAndProfile", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _index.getUserForSelectedEditionAndProfile;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(exports, "isCI", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return _index.isCI;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(exports, "loadCookiesIfPresent", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function () {
|
|
53
|
-
return _index.loadCookiesIfPresent;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
Object.defineProperty(exports, "performLoginSteps", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return _index.performLoginSteps;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
19
|
exports.test = void 0;
|
|
63
|
-
Object.defineProperty(exports, "verifyIfCookieFileExists", {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
get: function () {
|
|
66
|
-
return _index.verifyIfCookieFileExists;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
20
|
var _bddFramework = require("../../bdd-framework");
|
|
70
21
|
var _test = require("@playwright/test");
|
|
71
22
|
var _readConfigFile = require("./readConfigFile");
|
|
72
23
|
var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
|
|
73
|
-
var _index = require("./helpers/auth/index");
|
|
74
24
|
var _getUserFixtures = _interopRequireDefault(require("./helpers/getUserFixtures"));
|
|
25
|
+
// import {
|
|
26
|
+
// accountLogin,
|
|
27
|
+
// getRunMode,
|
|
28
|
+
// isCI,
|
|
29
|
+
// isDevelopmentSetup,
|
|
30
|
+
// getListOfActors,
|
|
31
|
+
// getDefaultActor,
|
|
32
|
+
// getUserForSelectedEditionAndProfile,
|
|
33
|
+
// loadCookiesIfPresent,
|
|
34
|
+
// performLoginSteps,
|
|
35
|
+
// verifyIfCookieFileExists
|
|
36
|
+
// } from './helpers/auth/index';
|
|
37
|
+
|
|
75
38
|
const {
|
|
76
39
|
bddMode
|
|
77
40
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
@@ -81,12 +44,4 @@ const userFixtures = (0, _getUserFixtures.default)();
|
|
|
81
44
|
const test = exports.test = base.extend({
|
|
82
45
|
...buildInFixtures,
|
|
83
46
|
...userFixtures
|
|
84
|
-
});
|
|
85
|
-
const {
|
|
86
|
-
Given,
|
|
87
|
-
When,
|
|
88
|
-
Then
|
|
89
|
-
} = (0, _bddFramework.createBdd)();
|
|
90
|
-
exports.Then = Then;
|
|
91
|
-
exports.When = When;
|
|
92
|
-
exports.Given = Given;
|
|
47
|
+
});
|
|
@@ -12,6 +12,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
12
12
|
var _logger = require("../../utils/logger");
|
|
13
13
|
var _configFileNameProvider = require("./helpers/configFileNameProvider");
|
|
14
14
|
var _mergeObjects = require("./helpers/mergeObjects");
|
|
15
|
+
let cachedConfig = null;
|
|
15
16
|
function getDefaultConfig() {
|
|
16
17
|
return {
|
|
17
18
|
uatDirectory: _path.default.join(process.cwd(), 'uat'),
|
|
@@ -31,7 +32,7 @@ function getDefaultConfig() {
|
|
|
31
32
|
height: 720
|
|
32
33
|
},
|
|
33
34
|
debug: false,
|
|
34
|
-
mode: 'dev',
|
|
35
|
+
mode: process.env.mode || 'dev',
|
|
35
36
|
additionalPages: {},
|
|
36
37
|
featureFilesFolder: 'feature-files',
|
|
37
38
|
stepDefinitionsFolder: 'steps',
|
|
@@ -40,10 +41,17 @@ function getDefaultConfig() {
|
|
|
40
41
|
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
41
42
|
};
|
|
42
43
|
}
|
|
44
|
+
function checkForDeprecatedKeys(configKey) {
|
|
45
|
+
let deprecatedConfigInUatConfigFile = ['mode'];
|
|
46
|
+
if (deprecatedConfigInUatConfigFile.includes(configKey)) {
|
|
47
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `key ${configKey} is deprecated. Please use other options`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
43
50
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
44
51
|
let defaultConfig = getDefaultConfig();
|
|
45
52
|
let configurationObj = {};
|
|
46
53
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
54
|
+
checkForDeprecatedKeys(configKey);
|
|
47
55
|
let configValue = userConfiguration[configKey];
|
|
48
56
|
if (configValue !== null && configValue !== undefined) {
|
|
49
57
|
configurationObj[configKey] = configValue;
|
|
@@ -80,7 +88,6 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
80
88
|
* @property {number} trace - trace for test cases.
|
|
81
89
|
* @property {boolean} video - video for test cases,
|
|
82
90
|
* @property {boolean} debug - debug mode
|
|
83
|
-
* @property {string} mode: mode in which the test cases needs to run
|
|
84
91
|
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
85
92
|
* @property {string} authFilePath - File Path where the cookies stored
|
|
86
93
|
* @property {any} browsers: List of browsers
|
|
@@ -104,11 +111,15 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
104
111
|
* @returns {UserConfig}
|
|
105
112
|
*/
|
|
106
113
|
function generateConfigFromFile() {
|
|
114
|
+
if (cachedConfig !== null) {
|
|
115
|
+
return cachedConfig; // If cached, return the cached configuration
|
|
116
|
+
}
|
|
107
117
|
const filePath = _path.default.resolve(process.cwd(), (0, _configFileNameProvider.getUATFileName)());
|
|
108
118
|
if ((0, _fs.existsSync)(filePath)) {
|
|
109
119
|
/** @type {UserConfig} */
|
|
110
120
|
const config = require(filePath);
|
|
111
121
|
const modifiedConfiguration = combineDefaultConfigWithUserConfig(config);
|
|
122
|
+
cachedConfig = modifiedConfiguration;
|
|
112
123
|
return modifiedConfiguration;
|
|
113
124
|
}
|
|
114
125
|
return {};
|
|
@@ -129,5 +140,6 @@ function getAuthFilePath(filePath) {
|
|
|
129
140
|
}
|
|
130
141
|
} catch (err) {
|
|
131
142
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Founded Path - ${filePath} Authetication file not Exist ...`);
|
|
143
|
+
_logger.Logger.error(err);
|
|
132
144
|
}
|
|
133
145
|
}
|
|
@@ -98,16 +98,15 @@ function runPlaywright(command, args) {
|
|
|
98
98
|
}
|
|
99
99
|
function main() {
|
|
100
100
|
const userArgsObject = (0, _parseUserArgs.default)();
|
|
101
|
+
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode);
|
|
101
102
|
const {
|
|
102
103
|
debug,
|
|
103
|
-
mode = 'dev',
|
|
104
104
|
bddMode = false,
|
|
105
105
|
headless = false,
|
|
106
106
|
editionOrder
|
|
107
107
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
108
108
|
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
109
109
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
110
|
-
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
111
110
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
112
111
|
const command = playwrightPath;
|
|
113
112
|
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
@@ -117,7 +116,7 @@ function main() {
|
|
|
117
116
|
promises.push(runPreprocessing(tagArgs, configPath));
|
|
118
117
|
}
|
|
119
118
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
120
|
-
_logger.Logger.
|
|
119
|
+
_logger.Logger.error(err);
|
|
121
120
|
process.exit();
|
|
122
121
|
});
|
|
123
122
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
loadCookiesIfPresent,
|
|
7
|
-
performLoginSteps,
|
|
8
|
-
verifyIfCookieFileExists } from './core/playwright/index';
|
|
1
|
+
import {
|
|
2
|
+
expect,
|
|
3
|
+
test,
|
|
4
|
+
createBdd
|
|
5
|
+
} from './core/playwright/index';
|
|
9
6
|
import { fireEvent, render } from '@testing-library/react';
|
|
10
7
|
import {
|
|
11
8
|
PlaywrightTestArgs,
|
|
@@ -64,16 +61,18 @@ const { Given, Then, When, Step, And, But } = createBdd();
|
|
|
64
61
|
|
|
65
62
|
type UserConfig = import('./core/playwright/readConfigFile').UserConfig;
|
|
66
63
|
|
|
67
|
-
export {
|
|
64
|
+
export {
|
|
68
65
|
UserConfig,
|
|
69
|
-
Given,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
Given,
|
|
67
|
+
Then,
|
|
68
|
+
When,
|
|
69
|
+
Step,
|
|
70
|
+
And,
|
|
71
|
+
But,
|
|
72
|
+
expect,
|
|
73
|
+
test,
|
|
74
|
+
createBdd,
|
|
75
|
+
Page
|
|
76
|
+
};
|
|
78
77
|
|
|
79
78
|
export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -22,16 +22,22 @@ Object.defineProperty(exports, "expect", {
|
|
|
22
22
|
return _index.expect;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
Object.defineProperty(exports, "
|
|
25
|
+
Object.defineProperty(exports, "getDefaultActor", {
|
|
26
26
|
enumerable: true,
|
|
27
27
|
get: function () {
|
|
28
|
-
return _index.
|
|
28
|
+
return _index.getDefaultActor;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
Object.defineProperty(exports, "
|
|
31
|
+
Object.defineProperty(exports, "getListOfActors", {
|
|
32
32
|
enumerable: true,
|
|
33
33
|
get: function () {
|
|
34
|
-
return _index.
|
|
34
|
+
return _index.getListOfActors;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "getRunMode", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _index.getRunMode;
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
43
|
Object.defineProperty(exports, "getUserForSelectedEditionAndProfile", {
|
|
@@ -46,6 +52,12 @@ Object.defineProperty(exports, "isCI", {
|
|
|
46
52
|
return _index.isCI;
|
|
47
53
|
}
|
|
48
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "isDevelopmentSetup", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _index.isDevelopmentSetup;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
49
61
|
Object.defineProperty(exports, "loadCookiesIfPresent", {
|
|
50
62
|
enumerable: true,
|
|
51
63
|
get: function () {
|
|
@@ -2,43 +2,51 @@
|
|
|
2
2
|
import { test as setup, expect } from '@zohodesk/testinglibrary';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
import { getAuthFileDirectory } from '../../core/playwright';
|
|
6
|
+
import { Logger } from '../../utils/logger';
|
|
5
7
|
|
|
6
8
|
const userdata = require('./authUsers.json');
|
|
7
9
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const authContent = { "cookies": [] };
|
|
10
|
+
const authContent = { cookies: [] };
|
|
11
11
|
|
|
12
12
|
const LOGIN_ERR_MESSAGE = 'Need go be logged in';
|
|
13
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
14
|
|
|
15
|
-
|
|
16
15
|
function convertCookiesToParse(cookies, authFilePath) {
|
|
17
16
|
try {
|
|
18
|
-
return JSON.parse(cookies)
|
|
17
|
+
return JSON.parse(cookies);
|
|
19
18
|
} catch (err) {
|
|
20
|
-
|
|
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
|
+
);
|
|
21
26
|
// process.exit()
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
|
-
|
|
29
|
+
const authDirectory = getAuthFileDirectory(); //path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
|
|
25
30
|
if (!existsSync(authDirectory)) {
|
|
26
31
|
console.log('Creating auth directory for the first time setup...');
|
|
27
32
|
mkdirSync(authDirectory, { recursive: true });
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
userdata.forEach(
|
|
35
|
+
userdata.forEach(data => {
|
|
31
36
|
const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
|
|
32
37
|
if (!existsSync(authFile)) {
|
|
33
38
|
console.log('creating auth file..');
|
|
34
|
-
writeFileSync(authFile, JSON.stringify(authContent, null, 2))
|
|
39
|
+
writeFileSync(authFile, JSON.stringify(authContent, null, 2));
|
|
35
40
|
}
|
|
36
41
|
setup(data.description, async ({ page }) => {
|
|
37
|
-
|
|
38
42
|
try {
|
|
39
43
|
const cookies = readFileSync(authFile);
|
|
40
44
|
const parsedCookies = convertCookiesToParse(cookies, authFile);
|
|
41
|
-
await page
|
|
45
|
+
await page
|
|
46
|
+
.context()
|
|
47
|
+
.addCookies(
|
|
48
|
+
parsedCookies.cookies === undefined ? [] : parsedCookies.cookies
|
|
49
|
+
);
|
|
42
50
|
await page.goto(page.getBaseUrl());
|
|
43
51
|
await page.waitForLoadState();
|
|
44
52
|
if (await page.url().includes(process.env.domain)) {
|
|
@@ -46,27 +54,20 @@ userdata.forEach((data) => {
|
|
|
46
54
|
} else {
|
|
47
55
|
throw new Error(LOGIN_ERR_MESSAGE);
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
57
|
} catch (err) {
|
|
52
58
|
if (err.message === LOGIN_ERR_MESSAGE) {
|
|
53
|
-
|
|
54
59
|
await expect(page.locator('.load-bg')).toBeHidden();
|
|
55
60
|
await page.locator('#login_id').type(data.useremail);
|
|
56
61
|
await page.locator('#nextbtn').click();
|
|
57
62
|
await page.locator('#password').type(data.password);
|
|
58
63
|
await page.locator('#nextbtn').click();
|
|
59
64
|
|
|
60
|
-
await page.waitForLoadState(
|
|
65
|
+
await page.waitForLoadState('networkidle');
|
|
61
66
|
|
|
62
|
-
await page.waitForSelector(data.locator)
|
|
67
|
+
await page.waitForSelector(data.locator);
|
|
63
68
|
|
|
64
69
|
await page.context().storageState({ path: authFile });
|
|
65
70
|
}
|
|
66
|
-
|
|
67
71
|
}
|
|
68
|
-
|
|
69
72
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
73
|
+
});
|
|
@@ -74,6 +74,7 @@ function createAuthenticationFile() {
|
|
|
74
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
|
+
_logger.Logger.error(err);
|
|
77
78
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
|
|
78
79
|
}
|
|
79
80
|
} else {
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -17,6 +17,7 @@ function checkIfFileExists(file) {
|
|
|
17
17
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
18
18
|
return true;
|
|
19
19
|
} catch (err) {
|
|
20
|
+
_logger.Logger.error(err);
|
|
20
21
|
return false;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -25,6 +26,7 @@ function readFileContents(filePath) {
|
|
|
25
26
|
let fileContents = _fs.default.readFileSync(filePath, 'utf-8');
|
|
26
27
|
return fileContents;
|
|
27
28
|
} catch (err) {
|
|
29
|
+
_logger.Logger.error(err);
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -40,6 +42,7 @@ function writeFileContents(filePath, content, writeOptions = {}) {
|
|
|
40
42
|
try {
|
|
41
43
|
_fs.default.writeFileSync(`${filePath}`, content, writeOptions);
|
|
42
44
|
} catch (err) {
|
|
45
|
+
_logger.Logger.error(err);
|
|
43
46
|
throw new Error(err);
|
|
44
47
|
}
|
|
45
48
|
}
|
|
@@ -48,6 +51,7 @@ function deleteFile(filePath) {
|
|
|
48
51
|
try {
|
|
49
52
|
_fs.default.unlinkSync(filePath);
|
|
50
53
|
} catch (err) {
|
|
54
|
+
_logger.Logger.error(err);
|
|
51
55
|
throw new Error(`Error while deleting the test data file: ${filePath}`);
|
|
52
56
|
}
|
|
53
57
|
} else {
|
|
@@ -61,6 +65,7 @@ function deleteFolder(folderPath) {
|
|
|
61
65
|
recursive: true
|
|
62
66
|
});
|
|
63
67
|
} catch (err) {
|
|
68
|
+
_logger.Logger.error(err);
|
|
64
69
|
throw new Error(`Error while deleting the test data file: ${folderPath}`);
|
|
65
70
|
}
|
|
66
71
|
}
|
package/changelog.md
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
# Testing Framework
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
+
# 0.2.1
|
|
5
|
+
**Issue Fixes**
|
|
6
|
+
- Fixes issue in actors configuration
|
|
7
|
+
- Added Error Logger
|
|
8
|
+
|
|
9
|
+
# 0.2.0
|
|
10
|
+
**Major Breaking Change**
|
|
11
|
+
- Removed Env-config.json in favour of conf/*/settings.json
|
|
12
|
+
- Mode in uat.config.js is deprecated. Use command args instead
|
|
13
|
+
|
|
14
|
+
**Enhancements**
|
|
15
|
+
- Playwright version updated to 1.42.1
|
|
16
|
+
- Playwright-bdd version updated to 6.1.1
|
|
17
|
+
- Tags Support
|
|
18
|
+
- Added getMetaInfo fixture to get the actors Info data
|
|
19
|
+
|
|
20
|
+
**Issue Fixes**
|
|
21
|
+
- Fixes #10- Mode config not working properly
|
|
4
22
|
|
|
5
23
|
# 0.1.9
|
|
6
24
|
**Enhancements**
|