@playq/core 0.2.77
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/README.md +41 -0
- package/bin/playq.js +175 -0
- package/cucumber.js +10 -0
- package/dist/exec/featureFileCache.d.ts +21 -0
- package/dist/exec/featureFileCache.js +124 -0
- package/dist/exec/featureFilePreProcess.d.ts +12 -0
- package/dist/exec/featureFilePreProcess.js +208 -0
- package/dist/exec/preLoader.d.ts +1 -0
- package/dist/exec/preLoader.js +72 -0
- package/dist/exec/preProcessEntry.d.ts +1 -0
- package/dist/exec/preProcessEntry.js +83 -0
- package/dist/exec/preProcess_old_todelete.d.ts +1 -0
- package/dist/exec/preProcess_old_todelete.js +258 -0
- package/dist/exec/runner.d.ts +1 -0
- package/dist/exec/runner.js +221 -0
- package/dist/exec/runner_orchestrator.d.ts +1 -0
- package/dist/exec/runner_orchestrator.js +85 -0
- package/dist/exec/sgGenerator.d.ts +11 -0
- package/dist/exec/sgGenerator.js +310 -0
- package/dist/global.d.ts +15 -0
- package/dist/global.js +185 -0
- package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
- package/dist/helper/actions/api/apiRequestActions.js +374 -0
- package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
- package/dist/helper/actions/api/apiValidationActions.js +615 -0
- package/dist/helper/actions/apiActions.d.ts +18 -0
- package/dist/helper/actions/apiActions.js +34 -0
- package/dist/helper/actions/apiStepDefs.d.ts +1 -0
- package/dist/helper/actions/apiStepDefs.js +64 -0
- package/dist/helper/actions/comm/commonActions.d.ts +58 -0
- package/dist/helper/actions/comm/commonActions.js +198 -0
- package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
- package/dist/helper/actions/comm/utilityActions.js +351 -0
- package/dist/helper/actions/commActions.d.ts +18 -0
- package/dist/helper/actions/commActions.js +34 -0
- package/dist/helper/actions/commStepDefs.d.ts +1 -0
- package/dist/helper/actions/commStepDefs.js +57 -0
- package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
- package/dist/helper/actions/stepGroupStepDefs.js +15 -0
- package/dist/helper/actions/web/alertActions.d.ts +61 -0
- package/dist/helper/actions/web/alertActions.js +224 -0
- package/dist/helper/actions/web/cookieActions.d.ts +45 -0
- package/dist/helper/actions/web/cookieActions.js +186 -0
- package/dist/helper/actions/web/downloadActions.d.ts +40 -0
- package/dist/helper/actions/web/downloadActions.js +153 -0
- package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
- package/dist/helper/actions/web/elementReaderActions.js +326 -0
- package/dist/helper/actions/web/formActions.d.ts +122 -0
- package/dist/helper/actions/web/formActions.js +423 -0
- package/dist/helper/actions/web/iframeActions.d.ts +23 -0
- package/dist/helper/actions/web/iframeActions.js +108 -0
- package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
- package/dist/helper/actions/web/javascriptActions.js +77 -0
- package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
- package/dist/helper/actions/web/keyboardActions.js +118 -0
- package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
- package/dist/helper/actions/web/localStorageActions.js +163 -0
- package/dist/helper/actions/web/mouseActions.d.ts +240 -0
- package/dist/helper/actions/web/mouseActions.js +609 -0
- package/dist/helper/actions/web/reportingActions.d.ts +34 -0
- package/dist/helper/actions/web/reportingActions.js +58 -0
- package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
- package/dist/helper/actions/web/screenshotActions.js +151 -0
- package/dist/helper/actions/web/testDataActions.d.ts +21 -0
- package/dist/helper/actions/web/testDataActions.js +211 -0
- package/dist/helper/actions/web/validationActions.d.ts +547 -0
- package/dist/helper/actions/web/validationActions.js +1754 -0
- package/dist/helper/actions/web/waitActions.d.ts +191 -0
- package/dist/helper/actions/web/waitActions.js +589 -0
- package/dist/helper/actions/web/webNavigation.d.ts +104 -0
- package/dist/helper/actions/web/webNavigation.js +288 -0
- package/dist/helper/actions/webActions.d.ts +32 -0
- package/dist/helper/actions/webActions.js +48 -0
- package/dist/helper/actions/webStepDefs.d.ts +1 -0
- package/dist/helper/actions/webStepDefs.js +455 -0
- package/dist/helper/browsers/browserManager.d.ts +1 -0
- package/dist/helper/browsers/browserManager.js +56 -0
- package/dist/helper/bundle/defaultEntries.d.ts +6 -0
- package/dist/helper/bundle/defaultEntries.js +200 -0
- package/dist/helper/bundle/env.d.ts +1 -0
- package/dist/helper/bundle/env.js +157 -0
- package/dist/helper/bundle/vars.d.ts +9 -0
- package/dist/helper/bundle/vars.js +375 -0
- package/dist/helper/faker/customFaker.d.ts +55 -0
- package/dist/helper/faker/customFaker.js +45 -0
- package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/dist/helper/faker/modules/dateTime.d.ts +18 -0
- package/dist/helper/faker/modules/dateTime.js +106 -0
- package/dist/helper/faker/modules/mobile.d.ts +4 -0
- package/dist/helper/faker/modules/mobile.js +59 -0
- package/dist/helper/faker/modules/nric.d.ts +32 -0
- package/dist/helper/faker/modules/nric.js +84 -0
- package/dist/helper/faker/modules/passport.d.ts +3 -0
- package/dist/helper/faker/modules/passport.js +36 -0
- package/dist/helper/faker/modules/person.d.ts +14 -0
- package/dist/helper/faker/modules/person.js +73 -0
- package/dist/helper/faker/modules/postcode.d.ts +6 -0
- package/dist/helper/faker/modules/postcode.js +47 -0
- package/dist/helper/fixtures/locAggregate.d.ts +7 -0
- package/dist/helper/fixtures/locAggregate.js +94 -0
- package/dist/helper/fixtures/logFixture.d.ts +8 -0
- package/dist/helper/fixtures/logFixture.js +56 -0
- package/dist/helper/fixtures/webFixture.d.ts +19 -0
- package/dist/helper/fixtures/webFixture.js +186 -0
- package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
- package/dist/helper/fixtures/webLocFixture.js +144 -0
- package/dist/helper/report/allureStepLogger.d.ts +0 -0
- package/dist/helper/report/allureStepLogger.js +25 -0
- package/dist/helper/report/customiseReport.d.ts +1 -0
- package/dist/helper/report/customiseReport.js +55 -0
- package/dist/helper/report/init.d.ts +1 -0
- package/dist/helper/report/init.js +14 -0
- package/dist/helper/report/report.d.ts +1 -0
- package/dist/helper/report/report.js +102 -0
- package/dist/helper/util/dataLoader.d.ts +10 -0
- package/dist/helper/util/dataLoader.js +73 -0
- package/dist/helper/util/logger.d.ts +4 -0
- package/dist/helper/util/logger.js +61 -0
- package/dist/helper/util/session/sessionUtil.d.ts +26 -0
- package/dist/helper/util/session/sessionUtil.js +729 -0
- package/dist/helper/util/stepHelpers.d.ts +2 -0
- package/dist/helper/util/stepHelpers.js +16 -0
- package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
- package/dist/helper/util/test-data/dataLoader.js +145 -0
- package/dist/helper/util/test-data/dataTest.d.ts +10 -0
- package/dist/helper/util/test-data/dataTest.js +216 -0
- package/dist/helper/util/totp/totpHelper.d.ts +38 -0
- package/dist/helper/util/totp/totpHelper.js +117 -0
- package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
- package/dist/helper/util/utilities/cryptoUtil.js +53 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
- package/dist/helper/util/utils.d.ts +2 -0
- package/dist/helper/util/utils.js +22 -0
- package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
- package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
- package/dist/helper/wrapper/assert.d.ts +9 -0
- package/dist/helper/wrapper/assert.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +57 -0
- package/dist/scripts/get-versions.d.ts +1 -0
- package/dist/scripts/get-versions.js +98 -0
- package/dist/scripts/posttest.d.ts +1 -0
- package/dist/scripts/posttest.js +29 -0
- package/dist/scripts/pretest.d.ts +1 -0
- package/dist/scripts/pretest.js +57 -0
- package/dist/scripts/util.d.ts +1 -0
- package/dist/scripts/util.js +376 -0
- package/package.json +68 -0
- package/src/exec/featureFileCache.ts +80 -0
- package/src/exec/featureFilePreProcess.ts +239 -0
- package/src/exec/preLoader.ts +72 -0
- package/src/exec/preProcessEntry.ts +59 -0
- package/src/exec/preProcess_old_todelete.ts +289 -0
- package/src/exec/runner.ts +241 -0
- package/src/exec/runnerCuke.js +90 -0
- package/src/exec/runner_orchestrator.ts +91 -0
- package/src/exec/sgGenerator.ts +373 -0
- package/src/global.ts +130 -0
- package/src/helper/actions/api/apiRequestActions.ts +362 -0
- package/src/helper/actions/api/apiValidationActions.ts +594 -0
- package/src/helper/actions/apiActions.ts +18 -0
- package/src/helper/actions/apiStepDefs.ts +80 -0
- package/src/helper/actions/comm/commonActions.ts +165 -0
- package/src/helper/actions/comm/utilityActions.ts +344 -0
- package/src/helper/actions/commActions.ts +18 -0
- package/src/helper/actions/commStepDefs.ts +72 -0
- package/src/helper/actions/stepGroupStepDefs.ts +17 -0
- package/src/helper/actions/web/alertActions.ts +179 -0
- package/src/helper/actions/web/cookieActions.ts +124 -0
- package/src/helper/actions/web/downloadActions.ts +129 -0
- package/src/helper/actions/web/elementReaderActions.ts +323 -0
- package/src/helper/actions/web/formActions.ts +469 -0
- package/src/helper/actions/web/iframeActions.ts +67 -0
- package/src/helper/actions/web/javascriptActions.ts +38 -0
- package/src/helper/actions/web/keyboardActions.ts +101 -0
- package/src/helper/actions/web/localStorageActions.ts +109 -0
- package/src/helper/actions/web/mouseActions.ts +864 -0
- package/src/helper/actions/web/reportingActions.ts +53 -0
- package/src/helper/actions/web/screenshotActions.ts +124 -0
- package/src/helper/actions/web/testDataActions.ts +162 -0
- package/src/helper/actions/web/validationActions.ts +2287 -0
- package/src/helper/actions/web/waitActions.ts +757 -0
- package/src/helper/actions/web/webNavigation.ts +313 -0
- package/src/helper/actions/webActions.ts +33 -0
- package/src/helper/actions/webStepDefs.ts +505 -0
- package/src/helper/browsers/browserManager.ts +23 -0
- package/src/helper/bundle/defaultEntries.ts +208 -0
- package/src/helper/bundle/env.ts +119 -0
- package/src/helper/bundle/vars.ts +368 -0
- package/src/helper/faker/customFaker.ts +107 -0
- package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/src/helper/faker/modules/dateTime.ts +121 -0
- package/src/helper/faker/modules/mobile.ts +58 -0
- package/src/helper/faker/modules/nric.ts +109 -0
- package/src/helper/faker/modules/passport.ts +34 -0
- package/src/helper/faker/modules/person.ts +93 -0
- package/src/helper/faker/modules/postcode.ts +57 -0
- package/src/helper/fixtures/locAggregate.ts +61 -0
- package/src/helper/fixtures/logFixture.ts +57 -0
- package/src/helper/fixtures/webFixture.ts +206 -0
- package/src/helper/fixtures/webLocFixture.ts +143 -0
- package/src/helper/report/allureStepLogger.ts +26 -0
- package/src/helper/report/customiseReport.ts +61 -0
- package/src/helper/report/init.ts +18 -0
- package/src/helper/report/report.ts +72 -0
- package/src/helper/util/dataLoader.ts +42 -0
- package/src/helper/util/logger.ts +32 -0
- package/src/helper/util/session/sessionUtil.ts +839 -0
- package/src/helper/util/stepHelpers.ts +14 -0
- package/src/helper/util/test-data/dataLoader.ts +108 -0
- package/src/helper/util/test-data/dataTest.ts +191 -0
- package/src/helper/util/test-data/registerUser.json +7 -0
- package/src/helper/util/totp/totpHelper.ts +102 -0
- package/src/helper/util/utilities/cryptoUtil.ts +53 -0
- package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
- package/src/helper/util/utils.ts +28 -0
- package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
- package/src/helper/wrapper/assert.ts +25 -0
- package/src/index.ts +17 -0
- package/src/scripts/get-versions.ts +68 -0
- package/src/scripts/posttest.ts +32 -0
- package/src/scripts/pretest.ts +48 -0
- package/src/scripts/util.ts +406 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cucumber_1 = require("@cucumber/cucumber");
|
|
4
|
+
const global_1 = require("../../global");
|
|
5
|
+
/**
|
|
6
|
+
* API Step Definitions
|
|
7
|
+
*
|
|
8
|
+
* Cucumber step patterns for API request and validation actions.
|
|
9
|
+
* Mirrors the functions in apiRequestActions.ts and apiValidationActions.ts.
|
|
10
|
+
*/
|
|
11
|
+
(0, cucumber_1.Given)("Api: Call api -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
12
|
+
await global_1.api.callApi(action, config, baseUrl, options);
|
|
13
|
+
});
|
|
14
|
+
(0, cucumber_1.Given)("Api: Get -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
15
|
+
await global_1.api.get(action, config, baseUrl, options);
|
|
16
|
+
});
|
|
17
|
+
(0, cucumber_1.Given)("Api: Post -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
18
|
+
await global_1.api.post(action, config, baseUrl, options);
|
|
19
|
+
});
|
|
20
|
+
(0, cucumber_1.Given)("Api: Request -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
21
|
+
await global_1.api.request(action, config, baseUrl, options);
|
|
22
|
+
});
|
|
23
|
+
(0, cucumber_1.Given)("Api: Put -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
24
|
+
await global_1.api.put(action, config, baseUrl, options);
|
|
25
|
+
});
|
|
26
|
+
(0, cucumber_1.Given)("Api: Patch -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
27
|
+
await global_1.api.patch(action, config, baseUrl, options);
|
|
28
|
+
});
|
|
29
|
+
(0, cucumber_1.Given)("Api: Delete -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (action, config, baseUrl, options) {
|
|
30
|
+
await global_1.api.del(action, config, baseUrl, options);
|
|
31
|
+
});
|
|
32
|
+
(0, cucumber_1.Given)("Api: Send request -method: {param} -action: {param} -config: {param} -baseUrl: {param} -options: {param}", async function (method, action, config, baseUrl, options) {
|
|
33
|
+
await global_1.api.sendRequest(method, action, config, baseUrl, options);
|
|
34
|
+
});
|
|
35
|
+
(0, cucumber_1.Given)("Api: Verify value -actual: {param} -expected: {param} -options: {param}", async function (actual, expected, options) {
|
|
36
|
+
await global_1.api.verifyValue(actual, expected, options);
|
|
37
|
+
});
|
|
38
|
+
(0, cucumber_1.Given)("Api: Assert value -actual: {param} -expected: {param} -options: {param}", async function (actual, expected, options) {
|
|
39
|
+
await global_1.api.assertValue(actual, expected, options);
|
|
40
|
+
});
|
|
41
|
+
(0, cucumber_1.Given)("Api: Verify api path value in last response -path: {param} -expected: {param} -options: {param}", async function (path, expected, options) {
|
|
42
|
+
await global_1.api.verifyPathValue(path, expected, options);
|
|
43
|
+
});
|
|
44
|
+
(0, cucumber_1.Given)("Api: Assert api path value -path: {param} -expected: {param} -options: {param}", async function (path, expected, options) {
|
|
45
|
+
await global_1.api.assertPathValue(path, expected, options);
|
|
46
|
+
});
|
|
47
|
+
(0, cucumber_1.Given)("Api: Get last response JSON path value -path: {param} -storeTo: {param}", async function (pathExpr, varName) {
|
|
48
|
+
const value = await global_1.api.getLastResponseJsonPathValue(pathExpr);
|
|
49
|
+
if (value !== undefined && value !== null) {
|
|
50
|
+
global_1.vars.setValue(varName, String(value));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
(0, cucumber_1.Given)("Api: Store last response JSON paths to variables -paths: {param} -vars: {param}", async function (paths, varsCsv) {
|
|
54
|
+
await global_1.api.storeLastResponseJsonPathsToVariables(paths, varsCsv);
|
|
55
|
+
});
|
|
56
|
+
(0, cucumber_1.Given)("Api: Get path value from last response -path: {param} -storeTo: {param}", async function (pathExpr, varName) {
|
|
57
|
+
const value = await global_1.api.getPathValueFromLastResponse(pathExpr);
|
|
58
|
+
if (value !== undefined && value !== null) {
|
|
59
|
+
global_1.vars.setValue(varName, String(value));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
(0, cucumber_1.Given)("Api: Store paths -paths: {param} -vars: {param}", async function (paths, varsCsv) {
|
|
63
|
+
await global_1.api.storePaths(paths, varsCsv);
|
|
64
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comm: Comment -text: {param}
|
|
3
|
+
*
|
|
4
|
+
* Logs a comment with variable substitution to the console.
|
|
5
|
+
* Useful for adding contextual information to the test log.
|
|
6
|
+
*
|
|
7
|
+
* Variables inside the message string (e.g., ${var.username}) will be replaced using `vars.replaceVariables`.
|
|
8
|
+
*
|
|
9
|
+
* @param message - The comment or message to log.
|
|
10
|
+
*
|
|
11
|
+
* @throws Error if `message` is not a non-empty string.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* Comm: Comment -text: "LAMBDA TEST COMPLETE"
|
|
15
|
+
*/
|
|
16
|
+
export declare function comment(message: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Comm: Store -value: {param} in -variable: {param} -options: {param}
|
|
19
|
+
*
|
|
20
|
+
* Stores a value (with optional variable substitution) into a runtime variable.
|
|
21
|
+
*
|
|
22
|
+
* Variables inside the value string (e.g., ${var.username}) will be resolved using `vars.replaceVariables`.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The value to store (can include variable references).
|
|
25
|
+
* @param varName - The name of the variable to store the resolved value into.
|
|
26
|
+
* @param options - Optional string or object with additional parameters (parsed if string). Currently unused but reserved for future logic.
|
|
27
|
+
*
|
|
28
|
+
* @throws Error if `varName` is not a non-empty string or `value` is undefined/null.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* Store -value: "${faker.string.alphanumeric({length:4})}" in -variable: "var.centre.code" -options: ""
|
|
32
|
+
*/
|
|
33
|
+
export declare function storeValue(value: string, varName: string, options?: string | Record<string, any>): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Comm: Attach-Log -message: {param} -mimeType: {param} -msgType: {param}
|
|
36
|
+
*
|
|
37
|
+
* Attach log or message to the test context (Cucumber or Playwright runner).
|
|
38
|
+
* @param message The message or buffer to attach
|
|
39
|
+
* @param mimeType The mime type (default: text/plain)
|
|
40
|
+
* @param msgType Optional label for the attachment (default: "Log").
|
|
41
|
+
*
|
|
42
|
+
* If `message` is empty or undefined, a warning is logged and no attachment is made.
|
|
43
|
+
*/
|
|
44
|
+
export declare function attachLog(message: string | Buffer, mimeType?: string, msgType?: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Comm: Wait-In-Milli-Seconds -seconds: {param}
|
|
47
|
+
*
|
|
48
|
+
* Pauses execution for a given number of milliseconds.
|
|
49
|
+
* Logs a message using the test logger if available.
|
|
50
|
+
*
|
|
51
|
+
* @param ms - The number of milliseconds to wait.
|
|
52
|
+
*
|
|
53
|
+
* @throws Error if `ms` is not a finite number or is negative.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Comm: Wait-In-Milli-Seconds -seconds: "1000"
|
|
57
|
+
*/
|
|
58
|
+
export declare function waitInMilliSeconds(ms: number): Promise<void>;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.comment = comment;
|
|
37
|
+
exports.storeValue = storeValue;
|
|
38
|
+
exports.attachLog = attachLog;
|
|
39
|
+
exports.waitInMilliSeconds = waitInMilliSeconds;
|
|
40
|
+
const global_1 = require("../../../global");
|
|
41
|
+
const vars_1 = require("../../bundle/vars");
|
|
42
|
+
const allure = __importStar(require("allure-js-commons"));
|
|
43
|
+
function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
|
|
44
|
+
function isCucumberRunner() { return process.env.TEST_RUNNER === 'cucumber'; }
|
|
45
|
+
const __allureAny_comm = allure;
|
|
46
|
+
if (typeof __allureAny_comm.step !== 'function') {
|
|
47
|
+
__allureAny_comm.step = async (_name, fn) => await fn();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Comm: Comment -text: {param}
|
|
51
|
+
*
|
|
52
|
+
* Logs a comment with variable substitution to the console.
|
|
53
|
+
* Useful for adding contextual information to the test log.
|
|
54
|
+
*
|
|
55
|
+
* Variables inside the message string (e.g., ${var.username}) will be replaced using `vars.replaceVariables`.
|
|
56
|
+
*
|
|
57
|
+
* @param message - The comment or message to log.
|
|
58
|
+
*
|
|
59
|
+
* @throws Error if `message` is not a non-empty string.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* Comm: Comment -text: "LAMBDA TEST COMPLETE"
|
|
63
|
+
*/
|
|
64
|
+
async function comment(message) {
|
|
65
|
+
if (typeof message !== 'string' || message.trim().length === 0) {
|
|
66
|
+
throw new Error('❌ comment: message must be a non-empty string.');
|
|
67
|
+
}
|
|
68
|
+
const formattedMessage = global_1.vars.replaceVariables(message);
|
|
69
|
+
if (isPlaywrightRunner()) {
|
|
70
|
+
await __allureAny_comm.step(`Comm: Comment -text: ${formattedMessage}`, async () => {
|
|
71
|
+
console.log(`💬 Comment: ${formattedMessage}`);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.log(`💬 Comment: ${formattedMessage}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Comm: Store -value: {param} in -variable: {param} -options: {param}
|
|
80
|
+
*
|
|
81
|
+
* Stores a value (with optional variable substitution) into a runtime variable.
|
|
82
|
+
*
|
|
83
|
+
* Variables inside the value string (e.g., ${var.username}) will be resolved using `vars.replaceVariables`.
|
|
84
|
+
*
|
|
85
|
+
* @param value - The value to store (can include variable references).
|
|
86
|
+
* @param varName - The name of the variable to store the resolved value into.
|
|
87
|
+
* @param options - Optional string or object with additional parameters (parsed if string). Currently unused but reserved for future logic.
|
|
88
|
+
*
|
|
89
|
+
* @throws Error if `varName` is not a non-empty string or `value` is undefined/null.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* Store -value: "${faker.string.alphanumeric({length:4})}" in -variable: "var.centre.code" -options: ""
|
|
93
|
+
*/
|
|
94
|
+
async function storeValue(value, varName, options) {
|
|
95
|
+
const options_json = typeof options === 'string' ? (0, vars_1.parseLooseJson)(options) : (options || {});
|
|
96
|
+
if (typeof varName !== 'string' || varName.trim().length === 0) {
|
|
97
|
+
throw new Error('❌ storeValue: varName must be a non-empty string.');
|
|
98
|
+
}
|
|
99
|
+
if (value === undefined || value === null) {
|
|
100
|
+
throw new Error('❌ storeValue: value must be provided.');
|
|
101
|
+
}
|
|
102
|
+
const resolvedValue = global_1.vars.replaceVariables(value);
|
|
103
|
+
if (isPlaywrightRunner()) {
|
|
104
|
+
await __allureAny_comm.step(`Comm: Store -value: ${resolvedValue} in -variable: ${varName} -options: ${JSON.stringify(options_json)}`, async () => {
|
|
105
|
+
global_1.vars.setValue(varName, resolvedValue);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
global_1.vars.setValue(varName, resolvedValue);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Comm: Attach-Log -message: {param} -mimeType: {param} -msgType: {param}
|
|
114
|
+
*
|
|
115
|
+
* Attach log or message to the test context (Cucumber or Playwright runner).
|
|
116
|
+
* @param message The message or buffer to attach
|
|
117
|
+
* @param mimeType The mime type (default: text/plain)
|
|
118
|
+
* @param msgType Optional label for the attachment (default: "Log").
|
|
119
|
+
*
|
|
120
|
+
* If `message` is empty or undefined, a warning is logged and no attachment is made.
|
|
121
|
+
*/
|
|
122
|
+
async function attachLog(message, mimeType, msgType) {
|
|
123
|
+
if (message === undefined || message === null || (typeof message === 'string' && message.length === 0)) {
|
|
124
|
+
console.warn('⚠️ attachLog: empty message provided; skipping attachment');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (!mimeType)
|
|
128
|
+
mimeType = "text/plain";
|
|
129
|
+
if (!msgType)
|
|
130
|
+
msgType = "Log";
|
|
131
|
+
if (isCucumberRunner()) {
|
|
132
|
+
const world = global_1.webFixture.getWorld();
|
|
133
|
+
if (world === null || world === void 0 ? void 0 : world.attach) {
|
|
134
|
+
await world.attach(message, mimeType);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
console.warn("⚠️ No World.attach() available in Cucumber context");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (isPlaywrightRunner()) {
|
|
141
|
+
try {
|
|
142
|
+
const anyAllure = allure;
|
|
143
|
+
if (typeof anyAllure.attachment === 'function') {
|
|
144
|
+
anyAllure.attachment(msgType, message, mimeType);
|
|
145
|
+
}
|
|
146
|
+
else if (typeof anyAllure.attach === 'function') {
|
|
147
|
+
anyAllure.attach(msgType || 'Log', message, mimeType);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
if (typeof message === 'string')
|
|
151
|
+
console.log(message);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
if (typeof message === 'string')
|
|
156
|
+
console.log(message);
|
|
157
|
+
}
|
|
158
|
+
// await playwrightTest
|
|
159
|
+
// .info()
|
|
160
|
+
// .attach("Log", { body: message, contentType: mimeType });
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
console.warn("⚠️ attachLog: Unknown runner type");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Comm: Wait-In-Milli-Seconds -seconds: {param}
|
|
168
|
+
*
|
|
169
|
+
* Pauses execution for a given number of milliseconds.
|
|
170
|
+
* Logs a message using the test logger if available.
|
|
171
|
+
*
|
|
172
|
+
* @param ms - The number of milliseconds to wait.
|
|
173
|
+
*
|
|
174
|
+
* @throws Error if `ms` is not a finite number or is negative.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* Comm: Wait-In-Milli-Seconds -seconds: "1000"
|
|
178
|
+
*/
|
|
179
|
+
async function waitInMilliSeconds(ms) {
|
|
180
|
+
var _a;
|
|
181
|
+
if (typeof ms !== 'number' || !isFinite(ms) || ms < 0) {
|
|
182
|
+
throw new Error('❌ waitInMilliSeconds: ms must be a non-negative number.');
|
|
183
|
+
}
|
|
184
|
+
const logger = (_a = global_1.logFixture.getLogger) === null || _a === void 0 ? void 0 : _a.call(global_1.logFixture);
|
|
185
|
+
const doWait = async () => {
|
|
186
|
+
var _a;
|
|
187
|
+
(_a = logger === null || logger === void 0 ? void 0 : logger.info) === null || _a === void 0 ? void 0 : _a.call(logger, `⏳ Waiting for ${ms} ms`);
|
|
188
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
189
|
+
};
|
|
190
|
+
if (isPlaywrightRunner()) {
|
|
191
|
+
await __allureAny_comm.step(`Comm: Wait-In-Milli-Seconds -seconds: ${ms}`, async () => {
|
|
192
|
+
await doWait();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
await doWait();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comm: Encrypt-Password -text: {param} -options: {param}
|
|
3
|
+
*
|
|
4
|
+
* Encrypts the given text as a password and returns it with a "pwd." prefix.
|
|
5
|
+
*
|
|
6
|
+
* @param encryptText - The text to encrypt.
|
|
7
|
+
* @param options - Optional string or object of additional options (parsed if string).
|
|
8
|
+
* @returns A string prefixed with "pwd." followed by the encrypted value.
|
|
9
|
+
*
|
|
10
|
+
* @throws Error if `encryptText` is not a non-empty string.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export declare function encryptPassword(encryptText: string, options?: string | Record<string, any>): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Comm: Encrypt-Text -text: {param} -options: {param}
|
|
16
|
+
*
|
|
17
|
+
* Encrypts the given text and returns it with an "enc." prefix.
|
|
18
|
+
*
|
|
19
|
+
* @param encryptText - The text to encrypt.
|
|
20
|
+
* @param options - Optional string or object of additional options (parsed if string).
|
|
21
|
+
* @returns A string prefixed with "enc." followed by the encrypted value.
|
|
22
|
+
*
|
|
23
|
+
* @throws Error if `encryptText` is not a non-empty string.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare function encryptText(encryptText: string, options?: string | Record<string, any>): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Comm: Encrypt-Password -text: {param} and store in -variable: {param} -options: {param}
|
|
29
|
+
*
|
|
30
|
+
* Encrypts the given password, prefixes it with "pwd.", and stores it in a variable.
|
|
31
|
+
*
|
|
32
|
+
* @param encryptText - The plain text password to encrypt.
|
|
33
|
+
* @param varNameToStore - The name of the variable to store the encrypted password.
|
|
34
|
+
* @param options - Optional string or object of additional options (parsed if string).
|
|
35
|
+
*
|
|
36
|
+
* @throws Error if `encryptText` or `varNameToStore` are not non-empty strings.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
export declare function encryptPasswordAndStore(encryptText: string, varNameToStore: string, options?: string | Record<string, any>): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Comm: Encrypt -text: {param} and store in -variable: {param} -options: {param}
|
|
42
|
+
*
|
|
43
|
+
* Encrypts the given text, prefixes it with "enc.", and stores it in a variable.
|
|
44
|
+
*
|
|
45
|
+
* @param encryptText - The text to encrypt.
|
|
46
|
+
* @param varNameToStore - The variable name to store the encrypted text.
|
|
47
|
+
* @param options - Optional string or object of additional options (parsed if string).
|
|
48
|
+
*
|
|
49
|
+
* @throws Error if `encryptText` or `varNameToStore` are not non-empty strings.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export declare function encryptTextAndStore(encryptText: string, varNameToStore: string, options?: string | Record<string, any>): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Comm: Decrypt -text: {param} and store in -variable: {param} -options: {param}
|
|
55
|
+
*
|
|
56
|
+
* Decrypts the given encrypted text and stores the result in a variable.
|
|
57
|
+
*
|
|
58
|
+
* @param encryptedText - The encrypted value to decrypt.
|
|
59
|
+
* @param varName - The variable name to store the decrypted result.
|
|
60
|
+
* @param options - Optional string or object of additional options (parsed if string).
|
|
61
|
+
*
|
|
62
|
+
* @throws Error if `encryptedText` or `varName` are not non-empty strings.
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
export declare function decrypt(encryptedText: string, varName: string, options?: string | Record<string, any>): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Comm: Get-Random-From-List -arrayList: {param}
|
|
68
|
+
*
|
|
69
|
+
* Selects and returns a random item from a given non-empty array.
|
|
70
|
+
*
|
|
71
|
+
* @template T
|
|
72
|
+
* @param list - The array to select a random item from.
|
|
73
|
+
* @returns A randomly selected item from the array.
|
|
74
|
+
*
|
|
75
|
+
* @throws Error if the list is not a non-empty array.
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
export declare function getRandomFromList<T>(list: T[]): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Comm: Remove-Leading-Zero-From-Date -text: {param}
|
|
81
|
+
*
|
|
82
|
+
* Removes leading zeros from both the day and month in a date string of format DD/MM/YYYY.
|
|
83
|
+
* Example: '03/07/2025' => '3/7/2025'
|
|
84
|
+
* @param dateStr - The date string in DD/MM/YYYY format
|
|
85
|
+
* @returns The date string with leading zeros removed from day and month
|
|
86
|
+
*
|
|
87
|
+
* @throws Error if `dateStr` is not a non-empty string.
|
|
88
|
+
*/
|
|
89
|
+
export declare function removeLeadingZeroFromMonthAndDate(dateStr: string): Promise<string>;
|
|
90
|
+
interface WriteJsonOptions {
|
|
91
|
+
override?: boolean;
|
|
92
|
+
append?: boolean;
|
|
93
|
+
toArray?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Comm: Write-JSON-To-File -filePath: {param} -data: {param} -options: {param}
|
|
97
|
+
*
|
|
98
|
+
* Writes JSON data to a file with options to override, append, or wrap in array.
|
|
99
|
+
*
|
|
100
|
+
* @param filePath - The destination file path.
|
|
101
|
+
* @param data - The JSON data to write (object or array).
|
|
102
|
+
* @param options - { override, append, toArray }
|
|
103
|
+
*
|
|
104
|
+
* @throws Error if `filePath` is empty, if append mode file content is not a JSON array, or if both `override` and `append` are false.
|
|
105
|
+
*/
|
|
106
|
+
export declare function writeJsonToFile(filePath: string, data: any, options?: WriteJsonOptions): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Ensures the value is formatted as a currency string: $<amount>.00
|
|
109
|
+
* @param value - The input value (number or string)
|
|
110
|
+
* @returns {string} - Formatted as $<amount>.00
|
|
111
|
+
*/
|
|
112
|
+
export declare function toDollarAmount(value: string | number): string;
|
|
113
|
+
/**
|
|
114
|
+
* Comm: Generate TOTP Token to variable -varName: {param} -options: {param}
|
|
115
|
+
*
|
|
116
|
+
* Generates a TOTP (Time-based One-Time Password) token using the provided secret and stores it in a variable.
|
|
117
|
+
*
|
|
118
|
+
* @param varName - The name of the variable to store the generated TOTP token.
|
|
119
|
+
* @param options - Optional string or object containing:
|
|
120
|
+
* - secret: [string] The TOTP secret key (default: process.env.PLAYQ_TOTP_SECRET_KEY).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* Comm: Generate TOTP Token to variable -varName: "var.otp" -options: '{"secret":"MYSECRET"}'
|
|
124
|
+
*/
|
|
125
|
+
export declare function generateTotpTokenToVariable(varName: string, options?: string | Record<string, any>): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Alias: wait
|
|
128
|
+
* Wrapper to maintain compatibility for step names mapping.
|
|
129
|
+
*/
|
|
130
|
+
export declare function wait(ms: number): Promise<void>;
|
|
131
|
+
export {};
|