@zohodesk/testinglibrary 0.4.6-experimental → 2.9.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/README.md +4 -19
- package/build/bdd-framework/cli/commands/env.js +42 -0
- package/build/bdd-framework/cli/commands/export.js +62 -0
- package/build/bdd-framework/cli/commands/test.js +64 -0
- package/build/bdd-framework/cli/index.js +11 -0
- package/build/bdd-framework/cli/options.js +19 -0
- package/build/bdd-framework/cli/worker.js +13 -0
- package/build/bdd-framework/config/configDir.js +35 -0
- package/build/bdd-framework/config/enrichReporterData.js +23 -0
- package/build/bdd-framework/config/env.js +50 -0
- package/build/bdd-framework/config/index.js +94 -0
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +43 -0
- package/build/bdd-framework/cucumber/createTestStep.js +43 -0
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +126 -0
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +72 -0
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +25 -0
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +13 -0
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +57 -0
- package/build/bdd-framework/cucumber/formatter/index.js +16 -0
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +16 -0
- package/build/bdd-framework/cucumber/loadConfig.js +17 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +70 -0
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +20 -0
- package/build/bdd-framework/cucumber/loadSteps.js +47 -0
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +62 -0
- package/build/bdd-framework/cucumber/stepArguments.js +21 -0
- package/build/bdd-framework/cucumber/types.js +5 -0
- package/build/bdd-framework/cucumber/valueChecker.js +23 -0
- package/build/bdd-framework/decorators.js +18 -0
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +167 -0
- package/build/bdd-framework/gen/i18n.js +39 -0
- package/build/bdd-framework/gen/index.js +197 -0
- package/build/bdd-framework/gen/specialTags.js +70 -0
- package/build/bdd-framework/gen/testFile.js +470 -0
- package/build/bdd-framework/gen/testMeta.js +60 -0
- package/build/bdd-framework/gen/testNode.js +35 -0
- package/build/bdd-framework/gen/testPoms.js +133 -0
- package/build/bdd-framework/hooks/scenario.js +130 -0
- package/build/bdd-framework/hooks/worker.js +89 -0
- package/build/bdd-framework/index.js +52 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +93 -0
- package/build/bdd-framework/playwright/getLocationInFile.js +79 -0
- package/build/bdd-framework/playwright/loadConfig.js +42 -0
- package/build/bdd-framework/playwright/loadUtils.js +33 -0
- package/build/bdd-framework/playwright/testTypeImpl.js +79 -0
- package/build/bdd-framework/playwright/transform.js +88 -0
- package/build/bdd-framework/playwright/types.js +12 -0
- package/build/bdd-framework/playwright/utils.js +56 -0
- package/build/bdd-framework/reporter/cucumber/base.js +52 -0
- package/build/bdd-framework/reporter/cucumber/custom.js +73 -0
- package/build/bdd-framework/reporter/cucumber/helper.js +12 -0
- package/build/bdd-framework/reporter/cucumber/html.js +40 -0
- package/build/bdd-framework/reporter/cucumber/index.js +74 -0
- package/build/bdd-framework/reporter/cucumber/json.js +312 -0
- package/build/bdd-framework/reporter/cucumber/junit.js +205 -0
- package/build/bdd-framework/reporter/cucumber/message.js +20 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +82 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +197 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +43 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +52 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +105 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +70 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +45 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +27 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +38 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +128 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +154 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +123 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +67 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +114 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +30 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +70 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +35 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +5 -0
- package/build/bdd-framework/run/StepInvoker.js +69 -0
- 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 +192 -0
- package/build/bdd-framework/run/bddWorld.js +79 -0
- package/build/bdd-framework/run/bddWorldInternal.js +11 -0
- package/build/bdd-framework/snippets/index.js +132 -0
- package/build/bdd-framework/snippets/snippetSyntax.js +43 -0
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +26 -0
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +18 -0
- package/build/bdd-framework/stepDefinitions/createBdd.js +66 -0
- package/build/bdd-framework/stepDefinitions/decorators/class.js +68 -0
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +99 -0
- package/build/bdd-framework/stepDefinitions/defineStep.js +62 -0
- package/build/bdd-framework/stepDefinitions/stepConfig.js +24 -0
- 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/bdd-framework/utils/AutofillMap.js +20 -0
- package/build/bdd-framework/utils/exit.js +62 -0
- package/build/bdd-framework/utils/index.js +93 -0
- package/build/bdd-framework/utils/jsStringWrap.js +44 -0
- package/build/bdd-framework/utils/logger.js +30 -0
- package/build/bdd-framework/utils/stripAnsiEscapes.js +20 -0
- package/build/core/playwright/helpers/auth/getUsers.js +12 -25
- package/build/core/playwright/index.js +23 -10
- package/build/core/playwright/setup/config-creator.js +3 -3
- package/build/core/playwright/setup/config-utils.js +25 -8
- package/build/core/playwright/tagProcessor.js +79 -0
- package/build/core/playwright/test-runner.js +4 -3
- package/build/core/playwright/validateFeature.js +3 -33
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- 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/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +10 -5
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
- package/nobdd/src/App.js +7 -0
- package/npm-shrinkwrap.json +2175 -5825
- package/package.json +7 -7
- package/build/core/playwright/fixtures.js +0 -24
- package/build/core/playwright/tag-processor.js +0 -68
- 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
|
@@ -1,24 +1,37 @@
|
|
|
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
|
-
exports
|
|
7
|
-
Object.defineProperty(exports, "expect", {
|
|
7
|
+
Object.defineProperty(exports, "createBdd", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return
|
|
10
|
+
return _bddFramework.createBdd;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
Object.defineProperty(exports, "
|
|
13
|
+
Object.defineProperty(exports, "expect", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function () {
|
|
16
|
-
return
|
|
16
|
+
return _test.expect;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
19
|
+
exports.test = void 0;
|
|
20
|
+
var _bddFramework = require("../../bdd-framework");
|
|
20
21
|
var _test = require("@playwright/test");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
var _readConfigFile = require("./readConfigFile");
|
|
23
|
+
var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
|
|
24
|
+
var _getUserFixtures = _interopRequireDefault(require("./helpers/getUserFixtures"));
|
|
25
|
+
const {
|
|
26
|
+
bddMode
|
|
27
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
28
|
+
let base = bddMode ? _bddFramework.test : _test.test;
|
|
29
|
+
const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
|
|
30
|
+
const buildInFixturesTest = base.extend({
|
|
31
|
+
...buildInFixtures
|
|
32
|
+
});
|
|
33
|
+
const userFixtures = (0, _getUserFixtures.default)();
|
|
34
|
+
const userFixturesTest = base.extend({
|
|
35
|
+
...userFixtures
|
|
36
|
+
});
|
|
37
|
+
const test = exports.test = (0, _test.mergeTests)(buildInFixturesTest, userFixturesTest);
|
|
@@ -39,12 +39,12 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
|
|
|
39
39
|
featureFilesFolder,
|
|
40
40
|
stepDefinitionsFolder
|
|
41
41
|
});
|
|
42
|
-
const
|
|
42
|
+
const testOptions = (0, _configUtils.getTestUseOptions)({
|
|
43
43
|
trace,
|
|
44
44
|
video,
|
|
45
45
|
viewport,
|
|
46
46
|
testIdAttribute
|
|
47
|
-
};
|
|
47
|
+
});
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Playwright configuration object
|
|
@@ -65,7 +65,7 @@ function getPlaywrightConfig() {
|
|
|
65
65
|
expect: {
|
|
66
66
|
timeout: expectTimeout
|
|
67
67
|
},
|
|
68
|
-
use,
|
|
68
|
+
use: testOptions,
|
|
69
69
|
projects: isAuthMode ? [{
|
|
70
70
|
name: 'setup',
|
|
71
71
|
testMatch: /.*\.setup\.js/,
|
|
@@ -7,12 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getBrowsersList = getBrowsersList;
|
|
8
8
|
exports.getProjects = getProjects;
|
|
9
9
|
exports.getTestDir = getTestDir;
|
|
10
|
+
exports.getTestUseOptions = getTestUseOptions;
|
|
10
11
|
var _test = require("@playwright/test");
|
|
11
12
|
var _path = _interopRequireDefault(require("path"));
|
|
12
13
|
var _readConfigFile = require("../readConfigFile");
|
|
13
|
-
var
|
|
14
|
+
var _bddFramework = require("../../../bdd-framework");
|
|
14
15
|
var _logger = require("../../../utils/logger");
|
|
15
16
|
var _browserTypes = require("../constants/browserTypes");
|
|
17
|
+
var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
16
18
|
var _fileUtils = require("../../../utils/fileUtils");
|
|
17
19
|
/**
|
|
18
20
|
** Playwright project configuration
|
|
@@ -146,15 +148,30 @@ function getPathsForFeatureFiles(cwd) {
|
|
|
146
148
|
function getTestDir(bddMode, cwd, {
|
|
147
149
|
stepDefinitionsFolder
|
|
148
150
|
}) {
|
|
149
|
-
return bddMode ? (0,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
importTestFrom: require.resolve('../fixtures.js'),
|
|
151
|
+
return bddMode ? (0, _bddFramework.defineBddConfig)({
|
|
152
|
+
paths: getPathsForFeatureFiles(cwd),
|
|
153
|
+
import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
|
|
153
154
|
featuresRoot: _path.default.join(cwd, 'uat'),
|
|
154
155
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
155
|
-
disableWarnings: {
|
|
156
|
-
importTestFrom: true
|
|
157
|
-
},
|
|
158
156
|
publish: true
|
|
159
157
|
}) : _path.default.join(cwd, 'uat');
|
|
158
|
+
}
|
|
159
|
+
function getTestUseOptions({
|
|
160
|
+
viewport,
|
|
161
|
+
trace,
|
|
162
|
+
video,
|
|
163
|
+
testIdAttribute
|
|
164
|
+
}) {
|
|
165
|
+
let defaultTestuseOptions = {
|
|
166
|
+
viewport,
|
|
167
|
+
testIdAttribute,
|
|
168
|
+
trace: trace ? 'on' : 'off',
|
|
169
|
+
video: video ? {
|
|
170
|
+
mode: 'on',
|
|
171
|
+
size: {
|
|
172
|
+
...viewport
|
|
173
|
+
}
|
|
174
|
+
} : 'off'
|
|
175
|
+
};
|
|
176
|
+
return defaultTestuseOptions;
|
|
160
177
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _logger = require("../../utils/logger");
|
|
4
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
5
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
6
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
7
|
+
var _buildTagsString = /*#__PURE__*/new WeakSet();
|
|
8
|
+
var _parseEdition = /*#__PURE__*/new WeakSet();
|
|
9
|
+
var _processSingleEdition = /*#__PURE__*/new WeakSet();
|
|
10
|
+
var _processMultipleEditions = /*#__PURE__*/new WeakSet();
|
|
11
|
+
var _getEditionArgs = /*#__PURE__*/new WeakSet();
|
|
12
|
+
var _buildEditionTags = /*#__PURE__*/new WeakSet();
|
|
13
|
+
class TagProcessor {
|
|
14
|
+
constructor(editionOrder) {
|
|
15
|
+
_classPrivateMethodInitSpec(this, _buildEditionTags);
|
|
16
|
+
_classPrivateMethodInitSpec(this, _getEditionArgs);
|
|
17
|
+
_classPrivateMethodInitSpec(this, _processMultipleEditions);
|
|
18
|
+
_classPrivateMethodInitSpec(this, _processSingleEdition);
|
|
19
|
+
_classPrivateMethodInitSpec(this, _parseEdition);
|
|
20
|
+
_classPrivateMethodInitSpec(this, _buildTagsString);
|
|
21
|
+
this.editionOrder = editionOrder;
|
|
22
|
+
}
|
|
23
|
+
processTags(userArgs) {
|
|
24
|
+
const tagArgs = userArgs['tags'] || '';
|
|
25
|
+
const edition = userArgs['edition'] || null;
|
|
26
|
+
if (!edition) return tagArgs;
|
|
27
|
+
const editionsArray = edition.split(',');
|
|
28
|
+
const editionTags = editionsArray.length === 1 ? _classPrivateMethodGet(this, _processSingleEdition, _processSingleEdition2).call(this, editionsArray[0], tagArgs) : _classPrivateMethodGet(this, _processMultipleEditions, _processMultipleEditions2).call(this, editionsArray, tagArgs);
|
|
29
|
+
return editionTags;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function _buildTagsString2(tags, editionTags) {
|
|
33
|
+
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
34
|
+
}
|
|
35
|
+
function _parseEdition2(edition) {
|
|
36
|
+
if (edition.startsWith('<=')) return ['<=', edition.slice(2)];
|
|
37
|
+
if (edition.startsWith('>=')) return ['>=', edition.slice(2)];
|
|
38
|
+
if (edition.startsWith('<')) return ['<', edition.slice(1)];
|
|
39
|
+
if (edition.startsWith('>')) return ['>', edition.slice(1)];
|
|
40
|
+
return [null, edition];
|
|
41
|
+
}
|
|
42
|
+
function _processSingleEdition2(selectedEdition, tagArgs) {
|
|
43
|
+
const editionArgs = _classPrivateMethodGet(this, _getEditionArgs, _getEditionArgs2).call(this, selectedEdition);
|
|
44
|
+
if (editionArgs && editionArgs.length > 0) {
|
|
45
|
+
const editionTags = _classPrivateMethodGet(this, _buildEditionTags, _buildEditionTags2).call(this, editionArgs, 'or');
|
|
46
|
+
return _classPrivateMethodGet(this, _buildTagsString, _buildTagsString2).call(this, tagArgs, editionTags);
|
|
47
|
+
}
|
|
48
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
49
|
+
return tagArgs;
|
|
50
|
+
}
|
|
51
|
+
function _processMultipleEditions2(editionsArray, tagArgs) {
|
|
52
|
+
const filteredEditions = this.editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
53
|
+
const editionTags = _classPrivateMethodGet(this, _buildEditionTags, _buildEditionTags2).call(this, filteredEditions, 'or');
|
|
54
|
+
return _classPrivateMethodGet(this, _buildTagsString, _buildTagsString2).call(this, tagArgs, editionTags);
|
|
55
|
+
}
|
|
56
|
+
function _getEditionArgs2(selectedEdition) {
|
|
57
|
+
const [operator, editionValue] = _classPrivateMethodGet(this, _parseEdition, _parseEdition2).call(this, selectedEdition.toLowerCase());
|
|
58
|
+
const index = this.editionOrder.findIndex(edition => edition.toLowerCase() === editionValue);
|
|
59
|
+
if (index === -1) {
|
|
60
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
switch (operator) {
|
|
64
|
+
case '<=':
|
|
65
|
+
return this.editionOrder.slice(index + 1);
|
|
66
|
+
case '>=':
|
|
67
|
+
return this.editionOrder.slice(0, index);
|
|
68
|
+
case '<':
|
|
69
|
+
return this.editionOrder.slice(index);
|
|
70
|
+
case '>':
|
|
71
|
+
return this.editionOrder.slice(0, index + 1);
|
|
72
|
+
default:
|
|
73
|
+
return this.editionOrder.filter((_, i) => i !== index);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function _buildEditionTags2(editionArgs, operator = 'or') {
|
|
77
|
+
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
78
|
+
}
|
|
79
|
+
module.exports = TagProcessor;
|
|
@@ -14,7 +14,7 @@ var _envInitializer = require("./env-initializer");
|
|
|
14
14
|
var _logger = require("../../utils/logger");
|
|
15
15
|
var _readConfigFile = require("./readConfigFile");
|
|
16
16
|
var _rootPath = require("../../utils/rootPath");
|
|
17
|
-
var _tagProcessor = require("./
|
|
17
|
+
var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
|
|
18
18
|
var _configUtils = require("./setup/config-utils");
|
|
19
19
|
var _browserTypes = require("./constants/browserTypes");
|
|
20
20
|
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
@@ -43,7 +43,7 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
|
43
43
|
}
|
|
44
44
|
function runPreprocessing(tagArgs, configPath) {
|
|
45
45
|
const beforeCommand = 'node';
|
|
46
|
-
const bddGenPath = _path.default.resolve(
|
|
46
|
+
const bddGenPath = _path.default.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
|
|
47
47
|
const beforeArgs = [bddGenPath, '-c', configPath];
|
|
48
48
|
if (tagArgs) {
|
|
49
49
|
beforeArgs.push('--tags');
|
|
@@ -122,7 +122,8 @@ function main() {
|
|
|
122
122
|
|
|
123
123
|
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
124
124
|
const userArgsObject = userArgConfig.getAll();
|
|
125
|
-
const
|
|
125
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
126
|
+
const tagArgs = tagProcessor.processTags(userArgsObject);
|
|
126
127
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
127
128
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
128
129
|
const command = playwrightPath;
|
|
@@ -7,40 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _parseUserArgs = _interopRequireDefault(require("./helpers/parseUserArgs"));
|
|
9
9
|
var _readConfigFile = require("./readConfigFile");
|
|
10
|
-
var _tagProcessor = require("./
|
|
10
|
+
var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
|
|
11
11
|
var _testRunner = require("./test-runner");
|
|
12
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
13
|
const validateFeatureFiles = () => {
|
|
45
14
|
const userArgsObject = (0, _parseUserArgs.default)();
|
|
46
15
|
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
@@ -48,7 +17,8 @@ const validateFeatureFiles = () => {
|
|
|
48
17
|
editionOrder
|
|
49
18
|
} = uatConfig;
|
|
50
19
|
const configPath = (0, _readConfigFile.isUserConfigFileAvailable)() ? require.resolve('./setup/config-creator.js') : require.resolve('../../../playwright.config.js');
|
|
51
|
-
const
|
|
20
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
21
|
+
const tagArgs = tagProcessor.processTags(userArgsObject);
|
|
52
22
|
(0, _testRunner.runPreprocessing)(tagArgs, configPath).then(() => {
|
|
53
23
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
|
|
54
24
|
}).catch(error => {
|
package/build/decorators.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from './bdd-framework/decorators';
|
package/build/decorators.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _decorators = require("
|
|
6
|
+
var _decorators = require("./bdd-framework/decorators");
|
|
7
7
|
Object.keys(_decorators).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
9
|
if (key in exports && exports[key] === _decorators[key]) return;
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _tagProcessor = _interopRequireDefault(require("../../../../../src/core/playwright/tagProcessor"));
|
|
5
|
+
var _logger = require("../../../../utils/logger");
|
|
6
|
+
jest.mock('../../../../utils/logger');
|
|
7
|
+
describe('TagProcessor', () => {
|
|
8
|
+
const editionOrder = ['edition1', 'edition2', 'edition3', 'edition4'];
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks();
|
|
11
|
+
});
|
|
12
|
+
test('should return tagArgs if no edition is provided', () => {
|
|
13
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
14
|
+
const userArgs = {
|
|
15
|
+
tags: 'tag1',
|
|
16
|
+
edition: null
|
|
17
|
+
};
|
|
18
|
+
const result = tagProcessor.processTags(userArgs);
|
|
19
|
+
expect(result).toBe('tag1');
|
|
20
|
+
});
|
|
21
|
+
test('should handle a single edition with <= operator', () => {
|
|
22
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
23
|
+
const userArgs = {
|
|
24
|
+
tags: 'tag1',
|
|
25
|
+
edition: '<=edition2'
|
|
26
|
+
};
|
|
27
|
+
const result = tagProcessor.processTags(userArgs);
|
|
28
|
+
expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
|
|
29
|
+
});
|
|
30
|
+
test('should handle a single edition with >= operator', () => {
|
|
31
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
32
|
+
const userArgs = {
|
|
33
|
+
tags: 'tag1',
|
|
34
|
+
edition: '>=edition2'
|
|
35
|
+
};
|
|
36
|
+
const result = tagProcessor.processTags(userArgs);
|
|
37
|
+
expect(result).toBe('tag1 and not (@edition_edition1)');
|
|
38
|
+
});
|
|
39
|
+
test('should handle a single edition with < operator', () => {
|
|
40
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
41
|
+
const userArgs = {
|
|
42
|
+
tags: 'tag1',
|
|
43
|
+
edition: '<edition3'
|
|
44
|
+
};
|
|
45
|
+
const result = tagProcessor.processTags(userArgs);
|
|
46
|
+
expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
|
|
47
|
+
});
|
|
48
|
+
test('should handle a single edition with > operator', () => {
|
|
49
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
50
|
+
const userArgs = {
|
|
51
|
+
tags: 'tag1',
|
|
52
|
+
edition: '>edition1'
|
|
53
|
+
};
|
|
54
|
+
const result = tagProcessor.processTags(userArgs);
|
|
55
|
+
expect(result).toBe('tag1 and not (@edition_edition1)');
|
|
56
|
+
});
|
|
57
|
+
test('should handle a single edition with no operator', () => {
|
|
58
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
59
|
+
const userArgs = {
|
|
60
|
+
tags: 'tag1',
|
|
61
|
+
edition: 'edition2'
|
|
62
|
+
};
|
|
63
|
+
const result = tagProcessor.processTags(userArgs);
|
|
64
|
+
expect(result).toBe('tag1 and not (@edition_edition1 or @edition_edition3 or @edition_edition4)');
|
|
65
|
+
});
|
|
66
|
+
test('should log a message if edition is not found', () => {
|
|
67
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
68
|
+
const userArgs = {
|
|
69
|
+
tags: 'tag1',
|
|
70
|
+
edition: 'nonexistentEdition'
|
|
71
|
+
};
|
|
72
|
+
const result = tagProcessor.processTags(userArgs);
|
|
73
|
+
expect(result).toBe('tag1');
|
|
74
|
+
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.INFO_TYPE, expect.stringContaining('No matching editions for nonexistentEdition found.'));
|
|
75
|
+
});
|
|
76
|
+
test('should handle multiple editions', () => {
|
|
77
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
78
|
+
const userArgs = {
|
|
79
|
+
tags: 'tag1',
|
|
80
|
+
edition: 'edition1,edition3'
|
|
81
|
+
};
|
|
82
|
+
const result = tagProcessor.processTags(userArgs);
|
|
83
|
+
expect(result).toBe('tag1 and not (@edition_edition2 or @edition_edition4)');
|
|
84
|
+
});
|
|
85
|
+
test('should build tags correctly when tags are empty', () => {
|
|
86
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
87
|
+
const userArgs = {
|
|
88
|
+
tags: '',
|
|
89
|
+
edition: 'edition1'
|
|
90
|
+
};
|
|
91
|
+
const result = tagProcessor.processTags(userArgs);
|
|
92
|
+
expect(result).toBe('not (@edition_edition2 or @edition_edition3 or @edition_edition4)');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _validateFeature = _interopRequireDefault(require("../../../../core/playwright/validateFeature"));
|
|
5
5
|
var _parseUserArgs = _interopRequireDefault(require("../../../../core/playwright/helpers/parseUserArgs"));
|
|
6
6
|
var _readConfigFile = require("../../../../core/playwright/readConfigFile");
|
|
7
|
-
var _tagProcessor = require("../../../../core/playwright/
|
|
7
|
+
var _tagProcessor = _interopRequireDefault(require("../../../../core/playwright/tagProcessor"));
|
|
8
8
|
var _testRunner = require("../../../../core/playwright/test-runner");
|
|
9
9
|
var _logger = require("../../../../utils/logger");
|
|
10
10
|
jest.mock('../../../../core/playwright/helpers/parseUserArgs', () => ({
|
|
@@ -12,7 +12,7 @@ jest.mock('../../../../core/playwright/helpers/parseUserArgs', () => ({
|
|
|
12
12
|
default: jest.fn()
|
|
13
13
|
}));
|
|
14
14
|
jest.mock('../../../../core/playwright/readConfigFile');
|
|
15
|
-
jest.mock('../../../../core/playwright/
|
|
15
|
+
jest.mock('../../../../core/playwright/tagProcessor');
|
|
16
16
|
jest.mock('../../../../core/playwright/test-runner');
|
|
17
17
|
jest.mock('../../../../utils/logger', () => ({
|
|
18
18
|
__esModule: true,
|
|
@@ -23,8 +23,13 @@ jest.mock('../../../../utils/logger', () => ({
|
|
|
23
23
|
}
|
|
24
24
|
}));
|
|
25
25
|
describe('validateFeatureFiles', () => {
|
|
26
|
+
let tagProcessorInstance;
|
|
26
27
|
beforeEach(() => {
|
|
27
28
|
jest.clearAllMocks();
|
|
29
|
+
tagProcessorInstance = {
|
|
30
|
+
processTags: jest.fn()
|
|
31
|
+
};
|
|
32
|
+
_tagProcessor.default.mockImplementation(() => tagProcessorInstance);
|
|
28
33
|
});
|
|
29
34
|
test('runPreprocessing with correct arguments and log success', async () => {
|
|
30
35
|
const mockUserArgs = {
|
|
@@ -37,19 +42,19 @@ describe('validateFeatureFiles', () => {
|
|
|
37
42
|
_readConfigFile.generateConfigFromFile.mockReturnValue(mockConfig);
|
|
38
43
|
_readConfigFile.isUserConfigFileAvailable.mockReturnValue(true);
|
|
39
44
|
const mockTagArgs = ['@beta_admin'];
|
|
40
|
-
|
|
45
|
+
tagProcessorInstance.processTags.mockReturnValue(mockTagArgs);
|
|
41
46
|
_testRunner.runPreprocessing.mockResolvedValueOnce();
|
|
42
47
|
await (0, _validateFeature.default)();
|
|
43
48
|
expect(_parseUserArgs.default).toHaveBeenCalled();
|
|
44
49
|
expect(_readConfigFile.generateConfigFromFile).toHaveBeenCalled();
|
|
45
50
|
expect(_readConfigFile.isUserConfigFileAvailable).toHaveBeenCalled();
|
|
46
|
-
expect(
|
|
51
|
+
expect(tagProcessorInstance.processTags).toHaveBeenCalledWith(mockUserArgs);
|
|
47
52
|
expect(_testRunner.runPreprocessing).toHaveBeenCalledWith(mockTagArgs, expect.stringContaining('config-creator.js'));
|
|
48
53
|
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.SUCCESS_TYPE, 'Feature files validated successfully.');
|
|
49
54
|
});
|
|
50
55
|
test('runPreprocessing with playwright conf', async () => {
|
|
51
56
|
const mockTagArgs = ['@beta_admin'];
|
|
52
|
-
|
|
57
|
+
tagProcessorInstance.processTags.mockReturnValue(mockTagArgs);
|
|
53
58
|
_readConfigFile.isUserConfigFileAvailable.mockReturnValue(false);
|
|
54
59
|
_testRunner.runPreprocessing.mockResolvedValueOnce();
|
|
55
60
|
await (0, _validateFeature.default)();
|