@zohodesk/testinglibrary 2.9.5 → 2.9.7
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/build/core/playwright/builtInFixtures/page.js +46 -64
- package/build/core/playwright/helpers/auth/loginSteps.js +13 -16
- package/build/core/playwright/tagProcessor.js +7 -5
- package/build/core/playwright/test-runner.js +1 -1
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +19 -18
- package/npm-shrinkwrap.json +301 -242
- package/package.json +4 -4
- package/unit_reports/unit-report.html +1 -1
package/.gitlab-ci.yml
CHANGED
|
@@ -14,18 +14,23 @@ stages:
|
|
|
14
14
|
|
|
15
15
|
default:
|
|
16
16
|
cache:
|
|
17
|
-
key: build-cache
|
|
17
|
+
key: node14-build-cache
|
|
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:
|
|
@@ -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
|
|
|
@@ -29,84 +27,68 @@ function getCustomAccountDetails(tags) {
|
|
|
29
27
|
const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
|
|
30
28
|
return user;
|
|
31
29
|
}
|
|
32
|
-
return
|
|
30
|
+
return (0, _auth.getDefaultActor)();
|
|
33
31
|
}
|
|
34
32
|
const {
|
|
35
33
|
testSetup
|
|
36
34
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
37
|
-
async function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await testSetup.page({
|
|
44
|
-
context,
|
|
45
|
-
$tags,
|
|
46
|
-
page
|
|
47
|
-
});
|
|
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);
|
|
48
41
|
} else {
|
|
49
42
|
await page.goto(process.env.domain);
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
|
-
async function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
async function performDefaultPageSteps(testInfo) {
|
|
46
|
+
if (testSetup.page && typeof testSetup.page === 'function') {
|
|
47
|
+
await testSetup.page(testInfo);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function verifyPageIsLoaded(testInfo) {
|
|
51
|
+
if (testSetup.validateLogin && typeof testSetup.validateLogin === 'function') {
|
|
52
|
+
return await testSetup.validateLogin(testInfo);
|
|
57
53
|
}
|
|
58
|
-
return
|
|
54
|
+
return true;
|
|
59
55
|
}
|
|
60
56
|
var _default = exports.default = {
|
|
61
57
|
page: async ({
|
|
62
58
|
context,
|
|
63
59
|
$tags,
|
|
64
60
|
page
|
|
65
|
-
}, use) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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();
|
|
61
|
+
}, use, testInfo) => {
|
|
62
|
+
let testPortalDetails = getCustomAccountDetails($tags);
|
|
63
|
+
let testDetails = {
|
|
64
|
+
page,
|
|
65
|
+
$tags,
|
|
66
|
+
context,
|
|
67
|
+
...testPortalDetails
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
//This block is used to skip the login process if the @unauthenticated tag is added to the script
|
|
71
|
+
if ($tags.includes('@unauthenticated')) {
|
|
72
|
+
await context.clearCookies();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
92
75
|
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
76
|
+
isAuthMode
|
|
77
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
78
|
+
if (!isAuthMode) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (testPortalDetails && testInfo.project.name !== 'setup') {
|
|
82
|
+
await context.clearCookies();
|
|
83
|
+
await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
|
|
84
|
+
return await verifyPageIsLoaded(testInfo);
|
|
85
|
+
}, loginSteps);
|
|
86
|
+
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error('Error during page', e);
|
|
90
|
+
} finally {
|
|
91
|
+
await performDefaultPageSteps(testDetails);
|
|
110
92
|
await use(page);
|
|
111
93
|
await context.close();
|
|
112
94
|
}
|
|
@@ -8,41 +8,38 @@ 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
|
-
await
|
|
29
|
-
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
30
|
-
const isAlreadyLoggedIn = await isLoggedIn(page);
|
|
28
|
+
const isAlreadyLoggedIn = await isLoggedIn(testInfo);
|
|
31
29
|
if (!isAlreadyLoggedIn) {
|
|
32
|
-
await (
|
|
33
|
-
await
|
|
34
|
-
await isLoggedIn(page);
|
|
30
|
+
await loginSteps(testInfo);
|
|
31
|
+
await isLoggedIn(testInfo);
|
|
35
32
|
await page.context().storageState({
|
|
36
33
|
path: authFile
|
|
37
34
|
});
|
|
38
35
|
}
|
|
39
36
|
} catch (error) {
|
|
40
|
-
console.error(`Error during login for ${
|
|
37
|
+
console.error(`Error during login for ${email}:`, error);
|
|
41
38
|
} finally {
|
|
42
39
|
try {
|
|
43
40
|
await fileMutex.release();
|
|
44
41
|
} catch (releaseError) {
|
|
45
|
-
console.error(`Error releasing lock for ${
|
|
42
|
+
console.error(`Error releasing lock for ${email}:`, releaseError);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
}
|
|
@@ -10,12 +10,14 @@ class TagProcessor {
|
|
|
10
10
|
_classPrivateMethodInitSpec(this, _TagProcessor_brand);
|
|
11
11
|
this.editionOrder = editionOrder;
|
|
12
12
|
}
|
|
13
|
-
processTags(
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
processTags(config) {
|
|
14
|
+
const {
|
|
15
|
+
tags,
|
|
16
|
+
edition
|
|
17
|
+
} = config.getAll();
|
|
18
|
+
if (!edition) return tags;
|
|
17
19
|
const editionsArray = edition.split(',');
|
|
18
|
-
const editionTags = editionsArray.length === 1 ? _assertClassBrand(_TagProcessor_brand, this, _processSingleEdition).call(this, editionsArray[0],
|
|
20
|
+
const editionTags = editionsArray.length === 1 ? _assertClassBrand(_TagProcessor_brand, this, _processSingleEdition).call(this, editionsArray[0], tags) : _assertClassBrand(_TagProcessor_brand, this, _processMultipleEditions).call(this, editionsArray, tags);
|
|
19
21
|
return editionTags;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -104,7 +104,7 @@ function main() {
|
|
|
104
104
|
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
105
105
|
const userArgsObject = userArgConfig.getAll();
|
|
106
106
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
107
|
-
const tagArgs = tagProcessor.processTags(
|
|
107
|
+
const tagArgs = tagProcessor.processTags(uatConfig);
|
|
108
108
|
const runnerObj = new _Runner.default();
|
|
109
109
|
runnerObj.setTagArgs(tagArgs);
|
|
110
110
|
runnerObj.setUserArgs(userArgsObject);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _tagProcessor = _interopRequireDefault(require("../../../../../src/core/playwright/tagProcessor"));
|
|
5
|
+
var _Configuration = _interopRequireDefault(require("../../../../../src/core/playwright/configuration/Configuration.js"));
|
|
5
6
|
var _logger = require("../../../../utils/logger");
|
|
6
7
|
jest.mock('../../../../utils/logger');
|
|
7
8
|
describe('TagProcessor', () => {
|
|
@@ -11,83 +12,83 @@ describe('TagProcessor', () => {
|
|
|
11
12
|
});
|
|
12
13
|
test('should return tagArgs if no edition is provided', () => {
|
|
13
14
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
14
|
-
const userArgs = {
|
|
15
|
+
const userArgs = new _Configuration.default({
|
|
15
16
|
tags: 'tag1',
|
|
16
17
|
edition: null
|
|
17
|
-
};
|
|
18
|
+
});
|
|
18
19
|
const result = tagProcessor.processTags(userArgs);
|
|
19
20
|
expect(result).toBe('tag1');
|
|
20
21
|
});
|
|
21
22
|
test('should handle a single edition with <= operator', () => {
|
|
22
23
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
23
|
-
const userArgs = {
|
|
24
|
+
const userArgs = new _Configuration.default({
|
|
24
25
|
tags: 'tag1',
|
|
25
26
|
edition: '<=edition2'
|
|
26
|
-
};
|
|
27
|
+
});
|
|
27
28
|
const result = tagProcessor.processTags(userArgs);
|
|
28
29
|
expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
|
|
29
30
|
});
|
|
30
31
|
test('should handle a single edition with >= operator', () => {
|
|
31
32
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
32
|
-
const userArgs = {
|
|
33
|
+
const userArgs = new _Configuration.default({
|
|
33
34
|
tags: 'tag1',
|
|
34
35
|
edition: '>=edition2'
|
|
35
|
-
};
|
|
36
|
+
});
|
|
36
37
|
const result = tagProcessor.processTags(userArgs);
|
|
37
38
|
expect(result).toBe('tag1 and not (@edition_edition1)');
|
|
38
39
|
});
|
|
39
40
|
test('should handle a single edition with < operator', () => {
|
|
40
41
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
41
|
-
const userArgs = {
|
|
42
|
+
const userArgs = new _Configuration.default({
|
|
42
43
|
tags: 'tag1',
|
|
43
44
|
edition: '<edition3'
|
|
44
|
-
};
|
|
45
|
+
});
|
|
45
46
|
const result = tagProcessor.processTags(userArgs);
|
|
46
47
|
expect(result).toBe('tag1 and not (@edition_edition3 or @edition_edition4)');
|
|
47
48
|
});
|
|
48
49
|
test('should handle a single edition with > operator', () => {
|
|
49
50
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
50
|
-
const userArgs = {
|
|
51
|
+
const userArgs = new _Configuration.default({
|
|
51
52
|
tags: 'tag1',
|
|
52
53
|
edition: '>edition1'
|
|
53
|
-
};
|
|
54
|
+
});
|
|
54
55
|
const result = tagProcessor.processTags(userArgs);
|
|
55
56
|
expect(result).toBe('tag1 and not (@edition_edition1)');
|
|
56
57
|
});
|
|
57
58
|
test('should handle a single edition with no operator', () => {
|
|
58
59
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
59
|
-
const userArgs = {
|
|
60
|
+
const userArgs = new _Configuration.default({
|
|
60
61
|
tags: 'tag1',
|
|
61
62
|
edition: 'edition2'
|
|
62
|
-
};
|
|
63
|
+
});
|
|
63
64
|
const result = tagProcessor.processTags(userArgs);
|
|
64
65
|
expect(result).toBe('tag1 and not (@edition_edition1 or @edition_edition3 or @edition_edition4)');
|
|
65
66
|
});
|
|
66
67
|
test('should log a message if edition is not found', () => {
|
|
67
68
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
68
|
-
const userArgs = {
|
|
69
|
+
const userArgs = new _Configuration.default({
|
|
69
70
|
tags: 'tag1',
|
|
70
71
|
edition: 'nonexistentEdition'
|
|
71
|
-
};
|
|
72
|
+
});
|
|
72
73
|
const result = tagProcessor.processTags(userArgs);
|
|
73
74
|
expect(result).toBe('tag1');
|
|
74
75
|
expect(_logger.Logger.log).toHaveBeenCalledWith(_logger.Logger.INFO_TYPE, expect.stringContaining('No matching editions for nonexistentEdition found.'));
|
|
75
76
|
});
|
|
76
77
|
test('should handle multiple editions', () => {
|
|
77
78
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
78
|
-
const userArgs = {
|
|
79
|
+
const userArgs = new _Configuration.default({
|
|
79
80
|
tags: 'tag1',
|
|
80
81
|
edition: 'edition1,edition3'
|
|
81
|
-
};
|
|
82
|
+
});
|
|
82
83
|
const result = tagProcessor.processTags(userArgs);
|
|
83
84
|
expect(result).toBe('tag1 and not (@edition_edition2 or @edition_edition4)');
|
|
84
85
|
});
|
|
85
86
|
test('should build tags correctly when tags are empty', () => {
|
|
86
87
|
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
87
|
-
const userArgs = {
|
|
88
|
+
const userArgs = new _Configuration.default({
|
|
88
89
|
tags: '',
|
|
89
90
|
edition: 'edition1'
|
|
90
|
-
};
|
|
91
|
+
});
|
|
91
92
|
const result = tagProcessor.processTags(userArgs);
|
|
92
93
|
expect(result).toBe('not (@edition_edition2 or @edition_edition3 or @edition_edition4)');
|
|
93
94
|
});
|