@zohodesk/testinglibrary 3.0.8 → 3.0.9
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/build/core/playwright/builtInFixtures/page.js +16 -32
- package/build/core/playwright/clear-caches.js +7 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +0 -3
- package/build/core/playwright/helpers/configFileNameProvider.js +1 -1
- package/build/core/playwright/setup/config-creator.js +3 -1
- package/build/index.js +6 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +1 -1
- package/npm-shrinkwrap.json +644 -1389
- package/package.json +5 -5
|
@@ -27,7 +27,7 @@ function getCustomAccountDetails(tags) {
|
|
|
27
27
|
const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
|
|
28
28
|
return user;
|
|
29
29
|
}
|
|
30
|
-
return
|
|
30
|
+
return (0, _auth.getDefaultActor)();
|
|
31
31
|
}
|
|
32
32
|
const {
|
|
33
33
|
testSetup
|
|
@@ -42,19 +42,9 @@ async function loginSteps(pageDetail) {
|
|
|
42
42
|
await page.goto(process.env.domain);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
async function performDefaultPageSteps({
|
|
46
|
-
context,
|
|
47
|
-
$tags,
|
|
48
|
-
page
|
|
49
|
-
}) {
|
|
45
|
+
async function performDefaultPageSteps(testInfo) {
|
|
50
46
|
if (testSetup.page && typeof testSetup.page === 'function') {
|
|
51
|
-
await testSetup.page(
|
|
52
|
-
context,
|
|
53
|
-
$tags,
|
|
54
|
-
page
|
|
55
|
-
});
|
|
56
|
-
} else {
|
|
57
|
-
await page.goto(process.env.domain);
|
|
47
|
+
await testSetup.page(testInfo);
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
async function verifyPageIsLoaded(testInfo) {
|
|
@@ -68,7 +58,14 @@ var _default = exports.default = {
|
|
|
68
58
|
context,
|
|
69
59
|
$tags,
|
|
70
60
|
page
|
|
71
|
-
}, use) => {
|
|
61
|
+
}, use, testInfo) => {
|
|
62
|
+
let testPortalDetails = getCustomAccountDetails($tags);
|
|
63
|
+
let testDetails = {
|
|
64
|
+
page,
|
|
65
|
+
$tags,
|
|
66
|
+
context,
|
|
67
|
+
...testPortalDetails
|
|
68
|
+
};
|
|
72
69
|
try {
|
|
73
70
|
//This block is used to skip the login process if the @unauthenticated tag is added to the script
|
|
74
71
|
if ($tags.includes('@unauthenticated')) {
|
|
@@ -81,30 +78,17 @@ var _default = exports.default = {
|
|
|
81
78
|
if (!isAuthMode) {
|
|
82
79
|
return;
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
if (testPortalDetails) {
|
|
81
|
+
if (testPortalDetails && testInfo.project.name !== 'setup') {
|
|
86
82
|
await context.clearCookies();
|
|
87
|
-
|
|
88
|
-
email
|
|
89
|
-
} = testPortalDetails;
|
|
90
|
-
await (0, _auth.performLoginSteps)({
|
|
91
|
-
page,
|
|
92
|
-
$tags,
|
|
93
|
-
context,
|
|
94
|
-
...testPortalDetails
|
|
95
|
-
}, async testInfo => {
|
|
83
|
+
await (0, _auth.performLoginSteps)(testDetails, async testInfo => {
|
|
96
84
|
return await verifyPageIsLoaded(testInfo);
|
|
97
85
|
}, loginSteps);
|
|
98
86
|
process.env.actorInfo = JSON.stringify(testPortalDetails);
|
|
99
87
|
}
|
|
100
|
-
} catch (
|
|
101
|
-
console.error('Error during page',
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error('Error during page', e);
|
|
102
90
|
} finally {
|
|
103
|
-
await performDefaultPageSteps(
|
|
104
|
-
context,
|
|
105
|
-
$tags,
|
|
106
|
-
page
|
|
107
|
-
});
|
|
91
|
+
await performDefaultPageSteps(testDetails);
|
|
108
92
|
await use(page);
|
|
109
93
|
await context.close();
|
|
110
94
|
}
|
|
@@ -9,6 +9,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
var _fileUtils = require("../../utils/fileUtils");
|
|
10
10
|
var _logger = require("../../utils/logger");
|
|
11
11
|
var _readConfigFile = require("./readConfigFile");
|
|
12
|
+
var _checkAuthDirectory = require("./helpers/checkAuthDirectory");
|
|
12
13
|
function deleteAuthFiles(authFilePath) {
|
|
13
14
|
authFilePath = _path.default.resolve(process.cwd(), authFilePath);
|
|
14
15
|
const authFileFolder = _path.default.dirname(authFilePath);
|
|
@@ -24,6 +25,11 @@ function deleteGeneratedFeatures() {
|
|
|
24
25
|
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting generated features at ${featuresGenPath}`);
|
|
25
26
|
(0, _fileUtils.deleteFolder)(featuresGenPath);
|
|
26
27
|
}
|
|
28
|
+
function deleteLockFiles() {
|
|
29
|
+
const lockFilePath = (0, _checkAuthDirectory.getLockDirectoryPath)();
|
|
30
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting lock files at ${lockFilePath}`);
|
|
31
|
+
(0, _fileUtils.deleteFolder)(lockFilePath);
|
|
32
|
+
}
|
|
27
33
|
function clearCaches() {
|
|
28
34
|
try {
|
|
29
35
|
const {
|
|
@@ -33,6 +39,7 @@ function clearCaches() {
|
|
|
33
39
|
deleteAuthFiles(authFilePath);
|
|
34
40
|
deletePlaywrightReport(reportPath);
|
|
35
41
|
deleteGeneratedFeatures();
|
|
42
|
+
deleteLockFiles();
|
|
36
43
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Caches Cleared. Now you can try running npm run uat');
|
|
37
44
|
} catch (err) {
|
|
38
45
|
_logger.Logger.error(err);
|
|
@@ -25,12 +25,9 @@ async function performLoginSteps(testInfo, isLoggedIn, loginSteps) {
|
|
|
25
25
|
try {
|
|
26
26
|
await fileMutex.acquire();
|
|
27
27
|
await (0, _checkAuthCookies.loadCookiesIfPresent)(page, authFile);
|
|
28
|
-
await page.goto(process.env.domain);
|
|
29
|
-
await Promise.race([page.waitForNavigation(), page.waitForLoadState('networkidle'), page.waitForTimeout(5000)]);
|
|
30
28
|
const isAlreadyLoggedIn = await isLoggedIn(testInfo);
|
|
31
29
|
if (!isAlreadyLoggedIn) {
|
|
32
30
|
await loginSteps(testInfo);
|
|
33
|
-
await page.goto(process.env.domain);
|
|
34
31
|
await isLoggedIn(testInfo);
|
|
35
32
|
await page.context().storageState({
|
|
36
33
|
path: authFile
|
|
@@ -16,7 +16,7 @@ function getUATFileName(mode) {
|
|
|
16
16
|
if (_fs.default.existsSync(uatConfFilePath)) {
|
|
17
17
|
return uatConfFilePath;
|
|
18
18
|
}
|
|
19
|
-
return _path.default.resolve(process.cwd(), `uat.config.js`);
|
|
19
|
+
return _path.default.resolve(process.cwd(), `uat/conf/default/uat.config.js`);
|
|
20
20
|
}
|
|
21
21
|
function getEnvConfigFilePath(mode) {
|
|
22
22
|
const confFilePath = _path.default.resolve(process.cwd(), `uat/conf/${mode}/settings.json`);
|
|
@@ -49,7 +49,9 @@ const use = {
|
|
|
49
49
|
let reporter = [['html', {
|
|
50
50
|
outputFolder: reportPath,
|
|
51
51
|
open: openReportOn
|
|
52
|
-
}], ['list'], ['
|
|
52
|
+
}], ['list'], ['json', {
|
|
53
|
+
outputFile: _path.default.join(process.cwd(), 'uat', 'test-results', 'test-results.json')
|
|
54
|
+
}], ['./custom-reporter.js']];
|
|
53
55
|
if (customReporter) {
|
|
54
56
|
reporter = [customReporter, ...reporter];
|
|
55
57
|
}
|
package/build/index.js
CHANGED
|
@@ -70,6 +70,12 @@ Object.defineProperty(exports, "performLoginSteps", {
|
|
|
70
70
|
return _index.performLoginSteps;
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
+
Object.defineProperty(exports, "setup", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return _index.setup;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
73
79
|
Object.defineProperty(exports, "test", {
|
|
74
80
|
enumerable: true,
|
|
75
81
|
get: function () {
|
|
@@ -24,7 +24,7 @@ describe('getUATFileName', () => {
|
|
|
24
24
|
});
|
|
25
25
|
test('return the default config files for pipeline matched files not exists', () => {
|
|
26
26
|
const mode = 'ci';
|
|
27
|
-
const defaultPath = `${mockCwd}/uat.config.js`;
|
|
27
|
+
const defaultPath = `${mockCwd}/uat/conf/default/uat.config.js`;
|
|
28
28
|
_fs.existsSync.mockReturnValue(false);
|
|
29
29
|
_path.default.resolve.mockImplementation((...args) => args.join('/'));
|
|
30
30
|
const result = (0, _configFileNameProvider.getUATFileName)(mode);
|