@zohodesk/testinglibrary 0.1.7-exp.2 → 0.1.8-exp-bdd
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 +27 -31
- 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 +2 -6
- 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 +4 -5
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/gherkin.d.ts +45 -0
- 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 +3 -8
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/formatter.js +17 -64
- package/build/bdd-framework/gen/i18n.js +5 -9
- package/build/bdd-framework/gen/index.js +8 -9
- package/build/bdd-framework/gen/poms.js +46 -0
- package/build/bdd-framework/gen/testFile.js +55 -121
- package/build/bdd-framework/gen/testNode.js +6 -19
- package/build/bdd-framework/gen/testPoms.js +39 -49
- package/build/bdd-framework/playwright/fixtureParameterNames.js +11 -27
- package/build/bdd-framework/playwright/getLocationInFile.js +11 -17
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +15 -19
- package/build/bdd-framework/playwright/transform.js +6 -10
- package/build/bdd-framework/playwright/utils.js +6 -3
- package/build/bdd-framework/run/bddFixtures.js +55 -118
- package/build/bdd-framework/run/bddWorld.js +36 -24
- package/build/bdd-framework/snippets/index.js +3 -5
- package/build/bdd-framework/snippets/snippetSyntax.js +1 -3
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +13 -30
- package/build/bdd-framework/stepDefinitions/createDecorators.js +108 -0
- package/build/bdd-framework/stepDefinitions/decorators/{class.js → poms.js} +9 -13
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +8 -14
- package/build/bdd-framework/stepDefinitions/defineStep.js +4 -5
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +18 -26
- package/build/bdd-framework/utils/index.js +4 -30
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +3 -5
- package/build/bdd-poc/core-runner/exportMethods.js +14 -0
- package/build/bdd-poc/core-runner/stepDefinitions.js +55 -0
- package/build/bdd-poc/main.js +10 -0
- package/build/bdd-poc/test/cucumber/featureFileParer.js +81 -0
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +36 -0
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +43 -0
- package/build/bdd-poc/test/testDataMap.js +98 -0
- package/build/bdd-poc/test/testStructure.js +83 -0
- package/build/bdd-poc/utils/stringManipulation.js +19 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/index.js +74 -6
- package/build/core/playwright/readConfigFile.js +30 -37
- package/build/core/playwright/report-generator.js +1 -2
- package/build/core/playwright/setup/config-creator.js +15 -21
- package/build/core/playwright/setup/config-utils.js +0 -30
- package/build/core/playwright/test-runner.js +5 -7
- package/build/index.d.ts +5 -60
- package/build/index.js +3 -5
- package/build/lib/cli.js +1 -10
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- 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 +32 -36
- package/build/setup-folder-structure/samples/uat-config-sample.js +43 -44
- package/build/setup-folder-structure/setupProject.js +5 -10
- package/build/utils/cliArgsToObject.js +25 -25
- package/build/utils/fileUtils.js +4 -15
- package/changelog.md +74 -124
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +7781 -6469
- package/package.json +54 -55
- package/playwright.config.js +112 -112
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/hooks/scenario.js +0 -107
- package/build/bdd-framework/hooks/worker.js +0 -83
- package/build/bdd-framework/run/StepInvoker.js +0 -73
- package/build/core/playwright/builtInFixtures/addTags.js +0 -19
- package/build/core/playwright/builtInFixtures/cacheLayer.js +0 -12
- package/build/core/playwright/builtInFixtures/context.js +0 -15
- package/build/core/playwright/builtInFixtures/index.js +0 -26
- package/build/core/playwright/builtInFixtures/page.js +0 -51
- package/build/core/playwright/clear-caches.js +0 -29
- package/build/core/playwright/setup/custom-reporter.js +0 -109
- package/build/core/playwright/tag-processor.js +0 -68
- package/build/setup-folder-structure/helper.js +0 -34
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +0 -25
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +0 -25
package/build/index.d.ts
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
import { expect, test } from './core/playwright/index';
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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';
|
|
1
|
+
import { Given, Then, When, Step, expect, test, createBdd } from './core/playwright/index';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
export { Given, Then, When, Step, expect, test, createBdd, fireEvent, render };
|
|
5
|
+
export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.When = exports.Then = exports.Step = exports.Given =
|
|
6
|
+
exports.When = exports.Then = exports.Step = exports.Given = void 0;
|
|
7
7
|
Object.defineProperty(exports, "createBdd", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
@@ -35,7 +35,7 @@ var _index = require("./core/playwright/index");
|
|
|
35
35
|
// }
|
|
36
36
|
|
|
37
37
|
// import { fireEvent, render } from '@testing-library/react';
|
|
38
|
-
|
|
38
|
+
globalThis.globalStepMap = new Map();
|
|
39
39
|
const {
|
|
40
40
|
Given,
|
|
41
41
|
Then,
|
|
@@ -45,6 +45,4 @@ const {
|
|
|
45
45
|
exports.Step = Step;
|
|
46
46
|
exports.When = When;
|
|
47
47
|
exports.Then = Then;
|
|
48
|
-
exports.Given = Given;
|
|
49
|
-
const And = exports.And = Then;
|
|
50
|
-
const But = exports.But = Then;
|
|
48
|
+
exports.Given = Given;
|
package/build/lib/cli.js
CHANGED
|
@@ -7,8 +7,6 @@ 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"));
|
|
12
10
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
13
11
|
|
|
14
12
|
const [,, option, ...otherOptions] = process.argv;
|
|
@@ -48,16 +46,9 @@ switch (option) {
|
|
|
48
46
|
(0, _parser.generateSpecCodeForFeatureFile)(otherOptions);
|
|
49
47
|
break;
|
|
50
48
|
}
|
|
51
|
-
case 'clearCaches':
|
|
52
|
-
{
|
|
53
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Clearing caches...');
|
|
54
|
-
(0, _clearCaches.default)();
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
case 'help':
|
|
58
49
|
default:
|
|
59
50
|
{
|
|
60
|
-
(
|
|
51
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Supported Commands test and report');
|
|
61
52
|
break;
|
|
62
53
|
}
|
|
63
54
|
}
|
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { Logger } from '../utils/logger';
|
|
4
|
-
import { generateConfigFromFile } from '../core/playwright/readConfigFile';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { reportPath = path.resolve(process.cwd(), 'uat', 'playwright-reports') } = generateConfigFromFile();
|
|
8
|
-
const testResultsPath = path.resolve(process.cwd(), 'uat', 'test-results');
|
|
9
|
-
|
|
10
|
-
const testResultsRelativepath = path.relative(
|
|
11
|
-
const reportRelativepath = path.relative(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Logger.log(Logger.INFO_TYPE, 'GitIgnore file is No Found ....')
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Logger } from '../utils/logger';
|
|
4
|
+
import { generateConfigFromFile } from '../core/playwright/readConfigFile';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const { reportPath = path.resolve(process.cwd(), 'uat', 'playwright-reports') } = generateConfigFromFile();
|
|
8
|
+
const testResultsPath = path.resolve(process.cwd(), 'uat', 'test-results');
|
|
9
|
+
|
|
10
|
+
const testResultsRelativepath = path.relative(path.resolve(process.cwd(), '../', '../'), testResultsPath)
|
|
11
|
+
const reportRelativepath = path.relative(path.resolve(process.cwd(), '../', '../'), reportPath)
|
|
12
|
+
|
|
13
|
+
const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}`
|
|
14
|
+
|
|
15
|
+
function updateGitIgnore() {
|
|
16
|
+
if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {
|
|
17
|
+
let gitIgnoreData = readFileSync(path.resolve(process.cwd(), '../', '../', '.gitignore'), 'utf-8', (err) => {
|
|
18
|
+
if (err) {
|
|
19
|
+
Logger.log(Logger.FAILURE_TYPE, 'cannot able to read git ignore ')
|
|
20
|
+
// process.exit()
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
if (gitIgnoreData.includes(dirpathtoIgnore)) {
|
|
24
|
+
return
|
|
25
|
+
} else {
|
|
26
|
+
writeFileSync(path.resolve(process.cwd(), '../', '../', '.gitignore', dirpathtoIgnore, null, 2))
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
Logger.log(Logger.INFO_TYPE, 'GitIgnore file is No Found ....')
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
37
33
|
export default updateGitIgnore;
|
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object|null} viewportConfig
|
|
3
|
-
* @property {number} width - width of the viewport
|
|
4
|
-
* @property {number} height - height of the viewport
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Represents the user configuration object.
|
|
8
|
-
* @typedef {Object} UserConfig
|
|
9
|
-
* @property {string} headless - Headless Browsers mode.
|
|
10
|
-
* @property {number} trace - trace for test cases.
|
|
11
|
-
* @property {boolean} video - video for test cases,
|
|
12
|
-
* @property {boolean} debug - debug mode
|
|
13
|
-
* @property {string} mode: mode in which the test cases needs to run
|
|
14
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
15
|
-
* @property {string} authFilePath - File Path where the cookies stored
|
|
16
|
-
* @property {any} browsers: List of browsers
|
|
17
|
-
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
18
|
-
* @property {any} reportPath : directory where report is generate
|
|
19
|
-
* @property {boolean} bddMode: Feature files needs to be processed
|
|
20
|
-
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
21
|
-
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
22
|
-
* @property {Object} additionalPages: custom pages configuration
|
|
23
|
-
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
24
|
-
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
25
|
-
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object|null} viewportConfig
|
|
3
|
+
* @property {number} width - width of the viewport
|
|
4
|
+
* @property {number} height - height of the viewport
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Represents the user configuration object.
|
|
8
|
+
* @typedef {Object} UserConfig
|
|
9
|
+
* @property {string} headless - Headless Browsers mode.
|
|
10
|
+
* @property {number} trace - trace for test cases.
|
|
11
|
+
* @property {boolean} video - video for test cases,
|
|
12
|
+
* @property {boolean} debug - debug mode
|
|
13
|
+
* @property {string} mode: mode in which the test cases needs to run
|
|
14
|
+
* @property {boolean} isAuthMode - Auth Mode
|
|
15
|
+
* @property {string} authFilePath - File Path where the cookies stored
|
|
16
|
+
* @property {any} browsers: List of browsers
|
|
17
|
+
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
18
|
+
* @property {any} reportPath : directory where report is generate
|
|
19
|
+
* @property {boolean} bddMode: Feature files needs to be processed
|
|
20
|
+
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
21
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
22
|
+
* @property {Object} additionalPages: custom pages configuration
|
|
23
|
+
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
24
|
+
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
25
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is {width: 1280, height: 720 }
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @type {UserConfig}
|
|
30
|
+
*/
|
|
31
|
+
module.exports = {
|
|
32
|
+
headless: false,
|
|
33
|
+
browsers: ['Chrome', 'Firefox', 'Safari', 'Edge'],
|
|
34
|
+
mode: 'dev',
|
|
35
|
+
isAuthMode: true,
|
|
36
|
+
authFilePath: 'uat/playwright/.auth/user.json',
|
|
37
|
+
trace: true,
|
|
38
|
+
video: true,
|
|
39
|
+
bddMode: true,
|
|
40
|
+
featureFilesFolder: 'feature-files',
|
|
41
|
+
stepDefinitionsFolder: 'steps',
|
|
42
|
+
viewport: { width: 1280, height: 720 }
|
|
43
|
+
}
|
|
@@ -61,18 +61,14 @@ function createUatConfig() {
|
|
|
61
61
|
function createAuthenticationFile() {
|
|
62
62
|
const isUATexist = _path.default.resolve(process.cwd(), 'uat');
|
|
63
63
|
if ((0, _fs.existsSync)(isUATexist)) {
|
|
64
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
64
65
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'), {
|
|
70
|
-
recursive: true
|
|
71
|
-
});
|
|
72
|
-
}
|
|
66
|
+
(0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures'));
|
|
67
|
+
(0, _fs.mkdirSync)(_path.default.resolve(process.cwd(), 'uat', 'playwright', '.auth'), {
|
|
68
|
+
recursive: true
|
|
69
|
+
});
|
|
73
70
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
|
|
74
71
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'authUsers.json'), getSetupFileAsString('authUsers-sample.json'), null, 2);
|
|
75
|
-
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
76
72
|
} catch (err) {
|
|
77
73
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
|
|
78
74
|
}
|
|
@@ -95,7 +91,6 @@ function setupProject() {
|
|
|
95
91
|
createFolderForUAT();
|
|
96
92
|
createConfigJson();
|
|
97
93
|
createAuthenticationFile();
|
|
98
|
-
//updateGitIgnore()
|
|
99
94
|
// Create folder for playwright . Inside .auth folder needs to be created. user.json
|
|
100
95
|
// Add playwright and test-results to .gitignore
|
|
101
96
|
setTimeout(() => {
|