@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.
Files changed (225) hide show
  1. package/README.md +41 -0
  2. package/bin/playq.js +175 -0
  3. package/cucumber.js +10 -0
  4. package/dist/exec/featureFileCache.d.ts +21 -0
  5. package/dist/exec/featureFileCache.js +124 -0
  6. package/dist/exec/featureFilePreProcess.d.ts +12 -0
  7. package/dist/exec/featureFilePreProcess.js +208 -0
  8. package/dist/exec/preLoader.d.ts +1 -0
  9. package/dist/exec/preLoader.js +72 -0
  10. package/dist/exec/preProcessEntry.d.ts +1 -0
  11. package/dist/exec/preProcessEntry.js +83 -0
  12. package/dist/exec/preProcess_old_todelete.d.ts +1 -0
  13. package/dist/exec/preProcess_old_todelete.js +258 -0
  14. package/dist/exec/runner.d.ts +1 -0
  15. package/dist/exec/runner.js +221 -0
  16. package/dist/exec/runner_orchestrator.d.ts +1 -0
  17. package/dist/exec/runner_orchestrator.js +85 -0
  18. package/dist/exec/sgGenerator.d.ts +11 -0
  19. package/dist/exec/sgGenerator.js +310 -0
  20. package/dist/global.d.ts +15 -0
  21. package/dist/global.js +185 -0
  22. package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
  23. package/dist/helper/actions/api/apiRequestActions.js +374 -0
  24. package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
  25. package/dist/helper/actions/api/apiValidationActions.js +615 -0
  26. package/dist/helper/actions/apiActions.d.ts +18 -0
  27. package/dist/helper/actions/apiActions.js +34 -0
  28. package/dist/helper/actions/apiStepDefs.d.ts +1 -0
  29. package/dist/helper/actions/apiStepDefs.js +64 -0
  30. package/dist/helper/actions/comm/commonActions.d.ts +58 -0
  31. package/dist/helper/actions/comm/commonActions.js +198 -0
  32. package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
  33. package/dist/helper/actions/comm/utilityActions.js +351 -0
  34. package/dist/helper/actions/commActions.d.ts +18 -0
  35. package/dist/helper/actions/commActions.js +34 -0
  36. package/dist/helper/actions/commStepDefs.d.ts +1 -0
  37. package/dist/helper/actions/commStepDefs.js +57 -0
  38. package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
  39. package/dist/helper/actions/stepGroupStepDefs.js +15 -0
  40. package/dist/helper/actions/web/alertActions.d.ts +61 -0
  41. package/dist/helper/actions/web/alertActions.js +224 -0
  42. package/dist/helper/actions/web/cookieActions.d.ts +45 -0
  43. package/dist/helper/actions/web/cookieActions.js +186 -0
  44. package/dist/helper/actions/web/downloadActions.d.ts +40 -0
  45. package/dist/helper/actions/web/downloadActions.js +153 -0
  46. package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
  47. package/dist/helper/actions/web/elementReaderActions.js +326 -0
  48. package/dist/helper/actions/web/formActions.d.ts +122 -0
  49. package/dist/helper/actions/web/formActions.js +423 -0
  50. package/dist/helper/actions/web/iframeActions.d.ts +23 -0
  51. package/dist/helper/actions/web/iframeActions.js +108 -0
  52. package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
  53. package/dist/helper/actions/web/javascriptActions.js +77 -0
  54. package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
  55. package/dist/helper/actions/web/keyboardActions.js +118 -0
  56. package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
  57. package/dist/helper/actions/web/localStorageActions.js +163 -0
  58. package/dist/helper/actions/web/mouseActions.d.ts +240 -0
  59. package/dist/helper/actions/web/mouseActions.js +609 -0
  60. package/dist/helper/actions/web/reportingActions.d.ts +34 -0
  61. package/dist/helper/actions/web/reportingActions.js +58 -0
  62. package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
  63. package/dist/helper/actions/web/screenshotActions.js +151 -0
  64. package/dist/helper/actions/web/testDataActions.d.ts +21 -0
  65. package/dist/helper/actions/web/testDataActions.js +211 -0
  66. package/dist/helper/actions/web/validationActions.d.ts +547 -0
  67. package/dist/helper/actions/web/validationActions.js +1754 -0
  68. package/dist/helper/actions/web/waitActions.d.ts +191 -0
  69. package/dist/helper/actions/web/waitActions.js +589 -0
  70. package/dist/helper/actions/web/webNavigation.d.ts +104 -0
  71. package/dist/helper/actions/web/webNavigation.js +288 -0
  72. package/dist/helper/actions/webActions.d.ts +32 -0
  73. package/dist/helper/actions/webActions.js +48 -0
  74. package/dist/helper/actions/webStepDefs.d.ts +1 -0
  75. package/dist/helper/actions/webStepDefs.js +455 -0
  76. package/dist/helper/browsers/browserManager.d.ts +1 -0
  77. package/dist/helper/browsers/browserManager.js +56 -0
  78. package/dist/helper/bundle/defaultEntries.d.ts +6 -0
  79. package/dist/helper/bundle/defaultEntries.js +200 -0
  80. package/dist/helper/bundle/env.d.ts +1 -0
  81. package/dist/helper/bundle/env.js +157 -0
  82. package/dist/helper/bundle/vars.d.ts +9 -0
  83. package/dist/helper/bundle/vars.js +375 -0
  84. package/dist/helper/faker/customFaker.d.ts +55 -0
  85. package/dist/helper/faker/customFaker.js +45 -0
  86. package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
  87. package/dist/helper/faker/modules/dateTime.d.ts +18 -0
  88. package/dist/helper/faker/modules/dateTime.js +106 -0
  89. package/dist/helper/faker/modules/mobile.d.ts +4 -0
  90. package/dist/helper/faker/modules/mobile.js +59 -0
  91. package/dist/helper/faker/modules/nric.d.ts +32 -0
  92. package/dist/helper/faker/modules/nric.js +84 -0
  93. package/dist/helper/faker/modules/passport.d.ts +3 -0
  94. package/dist/helper/faker/modules/passport.js +36 -0
  95. package/dist/helper/faker/modules/person.d.ts +14 -0
  96. package/dist/helper/faker/modules/person.js +73 -0
  97. package/dist/helper/faker/modules/postcode.d.ts +6 -0
  98. package/dist/helper/faker/modules/postcode.js +47 -0
  99. package/dist/helper/fixtures/locAggregate.d.ts +7 -0
  100. package/dist/helper/fixtures/locAggregate.js +94 -0
  101. package/dist/helper/fixtures/logFixture.d.ts +8 -0
  102. package/dist/helper/fixtures/logFixture.js +56 -0
  103. package/dist/helper/fixtures/webFixture.d.ts +19 -0
  104. package/dist/helper/fixtures/webFixture.js +186 -0
  105. package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
  106. package/dist/helper/fixtures/webLocFixture.js +144 -0
  107. package/dist/helper/report/allureStepLogger.d.ts +0 -0
  108. package/dist/helper/report/allureStepLogger.js +25 -0
  109. package/dist/helper/report/customiseReport.d.ts +1 -0
  110. package/dist/helper/report/customiseReport.js +55 -0
  111. package/dist/helper/report/init.d.ts +1 -0
  112. package/dist/helper/report/init.js +14 -0
  113. package/dist/helper/report/report.d.ts +1 -0
  114. package/dist/helper/report/report.js +102 -0
  115. package/dist/helper/util/dataLoader.d.ts +10 -0
  116. package/dist/helper/util/dataLoader.js +73 -0
  117. package/dist/helper/util/logger.d.ts +4 -0
  118. package/dist/helper/util/logger.js +61 -0
  119. package/dist/helper/util/session/sessionUtil.d.ts +26 -0
  120. package/dist/helper/util/session/sessionUtil.js +729 -0
  121. package/dist/helper/util/stepHelpers.d.ts +2 -0
  122. package/dist/helper/util/stepHelpers.js +16 -0
  123. package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
  124. package/dist/helper/util/test-data/dataLoader.js +145 -0
  125. package/dist/helper/util/test-data/dataTest.d.ts +10 -0
  126. package/dist/helper/util/test-data/dataTest.js +216 -0
  127. package/dist/helper/util/totp/totpHelper.d.ts +38 -0
  128. package/dist/helper/util/totp/totpHelper.js +117 -0
  129. package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
  130. package/dist/helper/util/utilities/cryptoUtil.js +53 -0
  131. package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
  132. package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
  133. package/dist/helper/util/utils.d.ts +2 -0
  134. package/dist/helper/util/utils.js +22 -0
  135. package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
  136. package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
  137. package/dist/helper/wrapper/assert.d.ts +9 -0
  138. package/dist/helper/wrapper/assert.js +23 -0
  139. package/dist/index.d.ts +7 -0
  140. package/dist/index.js +57 -0
  141. package/dist/scripts/get-versions.d.ts +1 -0
  142. package/dist/scripts/get-versions.js +98 -0
  143. package/dist/scripts/posttest.d.ts +1 -0
  144. package/dist/scripts/posttest.js +29 -0
  145. package/dist/scripts/pretest.d.ts +1 -0
  146. package/dist/scripts/pretest.js +57 -0
  147. package/dist/scripts/util.d.ts +1 -0
  148. package/dist/scripts/util.js +376 -0
  149. package/package.json +68 -0
  150. package/src/exec/featureFileCache.ts +80 -0
  151. package/src/exec/featureFilePreProcess.ts +239 -0
  152. package/src/exec/preLoader.ts +72 -0
  153. package/src/exec/preProcessEntry.ts +59 -0
  154. package/src/exec/preProcess_old_todelete.ts +289 -0
  155. package/src/exec/runner.ts +241 -0
  156. package/src/exec/runnerCuke.js +90 -0
  157. package/src/exec/runner_orchestrator.ts +91 -0
  158. package/src/exec/sgGenerator.ts +373 -0
  159. package/src/global.ts +130 -0
  160. package/src/helper/actions/api/apiRequestActions.ts +362 -0
  161. package/src/helper/actions/api/apiValidationActions.ts +594 -0
  162. package/src/helper/actions/apiActions.ts +18 -0
  163. package/src/helper/actions/apiStepDefs.ts +80 -0
  164. package/src/helper/actions/comm/commonActions.ts +165 -0
  165. package/src/helper/actions/comm/utilityActions.ts +344 -0
  166. package/src/helper/actions/commActions.ts +18 -0
  167. package/src/helper/actions/commStepDefs.ts +72 -0
  168. package/src/helper/actions/stepGroupStepDefs.ts +17 -0
  169. package/src/helper/actions/web/alertActions.ts +179 -0
  170. package/src/helper/actions/web/cookieActions.ts +124 -0
  171. package/src/helper/actions/web/downloadActions.ts +129 -0
  172. package/src/helper/actions/web/elementReaderActions.ts +323 -0
  173. package/src/helper/actions/web/formActions.ts +469 -0
  174. package/src/helper/actions/web/iframeActions.ts +67 -0
  175. package/src/helper/actions/web/javascriptActions.ts +38 -0
  176. package/src/helper/actions/web/keyboardActions.ts +101 -0
  177. package/src/helper/actions/web/localStorageActions.ts +109 -0
  178. package/src/helper/actions/web/mouseActions.ts +864 -0
  179. package/src/helper/actions/web/reportingActions.ts +53 -0
  180. package/src/helper/actions/web/screenshotActions.ts +124 -0
  181. package/src/helper/actions/web/testDataActions.ts +162 -0
  182. package/src/helper/actions/web/validationActions.ts +2287 -0
  183. package/src/helper/actions/web/waitActions.ts +757 -0
  184. package/src/helper/actions/web/webNavigation.ts +313 -0
  185. package/src/helper/actions/webActions.ts +33 -0
  186. package/src/helper/actions/webStepDefs.ts +505 -0
  187. package/src/helper/browsers/browserManager.ts +23 -0
  188. package/src/helper/bundle/defaultEntries.ts +208 -0
  189. package/src/helper/bundle/env.ts +119 -0
  190. package/src/helper/bundle/vars.ts +368 -0
  191. package/src/helper/faker/customFaker.ts +107 -0
  192. package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
  193. package/src/helper/faker/modules/dateTime.ts +121 -0
  194. package/src/helper/faker/modules/mobile.ts +58 -0
  195. package/src/helper/faker/modules/nric.ts +109 -0
  196. package/src/helper/faker/modules/passport.ts +34 -0
  197. package/src/helper/faker/modules/person.ts +93 -0
  198. package/src/helper/faker/modules/postcode.ts +57 -0
  199. package/src/helper/fixtures/locAggregate.ts +61 -0
  200. package/src/helper/fixtures/logFixture.ts +57 -0
  201. package/src/helper/fixtures/webFixture.ts +206 -0
  202. package/src/helper/fixtures/webLocFixture.ts +143 -0
  203. package/src/helper/report/allureStepLogger.ts +26 -0
  204. package/src/helper/report/customiseReport.ts +61 -0
  205. package/src/helper/report/init.ts +18 -0
  206. package/src/helper/report/report.ts +72 -0
  207. package/src/helper/util/dataLoader.ts +42 -0
  208. package/src/helper/util/logger.ts +32 -0
  209. package/src/helper/util/session/sessionUtil.ts +839 -0
  210. package/src/helper/util/stepHelpers.ts +14 -0
  211. package/src/helper/util/test-data/dataLoader.ts +108 -0
  212. package/src/helper/util/test-data/dataTest.ts +191 -0
  213. package/src/helper/util/test-data/registerUser.json +7 -0
  214. package/src/helper/util/totp/totpHelper.ts +102 -0
  215. package/src/helper/util/utilities/cryptoUtil.ts +53 -0
  216. package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
  217. package/src/helper/util/utils.ts +28 -0
  218. package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
  219. package/src/helper/wrapper/assert.ts +25 -0
  220. package/src/index.ts +17 -0
  221. package/src/scripts/get-versions.ts +68 -0
  222. package/src/scripts/posttest.ts +32 -0
  223. package/src/scripts/pretest.ts +48 -0
  224. package/src/scripts/util.ts +406 -0
  225. package/tsconfig.json +30 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertLog = void 0;
4
+ exports.logInfo = logInfo;
5
+ exports.logPass = logPass;
6
+ exports.logFail = logFail;
7
+ exports.assert = assert;
8
+ /**
9
+ * @file reportingActions.ts
10
+ *
11
+ * Lightweight reporting helpers for PlayQ web actions.
12
+ * Attaches info/pass/fail messages to the test report via comm fixture.
13
+ *
14
+ * Authors: PlayQ Team
15
+ * Version: v1.0.0
16
+ */
17
+ const global_1 = require("../../../global");
18
+ /**
19
+ * Web: Log Info -message: {param}
20
+ *
21
+ * Attaches an informational log message to the test report.
22
+ *
23
+ * @param message - Message to attach
24
+ */
25
+ async function logInfo(message) { await global_1.comm.attachLog(message, 'text/plain', 'INFO'); }
26
+ /**
27
+ * Web: Log Pass -message: {param}
28
+ *
29
+ * Attaches a success log message to the test report.
30
+ *
31
+ * @param message - Message to attach
32
+ */
33
+ async function logPass(message) { await global_1.comm.attachLog(`✅ ${message}`, 'text/plain', 'PASS'); }
34
+ /**
35
+ * Web: Log Fail -message: {param}
36
+ *
37
+ * Attaches a failure log message to the test report.
38
+ *
39
+ * @param message - Message to attach
40
+ */
41
+ async function logFail(message) { await global_1.comm.attachLog(`❌ ${message}`, 'text/plain', 'FAIL'); }
42
+ /**
43
+ * Web: Assert -condition: {param} -message: {param}
44
+ *
45
+ * Asserts a condition and logs pass/fail. Throws on failure.
46
+ *
47
+ * @param condition - Condition to assert
48
+ * @param message - Optional message to include in logs and error
49
+ */
50
+ async function assert(condition, message) {
51
+ if (!condition) {
52
+ await logFail(message || 'Assertion failed');
53
+ throw new Error(message || 'Assertion failed');
54
+ }
55
+ await logPass(message || 'Assertion passed');
56
+ }
57
+ // Friendly aliases
58
+ exports.assertLog = assert;
@@ -0,0 +1,34 @@
1
+ import { Page, Locator } from "@playwright/test";
2
+ /**
3
+ * Takes a screenshot of the provided Playwright page.
4
+ *
5
+ * @param page - The Playwright Page object to capture.
6
+ * @param options - Optional screenshot configuration. Can be a JSON string or an object.
7
+ * - `screenshot_text` (string): Optional text to annotate the screenshot.
8
+ * - `screenshot_fullPage` (boolean): Whether to capture the full page (default: true).
9
+ * @throws Will throw an error if the page is not initialized.
10
+ * @remarks
11
+ * Waits for the page to load before taking the screenshot.
12
+ */
13
+ export declare function takeScreenshot(page: Page, options?: string | Record<string, any>): Promise<void>;
14
+ /**
15
+ * Web: Process Screenshot -options: {param}
16
+ *
17
+ * Internal helper to capture and attach a screenshot.
18
+ *
19
+ * @param page - Playwright Page instance
20
+ * @param shouldTake - Whether to capture
21
+ * @param text - Attachment text
22
+ * @param fullPage - Full page flag
23
+ * @param selector - Optional Locator to screenshot
24
+ */
25
+ export declare function processScreenshot(page: Page, shouldTake: boolean, text?: string, fullPage?: boolean, selector?: Locator): Promise<void>;
26
+ /**
27
+ * Web: Take Full Screenshot -options: {param}
28
+ *
29
+ * Captures a full-page screenshot by delegating to `takeScreenshot` with defaults.
30
+ *
31
+ * @param page - Playwright Page instance
32
+ * @param options - Optional JSON string or object (merged with defaults)
33
+ */
34
+ export declare function takeFullScreenshot(page: Page, options?: string | Record<string, any>): Promise<void>;
@@ -0,0 +1,151 @@
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.takeScreenshot = takeScreenshot;
37
+ exports.processScreenshot = processScreenshot;
38
+ exports.takeFullScreenshot = takeFullScreenshot;
39
+ /**
40
+ * @file screenshotActions.ts
41
+ *
42
+ * Screenshot helpers for PlayQ web actions.
43
+ * Provides takeScreenshot and internal processScreenshot with hybrid
44
+ * runner support (Playwright/Cucumber) and robust attachment fallbacks.
45
+ *
46
+ * Authors: PlayQ Team
47
+ * Version: v1.0.0
48
+ */
49
+ const fs = __importStar(require("fs"));
50
+ const path = __importStar(require("path"));
51
+ const allure = __importStar(require("allure-js-commons"));
52
+ const global_1 = require("../../../global");
53
+ const waitActions_1 = require("./waitActions");
54
+ const vars_1 = require("../../bundle/vars");
55
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
56
+ function isCucumberRunner() { return process.env.TEST_RUNNER === 'cucumber'; }
57
+ const __allureAny_shot = allure;
58
+ if (typeof __allureAny_shot.step !== 'function') {
59
+ __allureAny_shot.step = async (_name, fn) => await fn();
60
+ }
61
+ /**
62
+ * Takes a screenshot of the provided Playwright page.
63
+ *
64
+ * @param page - The Playwright Page object to capture.
65
+ * @param options - Optional screenshot configuration. Can be a JSON string or an object.
66
+ * - `screenshot_text` (string): Optional text to annotate the screenshot.
67
+ * - `screenshot_fullPage` (boolean): Whether to capture the full page (default: true).
68
+ * @throws Will throw an error if the page is not initialized.
69
+ * @remarks
70
+ * Waits for the page to load before taking the screenshot.
71
+ */
72
+ async function takeScreenshot(page, options) {
73
+ const options_json = typeof options === "string" ? (0, vars_1.parseLooseJson)(options) : options || {};
74
+ const { screenshot_text = "", screenshot_fullPage = true } = options_json;
75
+ if (!page)
76
+ throw new Error("Page not initialized");
77
+ await (0, waitActions_1.waitForPageToLoad)(page);
78
+ await processScreenshot(page, true, screenshot_text, screenshot_fullPage);
79
+ }
80
+ function persistScreenshotToDisk(buffer, text) {
81
+ try {
82
+ const baseDir = path.resolve(process.cwd(), "test-results", "screenshots");
83
+ fs.mkdirSync(baseDir, { recursive: true });
84
+ const safe = (text || "screenshot").toString().toLowerCase().replace(/[^a-z0-9-_]+/gi, "_").slice(0, 80);
85
+ const file = path.join(baseDir, `${Date.now()}_${safe || "shot"}.png`);
86
+ fs.writeFileSync(file, buffer);
87
+ console.log(`📸 Screenshot saved to: ${file}`);
88
+ }
89
+ catch (e) {
90
+ console.warn(`⚠️ Failed to save screenshot to disk: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
91
+ }
92
+ }
93
+ /**
94
+ * Web: Process Screenshot -options: {param}
95
+ *
96
+ * Internal helper to capture and attach a screenshot.
97
+ *
98
+ * @param page - Playwright Page instance
99
+ * @param shouldTake - Whether to capture
100
+ * @param text - Attachment text
101
+ * @param fullPage - Full page flag
102
+ * @param selector - Optional Locator to screenshot
103
+ */
104
+ async function processScreenshot(page, shouldTake, text = "Screenshot", fullPage = true, selector) {
105
+ if (!shouldTake)
106
+ return;
107
+ if (!page)
108
+ throw new Error("Page not initialized for screenshot");
109
+ const screenshotBuffer = selector
110
+ ? await selector.screenshot()
111
+ : await page.screenshot({ fullPage });
112
+ try {
113
+ if (isCucumberRunner()) {
114
+ const world = global_1.webFixture.getWorld();
115
+ if (world && typeof world.attach === "function") {
116
+ await world.attach(screenshotBuffer, "image/png");
117
+ await world.attach(`Screenshot Text: ${text}`, "text/plain");
118
+ console.log(`✅ Screenshot attached via Cucumber World: ${text}`);
119
+ }
120
+ else {
121
+ console.warn(`⚠️ No Cucumber World context. Screenshot not attached.`);
122
+ }
123
+ }
124
+ else if (isPlaywrightRunner()) {
125
+ const { test } = await Promise.resolve().then(() => __importStar(require("@playwright/test")));
126
+ await test
127
+ .info()
128
+ .attach(text, { body: screenshotBuffer, contentType: "image/png" });
129
+ console.log(`✅ Screenshot attached via Playwright: ${text}`);
130
+ }
131
+ else {
132
+ console.warn(`⚠️ Unknown runner context. Screenshot not attached.`);
133
+ }
134
+ }
135
+ catch (error) {
136
+ console.warn(`⚠️ Error attaching screenshot: ${error.message}`);
137
+ }
138
+ }
139
+ /**
140
+ * Web: Take Full Screenshot -options: {param}
141
+ *
142
+ * Captures a full-page screenshot by delegating to `takeScreenshot` with defaults.
143
+ *
144
+ * @param page - Playwright Page instance
145
+ * @param options - Optional JSON string or object (merged with defaults)
146
+ */
147
+ async function takeFullScreenshot(page, options) {
148
+ const defaults = { screenshot: true, screenshotFullPage: true };
149
+ let opts = typeof options === 'string' ? defaults : { ...defaults, ...(options || {}) };
150
+ return takeScreenshot(page, opts);
151
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Web: Load Test Data JSON -file: {param}
3
+ *
4
+ * Loads and parses JSON test data from a file.
5
+ *
6
+ * @param filePath - Path to JSON file
7
+ * @returns Parsed JSON content
8
+ * @throws Error if file does not exist or JSON parsing fails
9
+ */
10
+ export declare function loadFromJson(filePath: string): Promise<any>;
11
+ /**
12
+ * Web: Load Test Data CSV -file: {param}
13
+ *
14
+ * Loads CSV test data from a file and returns an array of objects.
15
+ *
16
+ * @param filePath - Path to CSV file
17
+ * @returns Array of row objects keyed by header names
18
+ * @throws Error if file does not exist or CSV is empty/invalid
19
+ */
20
+ export declare function loadFromCsv(filePath: string): Promise<any[]>;
21
+ export declare function generateSampleData(schema?: Record<string, any>): Promise<any>;
@@ -0,0 +1,211 @@
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.loadFromJson = loadFromJson;
37
+ exports.loadFromCsv = loadFromCsv;
38
+ exports.generateSampleData = generateSampleData;
39
+ /**
40
+ * @file testDataActions.ts
41
+ *
42
+ * Test data helpers for PlayQ web actions.
43
+ * Supports JSON and CSV loading plus sample data generation via faker.
44
+ *
45
+ * Authors: PlayQ Team
46
+ * Version: v1.0.0
47
+ */
48
+ const fs = __importStar(require("fs"));
49
+ const path = __importStar(require("path"));
50
+ const global_1 = require("../../../global");
51
+ /**
52
+ * Web: Load Test Data JSON -file: {param}
53
+ *
54
+ * Loads and parses JSON test data from a file.
55
+ *
56
+ * @param filePath - Path to JSON file
57
+ * @returns Parsed JSON content
58
+ * @throws Error if file does not exist or JSON parsing fails
59
+ */
60
+ async function loadFromJson(filePath) {
61
+ if (!filePath)
62
+ throw new Error("testData.loadFromJson: 'filePath' is required");
63
+ const abs = path.resolve(filePath);
64
+ if (!fs.existsSync(abs))
65
+ throw new Error(`testData.loadFromJson: File not found at '${abs}'`);
66
+ const content = fs.readFileSync(abs, 'utf-8');
67
+ try {
68
+ return JSON.parse(content);
69
+ }
70
+ catch (err) {
71
+ throw new Error(`testData.loadFromJson: Failed to parse JSON - ${(err === null || err === void 0 ? void 0 : err.message) || err}`);
72
+ }
73
+ }
74
+ /**
75
+ * Web: Load Test Data CSV -file: {param}
76
+ *
77
+ * Loads CSV test data from a file and returns an array of objects.
78
+ *
79
+ * @param filePath - Path to CSV file
80
+ * @returns Array of row objects keyed by header names
81
+ * @throws Error if file does not exist or CSV is empty/invalid
82
+ */
83
+ async function loadFromCsv(filePath) {
84
+ if (!filePath)
85
+ throw new Error("testData.loadFromCsv: 'filePath' is required");
86
+ const abs = path.resolve(filePath);
87
+ if (!fs.existsSync(abs))
88
+ throw new Error(`testData.loadFromCsv: File not found at '${abs}'`);
89
+ const content = (fs.readFileSync(abs, 'utf-8') || '').trim();
90
+ if (!content)
91
+ throw new Error("testData.loadFromCsv: CSV file is empty");
92
+ const [headerLine, ...rows] = content.split(/\r?\n/);
93
+ if (!headerLine)
94
+ throw new Error("testData.loadFromCsv: Missing header line");
95
+ const headers = headerLine.split(',').map(h => h.trim());
96
+ return rows.filter(r => r && r.trim().length > 0).map(r => {
97
+ const cols = r.split(',');
98
+ const obj = {};
99
+ headers.forEach((h, i) => { var _a; return obj[h] = ((_a = cols[i]) !== null && _a !== void 0 ? _a : '').trim(); });
100
+ return obj;
101
+ });
102
+ }
103
+ /**
104
+ * Web: Generate Sample Data -schema: {param}
105
+ *
106
+ * Generates sample test data, optionally merged with a provided schema.
107
+ *
108
+ * @param schema - Optional object to override default generated fields
109
+ * @returns Object containing generated sample fields
110
+ */
111
+ function generateValueByDescriptor(descriptor) {
112
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
113
+ const d = (descriptor || '').toString().toLowerCase().trim();
114
+ switch (d) {
115
+ case 'string':
116
+ return ((_b = (_a = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.lorem) === null || _a === void 0 ? void 0 : _a.word) === null || _b === void 0 ? void 0 : _b.call(_a)) || 'sample';
117
+ case 'number':
118
+ case 'int':
119
+ case 'integer':
120
+ return (_e = (_d = (_c = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.number) === null || _c === void 0 ? void 0 : _c.int) === null || _d === void 0 ? void 0 : _d.call(_c, { min: 0, max: 9999 })) !== null && _e !== void 0 ? _e : 0;
121
+ case 'float':
122
+ case 'decimal':
123
+ return (_h = (_g = (_f = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.number) === null || _f === void 0 ? void 0 : _f.float) === null || _g === void 0 ? void 0 : _g.call(_f, { min: 0, max: 9999, precision: 0.01 })) !== null && _h !== void 0 ? _h : 0.0;
124
+ case 'boolean':
125
+ return Math.random() < 0.5;
126
+ case 'email':
127
+ return ((_k = (_j = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.internet) === null || _j === void 0 ? void 0 : _j.email) === null || _k === void 0 ? void 0 : _k.call(_j)) || 'user@example.com';
128
+ case 'phone':
129
+ case 'phonenumber':
130
+ return ((_m = (_l = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.phone) === null || _l === void 0 ? void 0 : _l.number) === null || _m === void 0 ? void 0 : _m.call(_l)) || '1234567890';
131
+ case 'firstname':
132
+ return ((_p = (_o = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.person) === null || _o === void 0 ? void 0 : _o.firstName) === null || _p === void 0 ? void 0 : _p.call(_o)) || 'John';
133
+ case 'lastname':
134
+ return ((_r = (_q = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.person) === null || _q === void 0 ? void 0 : _q.lastName) === null || _r === void 0 ? void 0 : _r.call(_q)) || 'Doe';
135
+ case 'fullname':
136
+ case 'name':
137
+ return `${((_t = (_s = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.person) === null || _s === void 0 ? void 0 : _s.firstName) === null || _t === void 0 ? void 0 : _t.call(_s)) || 'John'} ${((_v = (_u = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.person) === null || _u === void 0 ? void 0 : _u.lastName) === null || _v === void 0 ? void 0 : _v.call(_u)) || 'Doe'}`;
138
+ case 'uuid':
139
+ return ((_x = (_w = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.string) === null || _w === void 0 ? void 0 : _w.uuid) === null || _x === void 0 ? void 0 : _x.call(_w)) || '00000000-0000-0000-0000-000000000000';
140
+ case 'date':
141
+ return new Date().toISOString().slice(0, 10);
142
+ case 'datetime':
143
+ case 'isodatetime':
144
+ return new Date().toISOString();
145
+ case 'timestamp':
146
+ return Date.now();
147
+ case 'url':
148
+ return ((_z = (_y = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.internet) === null || _y === void 0 ? void 0 : _y.url) === null || _z === void 0 ? void 0 : _z.call(_y)) || 'https://example.com';
149
+ case 'ip':
150
+ case 'ipv4':
151
+ return ((_1 = (_0 = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.internet) === null || _0 === void 0 ? void 0 : _0.ip) === null || _1 === void 0 ? void 0 : _1.call(_0)) || '127.0.0.1';
152
+ case 'city':
153
+ return ((_3 = (_2 = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.location) === null || _2 === void 0 ? void 0 : _2.city) === null || _3 === void 0 ? void 0 : _3.call(_2)) || 'Metropolis';
154
+ case 'country':
155
+ return ((_5 = (_4 = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.location) === null || _4 === void 0 ? void 0 : _4.country) === null || _5 === void 0 ? void 0 : _5.call(_4)) || 'Wonderland';
156
+ case 'company':
157
+ return ((_7 = (_6 = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.company) === null || _6 === void 0 ? void 0 : _6.name) === null || _7 === void 0 ? void 0 : _7.call(_6)) || 'ACME Inc.';
158
+ default:
159
+ // Unknown descriptor → return as-is to avoid surprises
160
+ return descriptor;
161
+ }
162
+ }
163
+ function generateFromSchema(schema) {
164
+ if (schema == null)
165
+ return schema;
166
+ if (Array.isArray(schema)) {
167
+ // If array has a single descriptor like ['string'], generate a small array of values
168
+ if (schema.length === 1 && typeof schema[0] === 'string') {
169
+ return [generateValueByDescriptor(schema[0]), generateValueByDescriptor(schema[0])];
170
+ }
171
+ // Otherwise, map values
172
+ return schema.map((v) => (typeof v === 'string' ? generateValueByDescriptor(v) : generateFromSchema(v)));
173
+ }
174
+ if (typeof schema === 'object') {
175
+ const out = {};
176
+ for (const [k, v] of Object.entries(schema)) {
177
+ if (typeof v === 'string') {
178
+ out[k] = generateValueByDescriptor(v);
179
+ }
180
+ else if (typeof v === 'number' || typeof v === 'boolean') {
181
+ out[k] = v;
182
+ }
183
+ else if (Array.isArray(v)) {
184
+ out[k] = generateFromSchema(v);
185
+ }
186
+ else if (typeof v === 'object' && v !== null) {
187
+ out[k] = generateFromSchema(v);
188
+ }
189
+ else {
190
+ out[k] = v;
191
+ }
192
+ }
193
+ return out;
194
+ }
195
+ if (typeof schema === 'string')
196
+ return generateValueByDescriptor(schema);
197
+ return schema;
198
+ }
199
+ async function generateSampleData(schema) {
200
+ var _a, _b, _c, _d, _e, _f, _g, _h;
201
+ const sample = {
202
+ firstName: ((_b = (_a = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.person) === null || _a === void 0 ? void 0 : _a.firstName) === null || _b === void 0 ? void 0 : _b.call(_a)) || 'John',
203
+ lastName: ((_d = (_c = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.person) === null || _c === void 0 ? void 0 : _c.lastName) === null || _d === void 0 ? void 0 : _d.call(_c)) || 'Doe',
204
+ email: ((_f = (_e = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.internet) === null || _e === void 0 ? void 0 : _e.email) === null || _f === void 0 ? void 0 : _f.call(_e)) || 'john.doe@example.com',
205
+ phone: ((_h = (_g = global_1.faker === null || global_1.faker === void 0 ? void 0 : global_1.faker.phone) === null || _g === void 0 ? void 0 : _g.number) === null || _h === void 0 ? void 0 : _h.call(_g)) || '1234567890'
206
+ };
207
+ if (!schema)
208
+ return sample;
209
+ const interpreted = generateFromSchema(schema);
210
+ return { ...sample, ...interpreted };
211
+ }