@zohodesk/testinglibrary 0.1.8-exp-bdd-v1 → 0.1.8-exp.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/.babelrc +18 -18
- package/.eslintrc.js +31 -27
- package/.prettierrc +5 -5
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/build/bdd-framework/cli/commands/env.js +4 -4
- package/build/bdd-framework/cli/commands/test.js +6 -2
- package/build/bdd-framework/cli/options.js +4 -4
- package/build/bdd-framework/cli/worker.js +3 -3
- package/build/bdd-framework/config/dir.js +6 -6
- package/build/bdd-framework/config/env.js +5 -4
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
- package/build/bdd-framework/cucumber/loadSources.js +9 -9
- package/build/bdd-framework/cucumber/loadSteps.js +8 -3
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +64 -17
- package/build/bdd-framework/gen/i18n.js +9 -5
- package/build/bdd-framework/gen/index.js +9 -8
- package/build/bdd-framework/gen/testFile.js +121 -55
- package/build/bdd-framework/gen/testNode.js +19 -6
- package/build/bdd-framework/gen/testPoms.js +49 -39
- package/build/bdd-framework/hooks/scenario.js +107 -0
- package/build/bdd-framework/hooks/worker.js +83 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +27 -11
- package/build/bdd-framework/playwright/getLocationInFile.js +17 -11
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +19 -15
- package/build/bdd-framework/playwright/transform.js +10 -6
- package/build/bdd-framework/playwright/utils.js +3 -6
- package/build/bdd-framework/run/StepInvoker.js +73 -0
- package/build/bdd-framework/run/bddFixtures.js +118 -55
- package/build/bdd-framework/run/bddWorld.js +24 -36
- package/build/bdd-framework/snippets/index.js +5 -3
- package/build/bdd-framework/snippets/snippetSyntax.js +3 -1
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +30 -13
- package/build/bdd-framework/stepDefinitions/decorators/{poms.js → class.js} +13 -9
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +14 -8
- package/build/bdd-framework/stepDefinitions/defineStep.js +5 -4
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +26 -18
- package/build/bdd-framework/utils/index.js +30 -4
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +5 -3
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
- package/build/core/playwright/builtInFixtures/context.js +15 -0
- package/build/core/playwright/builtInFixtures/index.js +26 -0
- package/build/core/playwright/builtInFixtures/page.js +51 -0
- package/build/core/playwright/clear-caches.js +29 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/index.js +6 -74
- package/build/core/playwright/readConfigFile.js +37 -30
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +43 -20
- package/build/core/playwright/setup/config-utils.js +30 -0
- package/build/core/playwright/setup/custom-reporter.js +109 -0
- package/build/core/playwright/tag-processor.js +68 -0
- package/build/core/playwright/test-runner.js +8 -12
- package/build/index.d.ts +60 -5
- package/build/index.js +18 -12
- package/build/lib/cli.js +10 -1
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- package/build/setup-folder-structure/helper.js +35 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
- package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
- package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
- package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -32
- package/build/setup-folder-structure/samples/uat-config-sample.js +44 -43
- package/build/setup-folder-structure/setupProject.js +10 -5
- package/build/utils/cliArgsToObject.js +29 -25
- package/build/utils/fileUtils.js +15 -4
- package/changelog.md +137 -74
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +6469 -7781
- package/package.json +55 -54
- package/playwright.config.js +112 -112
- package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
- package/build/bdd-framework/gen/poms.js +0 -46
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -108
- package/build/bdd-poc/core-runner/exportMethods.js +0 -20
- package/build/bdd-poc/core-runner/stepDefinitions.js +0 -53
- package/build/bdd-poc/main.js +0 -10
- package/build/bdd-poc/runner.js +0 -19
- package/build/bdd-poc/test/cucumber/featureFileParer.js +0 -81
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +0 -36
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +0 -43
- package/build/bdd-poc/test/testDataMap.js +0 -98
- package/build/bdd-poc/test/testStructure.js +0 -83
- package/build/bdd-poc/utils/stringManipulation.js +0 -19
|
@@ -13,10 +13,7 @@ var _envInitializer = require("./env-initializer");
|
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
-
var
|
|
17
|
-
function parseUserArgs() {
|
|
18
|
-
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
19
|
-
}
|
|
16
|
+
var _tagProcessor = require("./tag-processor");
|
|
20
17
|
function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
21
18
|
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
22
19
|
if (debug) {
|
|
@@ -67,7 +64,6 @@ function runPlaywright(command, args) {
|
|
|
67
64
|
});
|
|
68
65
|
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
69
66
|
if (code !== 0) {
|
|
70
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
71
67
|
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
72
68
|
} else {
|
|
73
69
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
@@ -75,25 +71,26 @@ function runPlaywright(command, args) {
|
|
|
75
71
|
}
|
|
76
72
|
});
|
|
77
73
|
process.on('exit', () => {
|
|
78
|
-
|
|
74
|
+
childProcessForRunningPlaywright.kill();
|
|
79
75
|
reject('Terminating Playwright Process...');
|
|
80
76
|
});
|
|
81
77
|
process.on('SIGINT', () => {
|
|
82
|
-
|
|
78
|
+
childProcessForRunningPlaywright.kill();
|
|
83
79
|
reject('Cleaning up...');
|
|
84
80
|
});
|
|
85
81
|
});
|
|
86
82
|
}
|
|
87
83
|
function main() {
|
|
88
|
-
const userArgsObject = parseUserArgs();
|
|
84
|
+
const userArgsObject = (0, _cliArgsToObject.parseUserArgs)();
|
|
89
85
|
// eslint-disable-next-line
|
|
90
|
-
const tagArgs = userArgsObject['tags'];
|
|
91
86
|
const {
|
|
92
87
|
debug,
|
|
93
88
|
mode = 'dev',
|
|
94
89
|
bddMode = false,
|
|
95
|
-
headless = false
|
|
90
|
+
headless = false,
|
|
91
|
+
editionOrder
|
|
96
92
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
93
|
+
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
97
94
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
98
95
|
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
99
96
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
@@ -102,8 +99,7 @@ function main() {
|
|
|
102
99
|
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
103
100
|
let promises = [];
|
|
104
101
|
if (bddMode) {
|
|
105
|
-
(
|
|
106
|
-
// promises.push(runPreprocessing(tagArgs, configPath));
|
|
102
|
+
promises.push(runPreprocessing(tagArgs, configPath));
|
|
107
103
|
}
|
|
108
104
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
109
105
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { expect, test } from './core/playwright/index';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
import {
|
|
4
|
+
PlaywrightTestArgs,
|
|
5
|
+
PlaywrightTestOptions,
|
|
6
|
+
PlaywrightWorkerArgs,
|
|
7
|
+
PlaywrightWorkerOptions,
|
|
8
|
+
TestType,
|
|
9
|
+
Page
|
|
10
|
+
} from '@playwright/test';
|
|
11
|
+
import { DefineStepPattern } from '@cucumber/cucumber/lib/support_code_library_builder/types';
|
|
12
|
+
|
|
13
|
+
export type KeyValue = { [key: string]: any };
|
|
14
|
+
|
|
15
|
+
export type BuiltInFixturesWorker = PlaywrightWorkerArgs &
|
|
16
|
+
PlaywrightWorkerOptions;
|
|
17
|
+
export type BuiltInFixtures = PlaywrightTestArgs &
|
|
18
|
+
PlaywrightTestOptions &
|
|
19
|
+
BuiltInFixturesWorker;
|
|
20
|
+
|
|
21
|
+
export type FixturesArg<T extends KeyValue = {}, W extends KeyValue = {}> = T &
|
|
22
|
+
W &
|
|
23
|
+
BuiltInFixtures;
|
|
24
|
+
|
|
25
|
+
export declare let hasCustomTest: boolean;
|
|
26
|
+
|
|
27
|
+
export declare function createBdd<
|
|
28
|
+
T extends KeyValue = BuiltInFixtures,
|
|
29
|
+
W extends KeyValue = BuiltInFixturesWorker,
|
|
30
|
+
World
|
|
31
|
+
>(
|
|
32
|
+
customTest?: TestType<T, W> | null,
|
|
33
|
+
_CustomWorld?: new (...args: any[]) => World
|
|
34
|
+
): {
|
|
35
|
+
Given: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
36
|
+
When: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
37
|
+
Then: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
38
|
+
And: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
39
|
+
But: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
40
|
+
Step: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
41
|
+
Before: any;
|
|
42
|
+
After: any;
|
|
43
|
+
BeforeAll: any;
|
|
44
|
+
AfterAll: any;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type StepFunctionFixturesArg<
|
|
48
|
+
T extends KeyValue,
|
|
49
|
+
W extends KeyValue
|
|
50
|
+
> = FixturesArg<T, W>;
|
|
51
|
+
type StepFunction<T extends KeyValue, W extends KeyValue> = (
|
|
52
|
+
fixtures: StepFunctionFixturesArg<T, W>,
|
|
53
|
+
...args: any[]
|
|
54
|
+
) => unknown;
|
|
55
|
+
|
|
56
|
+
const { Given, Then, When, Step, And, But } = createBdd();
|
|
57
|
+
|
|
58
|
+
export { Given, Then, When, Step, And, But, expect, test, createBdd, Page };
|
|
59
|
+
|
|
60
|
+
export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.When = exports.Then = exports.Step = exports.Given = void 0;
|
|
6
|
+
exports.When = exports.Then = exports.Step = exports.Given = exports.But = exports.And = void 0;
|
|
7
7
|
Object.defineProperty(exports, "createBdd", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "createNativeBDD", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _stepDefinitions.createNativeBDD;
|
|
10
|
+
return _index.createBdd;
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
13
|
Object.defineProperty(exports, "expect", {
|
|
@@ -29,16 +23,28 @@ Object.defineProperty(exports, "test", {
|
|
|
29
23
|
}
|
|
30
24
|
});
|
|
31
25
|
var _index = require("./core/playwright/index");
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
// const { expect, test, createBdd } = require('./core/playwright/index');
|
|
27
|
+
// const { fireEvent, render } = require('@testing-library/react');
|
|
28
|
+
|
|
29
|
+
// module.exports = {
|
|
30
|
+
// expect,
|
|
31
|
+
// test,
|
|
32
|
+
// fireEvent,
|
|
33
|
+
// render,
|
|
34
|
+
// createBdd
|
|
35
|
+
// }
|
|
36
|
+
|
|
34
37
|
// import { fireEvent, render } from '@testing-library/react';
|
|
38
|
+
|
|
35
39
|
const {
|
|
36
40
|
Given,
|
|
37
41
|
Then,
|
|
38
42
|
When,
|
|
39
43
|
Step
|
|
40
|
-
} = (0,
|
|
44
|
+
} = (0, _index.createBdd)();
|
|
41
45
|
exports.Step = Step;
|
|
42
46
|
exports.When = When;
|
|
43
47
|
exports.Then = Then;
|
|
44
|
-
exports.Given = Given;
|
|
48
|
+
exports.Given = Given;
|
|
49
|
+
const And = exports.And = Then;
|
|
50
|
+
const But = exports.But = Then;
|
package/build/lib/cli.js
CHANGED
|
@@ -7,6 +7,8 @@ var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
|
|
|
7
7
|
var _logger = require("../utils/logger");
|
|
8
8
|
var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
|
|
9
9
|
var _parser = require("../parser/parser");
|
|
10
|
+
var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
|
|
11
|
+
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
10
12
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
11
13
|
|
|
12
14
|
const [,, option, ...otherOptions] = process.argv;
|
|
@@ -46,9 +48,16 @@ switch (option) {
|
|
|
46
48
|
(0, _parser.generateSpecCodeForFeatureFile)(otherOptions);
|
|
47
49
|
break;
|
|
48
50
|
}
|
|
51
|
+
case 'clearCaches':
|
|
52
|
+
{
|
|
53
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Clearing caches...');
|
|
54
|
+
(0, _clearCaches.default)();
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'help':
|
|
49
58
|
default:
|
|
50
59
|
{
|
|
51
|
-
|
|
60
|
+
(0, _helper.default)();
|
|
52
61
|
break;
|
|
53
62
|
}
|
|
54
63
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
Feature: Home Page
|
|
2
|
-
|
|
3
|
-
Scenario: Home Page Default content
|
|
4
|
-
Given user is on "<App>" home page
|
|
5
|
-
Then user gets a "<App>" bootcamp section
|
|
6
|
-
And username is also displayed on right corner
|
|
7
|
-
|
|
8
|
-
Examples:
|
|
9
|
-
| App |
|
|
10
|
-
| GitHub |
|
|
11
|
-
|
|
12
|
-
Scenario: GitHub Bootcamp Section
|
|
13
|
-
Given user is on "<Site>" home page
|
|
14
|
-
When user focuses on "<Site>" Bootcamp Section
|
|
15
|
-
Then user gets an option to setup git
|
|
16
|
-
And user gets an option to create repository
|
|
17
|
-
And user gets an option to Fork Repository
|
|
18
|
-
And user gets an option to work together
|
|
19
|
-
|
|
20
|
-
Examples:
|
|
21
|
-
| Site |
|
|
22
|
-
| GitHub |
|
|
23
|
-
|
|
24
|
-
Scenario: Top Banner content
|
|
25
|
-
Given user is on "<Product>" home page
|
|
26
|
-
When user focuses on Top Banner
|
|
27
|
-
Then user gets an option of home page
|
|
28
|
-
And user gets an option to search
|
|
29
|
-
And user gets settings options
|
|
30
|
-
And user gets an option to logout
|
|
31
|
-
|
|
32
|
-
Examples:
|
|
33
|
-
| Product |
|
|
34
|
-
| GitHub |
|
|
1
|
+
Feature: Home Page
|
|
2
|
+
|
|
3
|
+
Scenario: Home Page Default content
|
|
4
|
+
Given user is on "<App>" home page
|
|
5
|
+
Then user gets a "<App>" bootcamp section
|
|
6
|
+
And username is also displayed on right corner
|
|
7
|
+
|
|
8
|
+
Examples:
|
|
9
|
+
| App |
|
|
10
|
+
| GitHub |
|
|
11
|
+
|
|
12
|
+
Scenario: GitHub Bootcamp Section
|
|
13
|
+
Given user is on "<Site>" home page
|
|
14
|
+
When user focuses on "<Site>" Bootcamp Section
|
|
15
|
+
Then user gets an option to setup git
|
|
16
|
+
And user gets an option to create repository
|
|
17
|
+
And user gets an option to Fork Repository
|
|
18
|
+
And user gets an option to work together
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
| Site |
|
|
22
|
+
| GitHub |
|
|
23
|
+
|
|
24
|
+
Scenario: Top Banner content
|
|
25
|
+
Given user is on "<Product>" home page
|
|
26
|
+
When user focuses on Top Banner
|
|
27
|
+
Then user gets an option of home page
|
|
28
|
+
And user gets an option to search
|
|
29
|
+
And user gets settings options
|
|
30
|
+
And user gets an option to logout
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
| Product |
|
|
34
|
+
| GitHub |
|
|
@@ -2,34 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
var _testinglibrary = require("@zohodesk/testinglibrary");
|
|
4
4
|
_testinglibrary.test.describe('Home Page', () => {
|
|
5
|
-
/*
|
|
6
|
-
** Given user is on "<App>" home page
|
|
7
|
-
** Then user gets a "<App>" bootcamp section
|
|
8
|
-
** And username is also displayed on right corner
|
|
5
|
+
/*
|
|
6
|
+
** Given user is on "<App>" home page
|
|
7
|
+
** Then user gets a "<App>" bootcamp section
|
|
8
|
+
** And username is also displayed on right corner
|
|
9
9
|
*/
|
|
10
10
|
(0, _testinglibrary.test)('Home Page Default content', () => {
|
|
11
11
|
// Your implementation here
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
/*
|
|
15
|
-
** Given user is on "<Site>" home page
|
|
16
|
-
** When user focuses on "<Site>" Bootcamp Section
|
|
17
|
-
** Then user gets an option to setup git
|
|
18
|
-
** And user gets an option to create repository
|
|
19
|
-
** And user gets an option to Fork Repository
|
|
20
|
-
** And user gets an option to work together
|
|
14
|
+
/*
|
|
15
|
+
** Given user is on "<Site>" home page
|
|
16
|
+
** When user focuses on "<Site>" Bootcamp Section
|
|
17
|
+
** Then user gets an option to setup git
|
|
18
|
+
** And user gets an option to create repository
|
|
19
|
+
** And user gets an option to Fork Repository
|
|
20
|
+
** And user gets an option to work together
|
|
21
21
|
*/
|
|
22
22
|
(0, _testinglibrary.test)('GitHub Bootcamp Section', () => {
|
|
23
23
|
// Your implementation here
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
/*
|
|
27
|
-
** Given user is on "<Product>" home page
|
|
28
|
-
** When user focuses on Top Banner
|
|
29
|
-
** Then user gets an option of home page
|
|
30
|
-
** And user gets an option to search
|
|
31
|
-
** And user gets settings options
|
|
32
|
-
** And user gets an option to logout
|
|
26
|
+
/*
|
|
27
|
+
** Given user is on "<Product>" home page
|
|
28
|
+
** When user focuses on Top Banner
|
|
29
|
+
** Then user gets an option of home page
|
|
30
|
+
** And user gets an option to search
|
|
31
|
+
** And user gets settings options
|
|
32
|
+
** And user gets an option to logout
|
|
33
33
|
*/
|
|
34
34
|
(0, _testinglibrary.test)('Top Banner content', () => {
|
|
35
35
|
// Your implementation here
|
|
@@ -0,0 +1,35 @@
|
|
|
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 _commander = require("commander");
|
|
9
|
+
var _fs = require("fs");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _logger = require("../utils/logger");
|
|
12
|
+
function helpercmd() {
|
|
13
|
+
const packageJsonPath = _path.default.resolve(process.cwd(), './package.json');
|
|
14
|
+
if ((0, _fs.existsSync)(packageJsonPath) && process.argv.includes('--version')) {
|
|
15
|
+
const {
|
|
16
|
+
dependencies
|
|
17
|
+
} = require(packageJsonPath);
|
|
18
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `zohodesk/testinglibrary Version : ${dependencies['@zohodesk/testinglibrary']}`);
|
|
19
|
+
_commander.program.version(dependencies['@zohodesk/testinglibrary'] || '0.0.1');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands...');
|
|
23
|
+
_commander.program.name('npx ZDTestingFramework');
|
|
24
|
+
_commander.program.command('test').description('This command is used to execute tests');
|
|
25
|
+
_commander.program.command('init').description('This command will initialize Project');
|
|
26
|
+
_commander.program.command('report').description('This command is used to generate a report summarizing the results of executed tests.');
|
|
27
|
+
_commander.program.command('codegen').description('This command is used to assist developer to write test case');
|
|
28
|
+
_commander.program.option('--headed', 'Run tests with a headed browser.');
|
|
29
|
+
_commander.program.option('--debug', 'This command is used to initiate a debugging session');
|
|
30
|
+
_commander.program.option('--tags', 'Run specific test case with mentioned tags (Usage: -- --tags="@live")');
|
|
31
|
+
_commander.program.option('--workers', 'Specify number of workers to run the test case parallely (Usage: -- --workers=2)');
|
|
32
|
+
_commander.program.option('--browsers', 'Specify the browsers on which the test case should run (Usage: -- --browsers="chrome,firefox,safari")');
|
|
33
|
+
_commander.program.parse(process.argv);
|
|
34
|
+
}
|
|
35
|
+
var _default = exports.default = helpercmd;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
function sortEdition(event) {
|
|
3
|
+
var currentURL = window.location.href;
|
|
4
|
+
const endPointCount = window.location.href.indexOf('#');
|
|
5
|
+
if (!(endPointCount == -1)) {
|
|
6
|
+
window.history.pushState({}, '', currentURL.slice(0, endPointCount));
|
|
7
|
+
currentURL = currentURL.slice(0, endPointCount);
|
|
8
|
+
}
|
|
9
|
+
console.log(currentURL);
|
|
10
|
+
window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
<div class="mainContainer" style="margin-left: 20px; display: flex;">
|
|
14
|
+
<div class="selectEditionContainer" style="padding: 20px;">
|
|
15
|
+
<select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
|
|
16
|
+
<option value="EnterPrise">EnterPrise</option>
|
|
17
|
+
<option value="Professional">Professional</option>
|
|
18
|
+
<option value="Express">Express</option>
|
|
19
|
+
<option value="Standard">Standard</option>
|
|
20
|
+
<option value="Free">Free</option>
|
|
21
|
+
</select>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.preProcessReport = preProcessReport;
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _logger = require("./../../utils/logger");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
const htmlFilePath = _path.default.resolve(process.cwd(), 'uat', 'playwright-report', 'index.html');
|
|
12
|
+
const fileHtml = _fs.default.readFileSync(htmlFilePath, 'utf-8');
|
|
13
|
+
const addOnHtml = _fs.default.readFileSync(_path.default.resolve(__filename, '../', 'addonScript.html'), 'utf-8');
|
|
14
|
+
const splitedHTML = fileHtml.split('\n');
|
|
15
|
+
const toAdd = addOnHtml.split('\n');
|
|
16
|
+
function preProcessReport() {
|
|
17
|
+
if (_fs.default.existsSync(htmlFilePath)) {
|
|
18
|
+
const modifiedContent = [...splitedHTML.slice(0, 55), ...toAdd, ...splitedHTML.slice(56)].join('').toString();
|
|
19
|
+
_fs.default.writeFileSync(htmlFilePath, modifiedContent);
|
|
20
|
+
return;
|
|
21
|
+
} else {
|
|
22
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Report is not generated Properly ...');
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { test as setup, expect } from '@zohodesk/testinglibrary';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
-
|
|
6
|
-
const userdata = require('./authUsers.json');
|
|
7
|
-
|
|
8
|
-
const authDirectory = path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
|
|
9
|
-
|
|
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
|
-
|
|
16
|
-
function convertCookiesToParse(cookies, authFilePath) {
|
|
17
|
-
try {
|
|
18
|
-
return JSON.parse(cookies)
|
|
19
|
-
} catch (err) {
|
|
20
|
-
throw new Error(` Error while parsing cookies ${err} \n${path.resolve(process.cwd(), authFilePath)} File is Empty`)
|
|
21
|
-
// process.exit()
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!existsSync(authDirectory)) {
|
|
26
|
-
console.log('Creating auth directory for the first time setup...');
|
|
27
|
-
mkdirSync(authDirectory, { recursive: true });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
userdata.forEach((data) => {
|
|
31
|
-
const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
|
|
32
|
-
if (!existsSync(authFile)) {
|
|
33
|
-
console.log('creating auth file..');
|
|
34
|
-
writeFileSync(authFile, JSON.stringify(authContent, null, 2))
|
|
35
|
-
}
|
|
36
|
-
setup(data.description, async ({ page }) => {
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const cookies = readFileSync(authFile);
|
|
40
|
-
const parsedCookies = convertCookiesToParse(cookies, authFile);
|
|
41
|
-
await page.context().addCookies(parsedCookies.cookies === undefined ? [] : parsedCookies.cookies)
|
|
42
|
-
await page.goto(page.getBaseUrl());
|
|
43
|
-
await page.waitForLoadState();
|
|
44
|
-
if (await page.url().includes(process.env.domain)) {
|
|
45
|
-
await page.waitForSelector(data.locator);
|
|
46
|
-
} else {
|
|
47
|
-
throw new Error(LOGIN_ERR_MESSAGE);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} catch (err) {
|
|
52
|
-
if (err.message === LOGIN_ERR_MESSAGE) {
|
|
53
|
-
|
|
54
|
-
await expect(page.locator('.load-bg')).toBeHidden();
|
|
55
|
-
await page.locator('#login_id').type(data.useremail);
|
|
56
|
-
await page.locator('#nextbtn').click();
|
|
57
|
-
await page.locator('#password').type(data.password);
|
|
58
|
-
await page.locator('#nextbtn').click();
|
|
59
|
-
|
|
60
|
-
await page.waitForLoadState("networkidle");
|
|
61
|
-
|
|
62
|
-
await page.waitForSelector(data.locator)
|
|
63
|
-
|
|
64
|
-
await page.context().storageState({ path: authFile });
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { test as setup, expect } from '@zohodesk/testinglibrary';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
|
|
6
|
+
const userdata = require('./authUsers.json');
|
|
7
|
+
|
|
8
|
+
const authDirectory = path.resolve(process.cwd(), 'uat', 'playwright', '.auth');
|
|
9
|
+
|
|
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
|
+
|
|
16
|
+
function convertCookiesToParse(cookies, authFilePath) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(cookies)
|
|
19
|
+
} catch (err) {
|
|
20
|
+
throw new Error(` Error while parsing cookies ${err} \n${path.resolve(process.cwd(), authFilePath)} File is Empty`)
|
|
21
|
+
// process.exit()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!existsSync(authDirectory)) {
|
|
26
|
+
console.log('Creating auth directory for the first time setup...');
|
|
27
|
+
mkdirSync(authDirectory, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
userdata.forEach((data) => {
|
|
31
|
+
const authFile = path.resolve(path.join(authDirectory, `${data.filename}`));
|
|
32
|
+
if (!existsSync(authFile)) {
|
|
33
|
+
console.log('creating auth file..');
|
|
34
|
+
writeFileSync(authFile, JSON.stringify(authContent, null, 2))
|
|
35
|
+
}
|
|
36
|
+
setup(data.description, async ({ page }) => {
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const cookies = readFileSync(authFile);
|
|
40
|
+
const parsedCookies = convertCookiesToParse(cookies, authFile);
|
|
41
|
+
await page.context().addCookies(parsedCookies.cookies === undefined ? [] : parsedCookies.cookies)
|
|
42
|
+
await page.goto(page.getBaseUrl());
|
|
43
|
+
await page.waitForLoadState();
|
|
44
|
+
if (await page.url().includes(process.env.domain)) {
|
|
45
|
+
await page.waitForSelector(data.locator);
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error(LOGIN_ERR_MESSAGE);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
} catch (err) {
|
|
52
|
+
if (err.message === LOGIN_ERR_MESSAGE) {
|
|
53
|
+
|
|
54
|
+
await expect(page.locator('.load-bg')).toBeHidden();
|
|
55
|
+
await page.locator('#login_id').type(data.useremail);
|
|
56
|
+
await page.locator('#nextbtn').click();
|
|
57
|
+
await page.locator('#password').type(data.password);
|
|
58
|
+
await page.locator('#nextbtn').click();
|
|
59
|
+
|
|
60
|
+
await page.waitForLoadState("networkidle");
|
|
61
|
+
|
|
62
|
+
await page.waitForSelector(data.locator)
|
|
63
|
+
|
|
64
|
+
await page.context().storageState({ path: authFile });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
})
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"useremail": "/ user name /",
|
|
4
|
-
"password": "/ password /",
|
|
5
|
-
"description": "/ description/",
|
|
6
|
-
"filename": "user.json",
|
|
7
|
-
"locator": "/ selector to identify page has been loaded completely /"
|
|
8
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"useremail": "/ user name /",
|
|
4
|
+
"password": "/ password /",
|
|
5
|
+
"description": "/ description/",
|
|
6
|
+
"filename": "user.json",
|
|
7
|
+
"locator": "/ selector to identify page has been loaded completely /"
|
|
8
|
+
}
|
|
9
9
|
]
|
|
@@ -1,21 +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
|
-
}
|
|
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
21
|
}
|