@zohodesk/testinglibrary 3.0.7 → 3.0.8
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/.gitlab-ci.yml +6 -1
- package/README.md +27 -0
- package/build/core/playwright/builtInFixtures/page.js +44 -46
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/helpers/auth/loginSteps.js +13 -13
- package/build/core/playwright/helpers/fileMutex.js +2 -2
- package/build/core/playwright/setup/config-creator.js +10 -5
- package/build/setup-folder-structure/samples/accountLogin-sample.js +19 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +4 -10
- package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +3 -1
- package/build/setup-folder-structure/setupProject.js +4 -0
- package/npm-shrinkwrap.json +2613 -1712
- package/package.json +6 -5
- package/playwright.config.js +0 -48
- package/unit_reports/unit-report.html +0 -260
package/.gitlab-ci.yml
CHANGED
|
@@ -18,14 +18,19 @@ default:
|
|
|
18
18
|
paths:
|
|
19
19
|
- node_modules
|
|
20
20
|
- build
|
|
21
|
+
- npm-shrinkwrap.json
|
|
21
22
|
|
|
22
23
|
# Install dependencies stage
|
|
23
24
|
build:
|
|
24
25
|
stage: build
|
|
25
26
|
script:
|
|
27
|
+
- npm -v
|
|
28
|
+
- node -v
|
|
26
29
|
- npm install --ignore-scripts
|
|
27
30
|
- npm run build
|
|
28
31
|
- npm install
|
|
32
|
+
- npm shrinkwrap
|
|
33
|
+
- npm run build
|
|
29
34
|
|
|
30
35
|
# Unit tests stage
|
|
31
36
|
unit:
|
|
@@ -101,7 +106,7 @@ uat-nobdd:
|
|
|
101
106
|
script:
|
|
102
107
|
- cd nobdd
|
|
103
108
|
- npm install $(npm pack ../../testing-framework | tail -1)
|
|
104
|
-
- output=$(npm run uatnobdd)
|
|
109
|
+
- output=$(npm run uatnobdd -- --headless)
|
|
105
110
|
- echo "$output"
|
|
106
111
|
- node ../ValidateUATReport.js nobdd
|
|
107
112
|
|
package/README.md
CHANGED
|
@@ -29,6 +29,28 @@
|
|
|
29
29
|
|
|
30
30
|
## Version History
|
|
31
31
|
|
|
32
|
+
### v3.0.8 - 25-12-2024
|
|
33
|
+
|
|
34
|
+
#### Enhancement
|
|
35
|
+
- Added support to disable headless mode using command line arguments
|
|
36
|
+
- Proper validation added for node 14 build process
|
|
37
|
+
- Removed unwanted uat.config.js files in test projects (examples / nobdd)
|
|
38
|
+
|
|
39
|
+
### v0.2.9.2 - 22-11-2024
|
|
40
|
+
|
|
41
|
+
#### BugFix
|
|
42
|
+
- Implemented synchronization for the login process. This fix will help avoid login session-related failures in UAT.
|
|
43
|
+
|
|
44
|
+
### v0.3.1 - 13-11-2024
|
|
45
|
+
|
|
46
|
+
#### Issue Fix
|
|
47
|
+
- Adding bddmode to get the fixtures.
|
|
48
|
+
|
|
49
|
+
### v0.2.9.1 - 14-11-2024
|
|
50
|
+
|
|
51
|
+
#### Enhancement
|
|
52
|
+
- Beta feature Actors and edition configurations are unified
|
|
53
|
+
|
|
32
54
|
### v0.2.9 - 25-10-2024
|
|
33
55
|
|
|
34
56
|
#### Feature
|
|
@@ -60,6 +82,11 @@
|
|
|
60
82
|
#### Issue Fix
|
|
61
83
|
- Adding bddmode to get the fixtures.
|
|
62
84
|
|
|
85
|
+
### v0.3.3 - 27-11-2024
|
|
86
|
+
|
|
87
|
+
#### Feature
|
|
88
|
+
- Custom report integration support (ReportPortal)
|
|
89
|
+
|
|
63
90
|
### v0.2.9.1 - 14-11-2024
|
|
64
91
|
|
|
65
92
|
#### Enhancement
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
7
|
var _auth = require("../helpers/auth");
|
|
9
|
-
var _getUrlOrigin = _interopRequireDefault(require("../helpers/auth/getUrlOrigin"));
|
|
10
8
|
var _readConfigFile = require("../readConfigFile");
|
|
11
9
|
/* eslint-disable global-require */
|
|
12
10
|
|
|
@@ -34,6 +32,16 @@ function getCustomAccountDetails(tags) {
|
|
|
34
32
|
const {
|
|
35
33
|
testSetup
|
|
36
34
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
35
|
+
async function loginSteps(pageDetail) {
|
|
36
|
+
const {
|
|
37
|
+
page
|
|
38
|
+
} = pageDetail;
|
|
39
|
+
if (testSetup.loginSteps && typeof testSetup.loginSteps === 'function') {
|
|
40
|
+
return await testSetup.loginSteps(pageDetail);
|
|
41
|
+
} else {
|
|
42
|
+
await page.goto(process.env.domain);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
async function performDefaultPageSteps({
|
|
38
46
|
context,
|
|
39
47
|
$tags,
|
|
@@ -49,13 +57,11 @@ async function performDefaultPageSteps({
|
|
|
49
57
|
await page.goto(process.env.domain);
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
|
-
async function verifyPageIsLoaded(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (urlOrigin === domainOrigin) {
|
|
56
|
-
return true;
|
|
60
|
+
async function verifyPageIsLoaded(testInfo) {
|
|
61
|
+
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
62
|
+
return await testSetup.validateLogin(testInfo);
|
|
57
63
|
}
|
|
58
|
-
return
|
|
64
|
+
return true;
|
|
59
65
|
}
|
|
60
66
|
var _default = exports.default = {
|
|
61
67
|
page: async ({
|
|
@@ -63,45 +69,37 @@ var _default = exports.default = {
|
|
|
63
69
|
$tags,
|
|
64
70
|
page
|
|
65
71
|
}, use) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//This block is used to skip the login process if the @unauthenticated tag is added to the script
|
|
75
|
-
if ($tags.includes('@unauthenticated')) {
|
|
76
|
-
await context.clearCookies();
|
|
77
|
-
await use(page);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const testPortalDetails = getCustomAccountDetails($tags);
|
|
81
|
-
if (testPortalDetails === null) {
|
|
82
|
-
await performDefaultPageSteps({
|
|
83
|
-
context,
|
|
84
|
-
$tags,
|
|
85
|
-
page
|
|
86
|
-
});
|
|
87
|
-
const user = (0, _auth.getDefaultActor)();
|
|
88
|
-
process.env.actorInfo = JSON.stringify(user);
|
|
89
|
-
await use(page);
|
|
90
|
-
} else {
|
|
91
|
-
await context.clearCookies();
|
|
72
|
+
try {
|
|
73
|
+
//This block is used to skip the login process if the @unauthenticated tag is added to the script
|
|
74
|
+
if ($tags.includes('@unauthenticated')) {
|
|
75
|
+
await context.clearCookies();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
92
78
|
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
isAuthMode
|
|
80
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
81
|
+
if (!isAuthMode) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const testPortalDetails = getCustomAccountDetails($tags);
|
|
85
|
+
if (testPortalDetails) {
|
|
86
|
+
await context.clearCookies();
|
|
87
|
+
const {
|
|
88
|
+
email
|
|
89
|
+
} = testPortalDetails;
|
|
90
|
+
await (0, _auth.performLoginSteps)({
|
|
91
|
+
page,
|
|
92
|
+
$tags,
|
|
93
|
+
context,
|
|
94
|
+
...testPortalDetails
|
|
95
|
+
}, async testInfo => {
|
|
96
|
+
return await verifyPageIsLoaded(testInfo);
|
|
97
|
+
}, loginSteps);
|
|
98
|
+
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Error during page', error);
|
|
102
|
+
} finally {
|
|
105
103
|
await performDefaultPageSteps({
|
|
106
104
|
context,
|
|
107
105
|
$tags,
|
|
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CUSTOM_COMMANDS = void 0;
|
|
7
|
-
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath'];
|
|
7
|
+
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition', 'browsers', 'filePath', 'headless'];
|
|
@@ -8,41 +8,41 @@ exports.default = void 0;
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _fileMutex = _interopRequireDefault(require("../fileMutex"));
|
|
10
10
|
var _fileMutexConfig = require("../../constants/fileMutexConfig");
|
|
11
|
-
var _accountLogin = _interopRequireDefault(require("./accountLogin"));
|
|
12
11
|
var _checkAuthCookies = require("./checkAuthCookies");
|
|
13
12
|
var _checkAuthDirectory = require("../checkAuthDirectory");
|
|
14
13
|
/* eslint-disable no-console */
|
|
15
14
|
|
|
16
|
-
async function performLoginSteps({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
15
|
+
async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
16
|
+
let {
|
|
17
|
+
page,
|
|
18
|
+
authFilePrefix,
|
|
19
|
+
email
|
|
20
|
+
} = testInfo;
|
|
21
|
+
authFilePrefix = authFilePrefix || email;
|
|
22
22
|
const authFile = _path.default.resolve(_path.default.join((0, _checkAuthCookies.getAuthFileDirectory)(), `${authFilePrefix}-cookies.json`));
|
|
23
|
-
const lockFileName =
|
|
23
|
+
const lockFileName = email.replace(/[@.]/g, '_');
|
|
24
24
|
const fileMutex = new _fileMutex.default((0, _checkAuthDirectory.getLockDirectoryPath)(), lockFileName, _fileMutexConfig.LOGIN_MUTEX_TIMEOUT);
|
|
25
25
|
try {
|
|
26
26
|
await fileMutex.acquire();
|
|
27
27
|
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
28
28
|
await page.goto(process.env.domain);
|
|
29
29
|
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
30
|
-
const isAlreadyLoggedIn = await isLoggedIn(
|
|
30
|
+
const isAlreadyLoggedIn = await isLoggedIn(testInfo);
|
|
31
31
|
if (!isAlreadyLoggedIn) {
|
|
32
|
-
await (
|
|
32
|
+
await loginSteps(testInfo);
|
|
33
33
|
await page.goto(process.env.domain);
|
|
34
|
-
await isLoggedIn(
|
|
34
|
+
await isLoggedIn(testInfo);
|
|
35
35
|
await page.context().storageState({
|
|
36
36
|
path: authFile
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
} catch (error) {
|
|
40
|
-
console.error(`Error during login for ${
|
|
40
|
+
console.error(`Error during login for ${email}:`, error);
|
|
41
41
|
} finally {
|
|
42
42
|
try {
|
|
43
43
|
await fileMutex.release();
|
|
44
44
|
} catch (releaseError) {
|
|
45
|
-
console.error(`Error releasing lock for ${
|
|
45
|
+
console.error(`Error releasing lock for ${email}:`, releaseError);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -21,13 +21,13 @@ class FileMutex {
|
|
|
21
21
|
}
|
|
22
22
|
async acquire() {
|
|
23
23
|
_assertClassBrand(_FileMutex_brand, this, _createDirectoryIfNotExist).call(this);
|
|
24
|
-
const lockFilePath =
|
|
24
|
+
const lockFilePath = _assertClassBrand(_FileMutex_brand, this, _getLockFilePath).call(this);
|
|
25
25
|
try {
|
|
26
26
|
if (!(0, _fs.existsSync)(lockFilePath)) {
|
|
27
27
|
console.log(`[DEBUG] Creating missing lock file:`, this.lockFileName);
|
|
28
28
|
(0, _fs.writeFileSync)(lockFilePath, 'locked');
|
|
29
29
|
}
|
|
30
|
-
await _properLockfile.default.lock(
|
|
30
|
+
await _properLockfile.default.lock(lockFilePath, this.options);
|
|
31
31
|
} catch (err) {
|
|
32
32
|
throw new Error(`Failed to acquire lock after ${this.options.retries.retries} attempts: ${err.message}`);
|
|
33
33
|
}
|
|
@@ -25,7 +25,8 @@ const {
|
|
|
25
25
|
featureFilesFolder,
|
|
26
26
|
stepDefinitionsFolder,
|
|
27
27
|
testIdAttribute,
|
|
28
|
-
globalTimeout
|
|
28
|
+
globalTimeout,
|
|
29
|
+
customReporter
|
|
29
30
|
} = uatConfig;
|
|
30
31
|
const projects = (0, _configUtils.getProjects)({
|
|
31
32
|
browsers,
|
|
@@ -45,6 +46,13 @@ const use = {
|
|
|
45
46
|
viewport,
|
|
46
47
|
testIdAttribute
|
|
47
48
|
};
|
|
49
|
+
let reporter = [['html', {
|
|
50
|
+
outputFolder: reportPath,
|
|
51
|
+
open: openReportOn
|
|
52
|
+
}], ['list'], ['./custom-reporter.js']];
|
|
53
|
+
if (customReporter) {
|
|
54
|
+
reporter = [customReporter, ...reporter];
|
|
55
|
+
}
|
|
48
56
|
|
|
49
57
|
/**
|
|
50
58
|
* Playwright configuration object
|
|
@@ -57,10 +65,7 @@ function getPlaywrightConfig() {
|
|
|
57
65
|
globalTimeout: globalTimeout || 3600000,
|
|
58
66
|
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
59
67
|
fullyParallel: true,
|
|
60
|
-
reporter
|
|
61
|
-
outputFolder: reportPath,
|
|
62
|
-
open: openReportOn
|
|
63
|
-
}], ['list'], ['./custom-reporter.js']],
|
|
68
|
+
reporter,
|
|
64
69
|
timeout: testTimeout,
|
|
65
70
|
expect: {
|
|
66
71
|
timeout: expectTimeout
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// This is the sample file generated by testing framework. You can change as per the respective project login
|
|
2
|
+
|
|
3
|
+
const getUrlOrigin = require('../shared/url-helpers/getUrlOrigin');
|
|
4
|
+
|
|
5
|
+
async function accountLogin( { page, email, password } ) {
|
|
6
|
+
await page.locator('#login_id').fill(email);
|
|
7
|
+
await page.locator('#nextbtn').click();
|
|
8
|
+
await page.locator('#password').fill(password);
|
|
9
|
+
await page.locator('#nextbtn').click();
|
|
10
|
+
|
|
11
|
+
const domainUrlOrigin = getUrlOrigin(process.env.domain);
|
|
12
|
+
await page.waitForNavigation();
|
|
13
|
+
await Promise.race([
|
|
14
|
+
page.waitForURL(`${domainUrlOrigin}/**`),
|
|
15
|
+
page.waitForURL('**/announcement/**')
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = accountLogin;
|
|
@@ -5,17 +5,11 @@ import {
|
|
|
5
5
|
getDefaultActor
|
|
6
6
|
} from '@zohodesk/testinglibrary/helpers';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { loginSteps , validateLogin } from './testSetup';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
//Implement your validation steps here
|
|
12
|
-
//Refer desk_client_app auth.setup.js
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
10
|
+
const user = getDefaultActor();
|
|
15
11
|
|
|
16
12
|
setup(`${user.edition} - Authentication`, async ({ page }) => {
|
|
17
|
-
|
|
18
13
|
//Implement performLoginSteps here
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
14
|
+
await performLoginSteps({page, ...user},validateLogin ,loginSteps);
|
|
15
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable global-require */
|
|
2
|
+
const accountLogin = require('./accountLogin');
|
|
3
|
+
|
|
4
|
+
async function verifyPageIsLoaded({page}) {
|
|
5
|
+
|
|
6
|
+
//Implement your validation logic here
|
|
7
|
+
//Refer deskclientapp testSetup.js
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
loginSteps:accountLogin,
|
|
12
|
+
validateLogin:verifyPageIsLoaded,
|
|
13
|
+
page:()=>{}
|
|
14
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const testSetup = require('../../fixtures/testSetup');
|
|
1
2
|
/**
|
|
2
3
|
* @typedef {Object|null} viewportConfig
|
|
3
4
|
* @property {number} width - width of the viewport
|
|
@@ -40,5 +41,6 @@ module.exports = {
|
|
|
40
41
|
bddMode: true,
|
|
41
42
|
featureFilesFolder: 'feature-files',
|
|
42
43
|
stepDefinitionsFolder: 'steps',
|
|
43
|
-
viewport: { width: 1280, height: 720 }
|
|
44
|
+
viewport: { width: 1280, height: 720 },
|
|
45
|
+
testSetup
|
|
44
46
|
}
|
|
@@ -73,6 +73,10 @@ function createAuthenticationFile() {
|
|
|
73
73
|
}
|
|
74
74
|
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'auth.setup.js'), getSetupFileAsString('auth-setup-sample.js'), null, 2);
|
|
75
75
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating Authentication File ....');
|
|
76
|
+
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'accountLogin.js'), getSetupFileAsString('accountLogin-sample.js'), null, 2);
|
|
77
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating login script File ....');
|
|
78
|
+
(0, _fs.writeFileSync)(_path.default.resolve(process.cwd(), 'uat', 'fixtures', 'testSetup.js'), getSetupFileAsString('testSetup-sample.js'), null, 2);
|
|
79
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Creating testSetup File ....');
|
|
76
80
|
} catch (err) {
|
|
77
81
|
_logger.Logger.error(err);
|
|
78
82
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Something went wrong ! Folder not Created. Please re-initialize npm init-uat');
|