@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,224 @@
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.acceptAlert = acceptAlert;
37
+ exports.dismissAlert = dismissAlert;
38
+ exports.fillAlert = fillAlert;
39
+ exports.seeAlertText = seeAlertText;
40
+ /**
41
+ * @file alertActions.ts
42
+ *
43
+ * Browser alert handling actions for PlayQ across Playwright and Cucumber.
44
+ * Provides accept, dismiss, fill, and verification of alert messages with
45
+ * runner-aware logging and Allure-compatible step wrappers.
46
+ *
47
+ * Key Features:
48
+ * - Hybrid runner support (Playwright/Cucumber) via lightweight shims
49
+ * - Consistent step naming for reporting and traceability
50
+ * - Attaches alert text to reports where available
51
+ *
52
+ * Authors: PlayQ Team
53
+ * Version: v1.0.0
54
+ */
55
+ const allure = __importStar(require("allure-js-commons"));
56
+ const global_1 = require("../../../global");
57
+ const screenshotActions_1 = require("./screenshotActions");
58
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
59
+ const __allureAny_alert = allure;
60
+ if (typeof __allureAny_alert.step !== 'function') {
61
+ __allureAny_alert.step = async (_n, f) => await f();
62
+ }
63
+ /**
64
+ * Web: Accept Alert -options: {param}
65
+ *
66
+ * Waits for a browser alert and accepts it. Attaches the alert text and optionally captures a screenshot.
67
+ *
68
+ * @param page - Playwright Page instance
69
+ * @param options - Optional JSON string or object:
70
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
71
+ * - screenshot: [boolean] Capture screenshot after handling the alert (default: false)
72
+ * - screenshotText: [string] Description for screenshot (default: "")
73
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
74
+ * @throws Error if page is not initialized or alert does not appear within timeout
75
+ */
76
+ async function acceptAlert(page, options) {
77
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
78
+ const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 10000, screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json;
79
+ const stepName = `Web: Accept Alert -options: ${JSON.stringify(options_json)}`;
80
+ if (!page)
81
+ throw new Error("Page not initialized");
82
+ async function run() {
83
+ const dialog = await page.waitForEvent('dialog', { timeout: actionTimeout }).catch(() => null);
84
+ if (!dialog)
85
+ throw new Error(`❌ No alert appeared within ${actionTimeout}ms`);
86
+ await global_1.comm.attachLog(`Alert Text: ${dialog.message()}`, 'text/plain', 'Alert');
87
+ await dialog.accept();
88
+ await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || 'After alert accept', screenshotFullPage);
89
+ }
90
+ if (isPlaywrightRunner()) {
91
+ await __allureAny_alert.step(stepName, run);
92
+ }
93
+ else {
94
+ await run();
95
+ }
96
+ }
97
+ /**
98
+ * Web: Dismiss Alert -options: {param}
99
+ *
100
+ * Waits for a browser alert and dismisses it. Attaches the alert text and optionally captures a screenshot.
101
+ *
102
+ * @param page - Playwright Page instance
103
+ * @param options - Optional JSON string or object:
104
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
105
+ * - screenshot: [boolean] Capture screenshot after handling the alert (default: false)
106
+ * - screenshotText: [string] Description for screenshot (default: "")
107
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
108
+ * @throws Error if page is not initialized or alert does not appear within timeout
109
+ */
110
+ async function dismissAlert(page, options) {
111
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
112
+ const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 10000, screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json;
113
+ const stepName = `Web: Dismiss Alert -options: ${JSON.stringify(options_json)}`;
114
+ if (!page)
115
+ throw new Error("Page not initialized");
116
+ async function run() {
117
+ const dialog = await page.waitForEvent('dialog', { timeout: actionTimeout }).catch(() => null);
118
+ if (!dialog)
119
+ throw new Error(`❌ No alert appeared within ${actionTimeout}ms`);
120
+ await global_1.comm.attachLog(`Alert Text: ${dialog.message()}`, 'text/plain', 'Alert');
121
+ await dialog.dismiss();
122
+ await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || 'After alert dismiss', screenshotFullPage);
123
+ }
124
+ if (isPlaywrightRunner()) {
125
+ await __allureAny_alert.step(stepName, run);
126
+ }
127
+ else {
128
+ await run();
129
+ }
130
+ }
131
+ /**
132
+ * Web: Fill Alert -text: {param} -options: {param}
133
+ *
134
+ * Waits for a prompt alert and fills it with the provided text. Attaches the alert text and optionally captures a screenshot.
135
+ *
136
+ * @param page - Playwright Page instance
137
+ * @param text - Text to send to alert prompt
138
+ * @param options - Optional JSON string or object:
139
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
140
+ * - screenshot: [boolean] Capture screenshot after handling the alert (default: false)
141
+ * - screenshotText: [string] Description for screenshot (default: "")
142
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
143
+ * @throws Error if page is not initialized or alert does not appear within timeout
144
+ */
145
+ async function fillAlert(page, text, options) {
146
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
147
+ const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 10000, screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json;
148
+ const stepName = `Web: Fill Alert -text: ${text} -options: ${JSON.stringify(options_json)}`;
149
+ if (!page)
150
+ throw new Error("Page not initialized");
151
+ async function run() {
152
+ const dialog = await page.waitForEvent('dialog', { timeout: actionTimeout }).catch(() => null);
153
+ if (!dialog)
154
+ throw new Error(`❌ No alert appeared within ${actionTimeout}ms`);
155
+ await global_1.comm.attachLog(`Alert Text: ${dialog.message()}`, 'text/plain', 'Alert');
156
+ await dialog.accept(text);
157
+ await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || 'After alert fill', screenshotFullPage);
158
+ }
159
+ if (isPlaywrightRunner()) {
160
+ await __allureAny_alert.step(stepName, run);
161
+ }
162
+ else {
163
+ await run();
164
+ }
165
+ }
166
+ /**
167
+ * Web: See Alert Text -expected: {param} -options: {param}
168
+ *
169
+ * Verifies the next alert message matches the expected text. Supports partial match and case-insensitive comparison.
170
+ *
171
+ * @param page - Playwright Page instance
172
+ * @param expected - Expected alert text
173
+ * @param options - Optional JSON string or object:
174
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
175
+ * - partialMatch: [boolean] If true, checks substring instead of exact match (default: false)
176
+ * - ignoreCase: [boolean] Case-insensitive comparison (default: false)
177
+ * - assert: [boolean] If false, logs failure but does not throw (default: true)
178
+ * - screenshot: [boolean] Capture screenshot after verification (default: false)
179
+ * - screenshotText: [string] Description for screenshot (default: "")
180
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
181
+ */
182
+ async function seeAlertText(page, expected, options) {
183
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
184
+ const { actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 10000, partialMatch = false, ignoreCase = false, assert = true, screenshot = false, screenshotText = "", screenshotFullPage = true, } = options_json;
185
+ const stepName = `Web: See Alert Text -expected: ${expected} -options: ${JSON.stringify(options_json)}`;
186
+ if (!page)
187
+ throw new Error("Page not initialized");
188
+ async function run() {
189
+ const dialog = await page.waitForEvent('dialog', { timeout: actionTimeout }).catch(() => null);
190
+ if (!dialog) {
191
+ const msg = `❌ No alert appeared within ${actionTimeout}ms`;
192
+ await global_1.comm.attachLog(msg, 'text/plain', 'Alert');
193
+ if (assert)
194
+ throw new Error(msg);
195
+ return;
196
+ }
197
+ let msg = dialog.message();
198
+ await global_1.comm.attachLog(`Alert Text: ${msg}`, 'text/plain', 'Alert');
199
+ let exp = global_1.vars.replaceVariables(expected);
200
+ let actual = msg;
201
+ if (ignoreCase) {
202
+ exp = exp.toLowerCase();
203
+ actual = actual.toLowerCase();
204
+ }
205
+ const matched = partialMatch ? actual.includes(exp) : actual === exp;
206
+ if (!matched) {
207
+ const err = `Alert text mismatch: expected '${expected}'${partialMatch ? " (partial)" : ""}, got '${msg}'`;
208
+ await global_1.comm.attachLog(`❌ ${err}`, 'text/plain', 'Validation');
209
+ if (assert)
210
+ throw new Error(err);
211
+ }
212
+ else {
213
+ await global_1.comm.attachLog(`✅ Alert text matched: '${msg}'`, 'text/plain', 'Validation');
214
+ }
215
+ await dialog.dismiss();
216
+ await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText || 'After alert verification', screenshotFullPage);
217
+ }
218
+ if (isPlaywrightRunner()) {
219
+ await __allureAny_alert.step(stepName, run);
220
+ }
221
+ else {
222
+ await run();
223
+ }
224
+ }
@@ -0,0 +1,45 @@
1
+ import type { Page } from "playwright";
2
+ /**
3
+ * Web: Set Cookie -name: {param} -value: {param} -options: {param}
4
+ *
5
+ * Adds a cookie for the current page URL.
6
+ *
7
+ * @param page - Playwright Page instance
8
+ * @param name - Cookie name
9
+ * @param value - Cookie value
10
+ * @param options - Optional JSON string or object with cookie attributes:
11
+ * - domain, path, sameSite, secure, httpOnly, expires
12
+ * @throws Error if page is not initialized or required params are missing
13
+ */
14
+ export declare function setCookie(page: Page, name: string, value: string, options?: string | Record<string, any>): Promise<void>;
15
+ /**
16
+ * Web: Get Cookie -name: {param}
17
+ *
18
+ * Retrieves the value of a cookie by name.
19
+ *
20
+ * @param page - Playwright Page instance
21
+ * @param name - Cookie name
22
+ * @param options - Optional JSON string or object: { assert?: boolean }
23
+ * @returns Cookie value or undefined
24
+ * @throws Error if page is not initialized or when assert=true and cookie missing
25
+ */
26
+ export declare function getCookie(page: Page, name: string, options?: string | Record<string, any>): Promise<any>;
27
+ /**
28
+ * Web: Delete Cookie -name: {param}
29
+ *
30
+ * Clears cookies. Note: Playwright API does not support deleting a single cookie directly; this clears all cookies in context.
31
+ *
32
+ * @param page - Playwright Page instance
33
+ * @param name - Cookie name (for reporting only)
34
+ * @throws Error if page is not initialized
35
+ */
36
+ export declare function deleteCookie(page: Page, name: string): Promise<void>;
37
+ /**
38
+ * Web: Clear Cookies
39
+ *
40
+ * Clears all cookies in the current browser context.
41
+ *
42
+ * @param page - Playwright Page instance
43
+ * @throws Error if page is not initialized
44
+ */
45
+ export declare function clearCookies(page: Page): Promise<void>;
@@ -0,0 +1,186 @@
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.setCookie = setCookie;
37
+ exports.getCookie = getCookie;
38
+ exports.deleteCookie = deleteCookie;
39
+ exports.clearCookies = clearCookies;
40
+ /**
41
+ * @file cookieActions.ts
42
+ *
43
+ * Cookie management utilities for PlayQ web tests.
44
+ * Supports setting, reading, and clearing cookies with reporting-friendly
45
+ * step wrappers compatible with Playwright and Cucumber runners.
46
+ *
47
+ * Authors: PlayQ Team
48
+ * Version: v1.0.0
49
+ */
50
+ const allure = __importStar(require("allure-js-commons"));
51
+ const global_1 = require("../../../global");
52
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
53
+ const __allureAny_cookie = allure;
54
+ if (typeof __allureAny_cookie.step !== 'function') {
55
+ __allureAny_cookie.step = async (_n, f) => await f();
56
+ }
57
+ /**
58
+ * Web: Set Cookie -name: {param} -value: {param} -options: {param}
59
+ *
60
+ * Adds a cookie for the current page URL.
61
+ *
62
+ * @param page - Playwright Page instance
63
+ * @param name - Cookie name
64
+ * @param value - Cookie value
65
+ * @param options - Optional JSON string or object with cookie attributes:
66
+ * - domain, path, sameSite, secure, httpOnly, expires
67
+ * @throws Error if page is not initialized or required params are missing
68
+ */
69
+ async function setCookie(page, name, value, options) {
70
+ if (!page)
71
+ throw new Error("Page not initialized");
72
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
73
+ const stepName = `Web: Set Cookie -name: ${name}`;
74
+ if (!name)
75
+ throw new Error("Cookie.setCookie: 'name' is required");
76
+ if (value === undefined || value === null)
77
+ throw new Error("Cookie.setCookie: 'value' is required");
78
+ const ctx = page.context();
79
+ const cookie = { name, value };
80
+ // Precedence: explicit url > domain/path > current page url
81
+ const explicitUrl = options_json === null || options_json === void 0 ? void 0 : options_json.url;
82
+ const explicitDomain = options_json === null || options_json === void 0 ? void 0 : options_json.domain;
83
+ const explicitPath = options_json === null || options_json === void 0 ? void 0 : options_json.path;
84
+ if (explicitUrl) {
85
+ // When url is specified, do not include domain/path
86
+ cookie.url = explicitUrl;
87
+ }
88
+ else if (explicitDomain || explicitPath) {
89
+ // When domain/path are specified, do not include url
90
+ if (explicitDomain)
91
+ cookie.domain = explicitDomain;
92
+ cookie.path = explicitPath || '/';
93
+ }
94
+ else {
95
+ // Default to current page url if no domain/path/url provided
96
+ cookie.url = page.url();
97
+ }
98
+ if (options_json === null || options_json === void 0 ? void 0 : options_json.sameSite)
99
+ cookie.sameSite = options_json.sameSite;
100
+ if ((options_json === null || options_json === void 0 ? void 0 : options_json.secure) !== undefined)
101
+ cookie.secure = !!options_json.secure;
102
+ if ((options_json === null || options_json === void 0 ? void 0 : options_json.httpOnly) !== undefined)
103
+ cookie.httpOnly = !!options_json.httpOnly;
104
+ if (typeof (options_json === null || options_json === void 0 ? void 0 : options_json.expires) === 'number')
105
+ cookie.expires = options_json.expires;
106
+ if (isPlaywrightRunner()) {
107
+ await __allureAny_cookie.step(stepName, async () => { await ctx.addCookies([cookie]); });
108
+ }
109
+ else {
110
+ await ctx.addCookies([cookie]);
111
+ }
112
+ }
113
+ /**
114
+ * Web: Get Cookie -name: {param}
115
+ *
116
+ * Retrieves the value of a cookie by name.
117
+ *
118
+ * @param page - Playwright Page instance
119
+ * @param name - Cookie name
120
+ * @param options - Optional JSON string or object: { assert?: boolean }
121
+ * @returns Cookie value or undefined
122
+ * @throws Error if page is not initialized or when assert=true and cookie missing
123
+ */
124
+ async function getCookie(page, name, options) {
125
+ if (!page)
126
+ throw new Error("Page not initialized");
127
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
128
+ const stepName = `Web: Get Cookie -name: ${name}`;
129
+ const run = async () => {
130
+ var _a;
131
+ const cookies = await page.context().cookies(page.url());
132
+ const val = (_a = cookies.find(c => c.name === name)) === null || _a === void 0 ? void 0 : _a.value;
133
+ if ((options_json === null || options_json === void 0 ? void 0 : options_json.assert) === true && (val === undefined || val === null)) {
134
+ throw new Error(`Cookie.getCookie: No cookie found with name '${name}'`);
135
+ }
136
+ return val;
137
+ };
138
+ if (isPlaywrightRunner()) {
139
+ return __allureAny_cookie.step(stepName, run);
140
+ }
141
+ return run();
142
+ }
143
+ /**
144
+ * Web: Delete Cookie -name: {param}
145
+ *
146
+ * Clears cookies. Note: Playwright API does not support deleting a single cookie directly; this clears all cookies in context.
147
+ *
148
+ * @param page - Playwright Page instance
149
+ * @param name - Cookie name (for reporting only)
150
+ * @throws Error if page is not initialized
151
+ */
152
+ async function deleteCookie(page, name) {
153
+ if (!page)
154
+ throw new Error("Page not initialized");
155
+ const stepName = `Web: Delete Cookie -name: ${name}`;
156
+ const run = async () => {
157
+ const ctx = page.context();
158
+ await ctx.clearCookies();
159
+ };
160
+ if (isPlaywrightRunner()) {
161
+ await __allureAny_cookie.step(stepName, run);
162
+ }
163
+ else {
164
+ await run();
165
+ }
166
+ }
167
+ /**
168
+ * Web: Clear Cookies
169
+ *
170
+ * Clears all cookies in the current browser context.
171
+ *
172
+ * @param page - Playwright Page instance
173
+ * @throws Error if page is not initialized
174
+ */
175
+ async function clearCookies(page) {
176
+ if (!page)
177
+ throw new Error("Page not initialized");
178
+ const stepName = `Web: Clear Cookies`;
179
+ const run = async () => { await page.context().clearCookies(); };
180
+ if (isPlaywrightRunner()) {
181
+ await __allureAny_cookie.step(stepName, run);
182
+ }
183
+ else {
184
+ await run();
185
+ }
186
+ }
@@ -0,0 +1,40 @@
1
+ import type { Page, Locator } from "playwright";
2
+ /**
3
+ * Web: List Files -dir: {param}
4
+ *
5
+ * Lists files in the given directory.
6
+ *
7
+ * @param dirPath - Directory path
8
+ * @returns Array of filenames or empty list if directory does not exist
9
+ * @throws Error if `dirPath` is empty
10
+ */
11
+ export declare function listFiles(dirPath: string): Promise<any>;
12
+ /**
13
+ * Web: Has File -dir: {param} -fileName: {param}
14
+ *
15
+ * Checks if a file exists in the directory listing.
16
+ *
17
+ * @param dirPath - Directory path
18
+ * @param fileName - File name to check
19
+ * @returns True if present; false otherwise
20
+ * @throws Error if `dirPath` or `fileName` is empty
21
+ */
22
+ export declare function hasFile(dirPath: string, fileName: string): Promise<any>;
23
+ /**
24
+ * Web: Download File -field: {param} -options: {param}
25
+ *
26
+ * Triggers a download by clicking the target element and saves it to a directory.
27
+ *
28
+ * @param page - Playwright Page instance
29
+ * @param field - Button/link text, selector, or Locator to click (e.g., 'Download Text')
30
+ * @param options - Optional JSON string or object:
31
+ * - pattern: [string] Locator pattern namespace (e.g., 'letcodesamples')
32
+ * - locatorCategory: [string] 'button' | 'link' (default 'button') used by webLocResolver
33
+ * - targetDir: [string] Directory to save file (default: PLAYQ_PROJECT_ROOT/_Temp/downloads)
34
+ * - fileName: [string] Override file name; default is suggested filename
35
+ * - actionTimeout: [number] Timeout for waits/clicks (default from config/testExecution)
36
+ * - screenshot, screenshotText, screenshotFullPage, screenshotBefore: screenshot options
37
+ *
38
+ * @returns Saved file absolute path
39
+ */
40
+ export declare function downloadFile(page: Page, field: string | Locator, options?: string | Record<string, any>): Promise<any>;
@@ -0,0 +1,153 @@
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.listFiles = listFiles;
37
+ exports.hasFile = hasFile;
38
+ exports.downloadFile = downloadFile;
39
+ /**
40
+ * @file downloadActions.ts
41
+ *
42
+ * Simple filesystem helpers used in web download scenarios.
43
+ * Provides directory listing and file existence checks with
44
+ * Allure-compatible step wrappers.
45
+ *
46
+ * Authors: PlayQ Team
47
+ * Version: v1.0.0
48
+ */
49
+ const allure = __importStar(require("allure-js-commons"));
50
+ const fs = __importStar(require("fs"));
51
+ const path = __importStar(require("path"));
52
+ const global_1 = require("../../../global");
53
+ const waitActions_1 = require("./waitActions");
54
+ const screenshotActions_1 = require("./screenshotActions");
55
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
56
+ const __allureAny_dl = allure;
57
+ if (typeof __allureAny_dl.step !== 'function') {
58
+ __allureAny_dl.step = async (_n, f) => await f();
59
+ }
60
+ /**
61
+ * Web: List Files -dir: {param}
62
+ *
63
+ * Lists files in the given directory.
64
+ *
65
+ * @param dirPath - Directory path
66
+ * @returns Array of filenames or empty list if directory does not exist
67
+ * @throws Error if `dirPath` is empty
68
+ */
69
+ async function listFiles(dirPath) {
70
+ if (!dirPath)
71
+ throw new Error("download.listFiles: 'dirPath' is required");
72
+ const abs = path.resolve(dirPath);
73
+ const stepName = `Web: List Files -dir: ${abs}`;
74
+ const run = async () => fs.existsSync(abs) ? fs.readdirSync(abs) : [];
75
+ if (isPlaywrightRunner()) {
76
+ return __allureAny_dl.step(stepName, run);
77
+ }
78
+ return run();
79
+ }
80
+ /**
81
+ * Web: Has File -dir: {param} -fileName: {param}
82
+ *
83
+ * Checks if a file exists in the directory listing.
84
+ *
85
+ * @param dirPath - Directory path
86
+ * @param fileName - File name to check
87
+ * @returns True if present; false otherwise
88
+ * @throws Error if `dirPath` or `fileName` is empty
89
+ */
90
+ async function hasFile(dirPath, fileName) {
91
+ if (!dirPath)
92
+ throw new Error("download.hasFile: 'dirPath' is required");
93
+ if (!fileName)
94
+ throw new Error("download.hasFile: 'fileName' is required");
95
+ const stepName = `Web: Has File -dir: ${path.resolve(dirPath)} -fileName: ${fileName}`;
96
+ const run = async () => {
97
+ const files = await listFiles(dirPath);
98
+ return files.includes(fileName);
99
+ };
100
+ if (isPlaywrightRunner()) {
101
+ return __allureAny_dl.step(stepName, run);
102
+ }
103
+ return run();
104
+ }
105
+ /**
106
+ * Web: Download File -field: {param} -options: {param}
107
+ *
108
+ * Triggers a download by clicking the target element and saves it to a directory.
109
+ *
110
+ * @param page - Playwright Page instance
111
+ * @param field - Button/link text, selector, or Locator to click (e.g., 'Download Text')
112
+ * @param options - Optional JSON string or object:
113
+ * - pattern: [string] Locator pattern namespace (e.g., 'letcodesamples')
114
+ * - locatorCategory: [string] 'button' | 'link' (default 'button') used by webLocResolver
115
+ * - targetDir: [string] Directory to save file (default: PLAYQ_PROJECT_ROOT/_Temp/downloads)
116
+ * - fileName: [string] Override file name; default is suggested filename
117
+ * - actionTimeout: [number] Timeout for waits/clicks (default from config/testExecution)
118
+ * - screenshot, screenshotText, screenshotFullPage, screenshotBefore: screenshot options
119
+ *
120
+ * @returns Saved file absolute path
121
+ */
122
+ async function downloadFile(page, field, options) {
123
+ if (!page)
124
+ throw new Error("Page not initialized");
125
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : options || {};
126
+ const { pattern, locatorCategory = 'button', targetDir, fileName, actionTimeout = Number(global_1.vars.getConfigValue("testExecution.actionTimeout")) || 60000, screenshot = false, screenshotText = "", screenshotFullPage = true, screenshotBefore = false, } = options_json || {};
127
+ const resolvedField = typeof field === 'string' ? global_1.vars.replaceVariables(field) : field;
128
+ const stepName = `Web: Download File -field: ${typeof resolvedField === 'string' ? resolvedField : '<locator>'}`;
129
+ const run = async () => {
130
+ await (0, waitActions_1.waitForPageToLoad)(page, actionTimeout);
131
+ const target = typeof resolvedField === 'string'
132
+ ? await (0, global_1.webLocResolver)(locatorCategory, resolvedField, page, pattern, actionTimeout)
133
+ : resolvedField;
134
+ await (0, screenshotActions_1.processScreenshot)(page, screenshotBefore, screenshotText, screenshotFullPage);
135
+ const [download] = await Promise.all([
136
+ page.waitForEvent('download', { timeout: actionTimeout }),
137
+ target.click({ timeout: actionTimeout })
138
+ ]);
139
+ const suggested = download.suggestedFilename();
140
+ const root = (targetDir ? path.resolve(targetDir) : path.join(process.env.PLAYQ_PROJECT_ROOT || process.cwd(), '_Temp', 'downloads'));
141
+ if (!fs.existsSync(root))
142
+ fs.mkdirSync(root, { recursive: true });
143
+ const finalName = fileName || suggested;
144
+ const savePath = path.join(root, finalName);
145
+ await download.saveAs(savePath);
146
+ await (0, screenshotActions_1.processScreenshot)(page, screenshot, screenshotText, screenshotFullPage);
147
+ return savePath;
148
+ };
149
+ if (isPlaywrightRunner()) {
150
+ return __allureAny_dl.step(stepName, run);
151
+ }
152
+ return run();
153
+ }