@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,351 @@
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.encryptPassword = encryptPassword;
37
+ exports.encryptText = encryptText;
38
+ exports.encryptPasswordAndStore = encryptPasswordAndStore;
39
+ exports.encryptTextAndStore = encryptTextAndStore;
40
+ exports.decrypt = decrypt;
41
+ exports.getRandomFromList = getRandomFromList;
42
+ exports.removeLeadingZeroFromMonthAndDate = removeLeadingZeroFromMonthAndDate;
43
+ exports.writeJsonToFile = writeJsonToFile;
44
+ exports.toDollarAmount = toDollarAmount;
45
+ exports.generateTotpTokenToVariable = generateTotpTokenToVariable;
46
+ exports.wait = wait;
47
+ const fs = __importStar(require("fs"));
48
+ const path = __importStar(require("path"));
49
+ const allure = __importStar(require("allure-js-commons"));
50
+ const global_1 = require("../../../global");
51
+ const crypto = __importStar(require("../../util/utilities/cryptoUtil"));
52
+ const totpHelper_1 = require("../../util/totp/totpHelper");
53
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
54
+ const __allureAny_comm = allure;
55
+ if (typeof __allureAny_comm.step !== 'function') {
56
+ __allureAny_comm.step = async (_name, fn) => await fn();
57
+ }
58
+ /**
59
+ * Comm: Encrypt-Password -text: {param} -options: {param}
60
+ *
61
+ * Encrypts the given text as a password and returns it with a "pwd." prefix.
62
+ *
63
+ * @param encryptText - The text to encrypt.
64
+ * @param options - Optional string or object of additional options (parsed if string).
65
+ * @returns A string prefixed with "pwd." followed by the encrypted value.
66
+ *
67
+ * @throws Error if `encryptText` is not a non-empty string.
68
+ *
69
+ */
70
+ async function encryptPassword(encryptText, options) {
71
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : (options || {});
72
+ if (typeof encryptText !== 'string' || encryptText.length === 0) {
73
+ throw new Error('❌ encryptPassword: encryptText must be a non-empty string.');
74
+ }
75
+ const doEncrypt = async () => {
76
+ const encryptedText = crypto.encrypt(encryptText);
77
+ console.log('🔐 Encrypted Password:', 'pwd.' + encryptedText);
78
+ return 'pwd.' + encryptedText;
79
+ };
80
+ if (isPlaywrightRunner()) {
81
+ return await __allureAny_comm.step(`Comm: Encrypt-Password -text: [redacted] -options: ${JSON.stringify(options_json)}`, async () => await doEncrypt());
82
+ }
83
+ return await doEncrypt();
84
+ }
85
+ /**
86
+ * Comm: Encrypt-Text -text: {param} -options: {param}
87
+ *
88
+ * Encrypts the given text and returns it with an "enc." prefix.
89
+ *
90
+ * @param encryptText - The text to encrypt.
91
+ * @param options - Optional string or object of additional options (parsed if string).
92
+ * @returns A string prefixed with "enc." followed by the encrypted value.
93
+ *
94
+ * @throws Error if `encryptText` is not a non-empty string.
95
+ *
96
+ */
97
+ async function encryptText(encryptText, options) {
98
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : (options || {});
99
+ if (typeof encryptText !== 'string' || encryptText.length === 0) {
100
+ throw new Error('❌ encryptText: encryptText must be a non-empty string.');
101
+ }
102
+ const doEncrypt = async () => {
103
+ const encryptedText = crypto.encrypt(encryptText);
104
+ console.log('🔐 Encrypted Text:', 'enc.' + encryptedText);
105
+ return 'enc.' + encryptedText;
106
+ };
107
+ if (isPlaywrightRunner()) {
108
+ return await __allureAny_comm.step(`Comm: Encrypt-Text -text: [redacted] -options: ${JSON.stringify(options_json)}`, async () => await doEncrypt());
109
+ }
110
+ return await doEncrypt();
111
+ }
112
+ /**
113
+ * Comm: Encrypt-Password -text: {param} and store in -variable: {param} -options: {param}
114
+ *
115
+ * Encrypts the given password, prefixes it with "pwd.", and stores it in a variable.
116
+ *
117
+ * @param encryptText - The plain text password to encrypt.
118
+ * @param varNameToStore - The name of the variable to store the encrypted password.
119
+ * @param options - Optional string or object of additional options (parsed if string).
120
+ *
121
+ * @throws Error if `encryptText` or `varNameToStore` are not non-empty strings.
122
+ *
123
+ */
124
+ async function encryptPasswordAndStore(encryptText, varNameToStore, options) {
125
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : (options || {});
126
+ if (typeof encryptText !== 'string' || encryptText.length === 0) {
127
+ throw new Error('❌ encryptPasswordAndStore: encryptText must be a non-empty string.');
128
+ }
129
+ if (typeof varNameToStore !== 'string' || varNameToStore.trim().length === 0) {
130
+ throw new Error('❌ encryptPasswordAndStore: varNameToStore must be a non-empty string.');
131
+ }
132
+ const doEncryptAndStore = async () => {
133
+ const encryptedText = crypto.encrypt(encryptText);
134
+ console.log('🔐 Encrypted Text:', 'pwd.' + encryptedText);
135
+ global_1.vars.setValue(varNameToStore, 'pwd.' + encryptedText);
136
+ await global_1.comm.attachLog(`✅ Encrypted password stored in "${varNameToStore}"`, 'text/plain');
137
+ };
138
+ if (isPlaywrightRunner()) {
139
+ await __allureAny_comm.step(`Comm: Encrypt-Password and store -variable: ${varNameToStore} -options: ${JSON.stringify(options_json)}`, async () => await doEncryptAndStore());
140
+ }
141
+ else {
142
+ await doEncryptAndStore();
143
+ }
144
+ }
145
+ /**
146
+ * Comm: Encrypt -text: {param} and store in -variable: {param} -options: {param}
147
+ *
148
+ * Encrypts the given text, prefixes it with "enc.", and stores it in a variable.
149
+ *
150
+ * @param encryptText - The text to encrypt.
151
+ * @param varNameToStore - The variable name to store the encrypted text.
152
+ * @param options - Optional string or object of additional options (parsed if string).
153
+ *
154
+ * @throws Error if `encryptText` or `varNameToStore` are not non-empty strings.
155
+ *
156
+ */
157
+ async function encryptTextAndStore(encryptText, varNameToStore, options) {
158
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : (options || {});
159
+ if (typeof encryptText !== 'string' || encryptText.length === 0) {
160
+ throw new Error('❌ encryptTextAndStore: encryptText must be a non-empty string.');
161
+ }
162
+ if (typeof varNameToStore !== 'string' || varNameToStore.trim().length === 0) {
163
+ throw new Error('❌ encryptTextAndStore: varNameToStore must be a non-empty string.');
164
+ }
165
+ const doEncryptAndStore = async () => {
166
+ const encryptedText = crypto.encrypt(encryptText);
167
+ console.log('🔐 Encrypted Text:', 'enc.' + encryptedText);
168
+ global_1.vars.setValue(varNameToStore, 'enc.' + encryptedText);
169
+ await global_1.comm.attachLog(`✅ Encrypted text stored in "${varNameToStore}"`, 'text/plain');
170
+ };
171
+ if (isPlaywrightRunner()) {
172
+ await __allureAny_comm.step(`Comm: Encrypt-Text and store -variable: ${varNameToStore} -options: ${JSON.stringify(options_json)}`, async () => await doEncryptAndStore());
173
+ }
174
+ else {
175
+ await doEncryptAndStore();
176
+ }
177
+ }
178
+ /**
179
+ * Comm: Decrypt -text: {param} and store in -variable: {param} -options: {param}
180
+ *
181
+ * Decrypts the given encrypted text and stores the result in a variable.
182
+ *
183
+ * @param encryptedText - The encrypted value to decrypt.
184
+ * @param varName - The variable name to store the decrypted result.
185
+ * @param options - Optional string or object of additional options (parsed if string).
186
+ *
187
+ * @throws Error if `encryptedText` or `varName` are not non-empty strings.
188
+ *
189
+ */
190
+ async function decrypt(encryptedText, varName, options) {
191
+ const options_json = typeof options === 'string' ? global_1.vars.parseLooseJson(options) : (options || {});
192
+ if (typeof encryptedText !== 'string' || encryptedText.length === 0) {
193
+ throw new Error('❌ decrypt: encryptedText must be a non-empty string.');
194
+ }
195
+ if (typeof varName !== 'string' || varName.trim().length === 0) {
196
+ throw new Error('❌ decrypt: varName must be a non-empty string.');
197
+ }
198
+ const doDecryptAndStore = async () => {
199
+ const decryptedText = crypto.decrypt(encryptedText);
200
+ global_1.vars.setValue(varName, decryptedText);
201
+ await global_1.comm.attachLog(`✅ Decrypted value stored in "${varName}"`, 'text/plain');
202
+ };
203
+ if (isPlaywrightRunner()) {
204
+ await __allureAny_comm.step(`Comm: Decrypt -text: [redacted] and store in -variable: ${varName} -options: ${JSON.stringify(options_json)}`, async () => await doDecryptAndStore());
205
+ }
206
+ else {
207
+ await doDecryptAndStore();
208
+ }
209
+ }
210
+ /**
211
+ * Comm: Get-Random-From-List -arrayList: {param}
212
+ *
213
+ * Selects and returns a random item from a given non-empty array.
214
+ *
215
+ * @template T
216
+ * @param list - The array to select a random item from.
217
+ * @returns A randomly selected item from the array.
218
+ *
219
+ * @throws Error if the list is not a non-empty array.
220
+ *
221
+ */
222
+ async function getRandomFromList(list) {
223
+ if (!Array.isArray(list) || list.length === 0) {
224
+ throw new Error("⚠️ getRandomFromList: list must be a non-empty array.");
225
+ }
226
+ const index = Math.floor(Math.random() * list.length);
227
+ return list[index];
228
+ }
229
+ /**
230
+ * Comm: Remove-Leading-Zero-From-Date -text: {param}
231
+ *
232
+ * Removes leading zeros from both the day and month in a date string of format DD/MM/YYYY.
233
+ * Example: '03/07/2025' => '3/7/2025'
234
+ * @param dateStr - The date string in DD/MM/YYYY format
235
+ * @returns The date string with leading zeros removed from day and month
236
+ *
237
+ * @throws Error if `dateStr` is not a non-empty string.
238
+ */
239
+ async function removeLeadingZeroFromMonthAndDate(dateStr) {
240
+ if (typeof dateStr !== 'string' || dateStr.length === 0) {
241
+ throw new Error('❌ removeLeadingZeroFromMonthAndDate: dateStr must be a non-empty string.');
242
+ }
243
+ return dateStr.replace(/\b0(\d)/g, "$1");
244
+ }
245
+ /**
246
+ * Comm: Write-JSON-To-File -filePath: {param} -data: {param} -options: {param}
247
+ *
248
+ * Writes JSON data to a file with options to override, append, or wrap in array.
249
+ *
250
+ * @param filePath - The destination file path.
251
+ * @param data - The JSON data to write (object or array).
252
+ * @param options - { override, append, toArray }
253
+ *
254
+ * @throws Error if `filePath` is empty, if append mode file content is not a JSON array, or if both `override` and `append` are false.
255
+ */
256
+ async function writeJsonToFile(filePath, data, options = { override: true, append: false, toArray: false }) {
257
+ const defaultOptions = { override: true, append: false, toArray: false };
258
+ const opts = { ...defaultOptions, ...options };
259
+ if (typeof filePath !== 'string' || filePath.trim().length === 0) {
260
+ throw new Error('❌ writeJsonToFile: filePath must be a non-empty string.');
261
+ }
262
+ const absPath = path.resolve(filePath);
263
+ if (opts.append) {
264
+ // Only works if file contains an array
265
+ let arr = [];
266
+ if (fs.existsSync(absPath)) {
267
+ const fileContent = fs.readFileSync(absPath, 'utf-8');
268
+ try {
269
+ arr = JSON.parse(fileContent);
270
+ if (!Array.isArray(arr))
271
+ throw new Error('File does not contain a JSON array.');
272
+ }
273
+ catch {
274
+ throw new Error('File is not a valid JSON array.');
275
+ }
276
+ }
277
+ arr.push(data);
278
+ fs.writeFileSync(absPath, JSON.stringify(arr, null, 2), 'utf-8');
279
+ await global_1.comm.attachLog(`✅ JSON appended to file: ${absPath}`, 'text/plain');
280
+ }
281
+ else if (opts.override) {
282
+ // Overwrite or create new file
283
+ let out = data;
284
+ if (opts.toArray) {
285
+ out = Array.isArray(data) ? data : [data];
286
+ }
287
+ fs.writeFileSync(absPath, JSON.stringify(out, null, 2), 'utf-8');
288
+ await global_1.comm.attachLog(`✅ JSON written to file: ${absPath}`, 'text/plain');
289
+ }
290
+ else {
291
+ throw new Error('Either override or append must be true.');
292
+ }
293
+ }
294
+ /**
295
+ * Ensures the value is formatted as a currency string: $<amount>.00
296
+ * @param value - The input value (number or string)
297
+ * @returns {string} - Formatted as $<amount>.00
298
+ */
299
+ function toDollarAmount(value) {
300
+ // Remove any non-numeric except dot
301
+ let num = typeof value === 'number'
302
+ ? value
303
+ : parseFloat(String(value).replace(/[^0-9.]/g, ''));
304
+ if (isNaN(num))
305
+ num = 0;
306
+ return `$${num.toFixed(2)}`;
307
+ }
308
+ /**
309
+ * Comm: Generate TOTP Token to variable -varName: {param} -options: {param}
310
+ *
311
+ * Generates a TOTP (Time-based One-Time Password) token using the provided secret and stores it in a variable.
312
+ *
313
+ * @param varName - The name of the variable to store the generated TOTP token.
314
+ * @param options - Optional string or object containing:
315
+ * - secret: [string] The TOTP secret key (default: process.env.PLAYQ_TOTP_SECRET_KEY).
316
+ *
317
+ * @example
318
+ * Comm: Generate TOTP Token to variable -varName: "var.otp" -options: '{"secret":"MYSECRET"}'
319
+ */
320
+ async function generateTotpTokenToVariable(varName, options) {
321
+ const options_json = typeof options === "string" ? global_1.vars.parseLooseJson(options) : options || {};
322
+ const { secret, step = 30, digits = 6, algorithm = "SHA-1" } = options_json;
323
+ if (isPlaywrightRunner()) {
324
+ await __allureAny_comm.step(`Comm: Generate TOTP Token to variable -varName: ${varName} -options: ${JSON.stringify(options_json)}`, async () => {
325
+ await doGenerateTotpTokenToVariable();
326
+ });
327
+ }
328
+ else {
329
+ await doGenerateTotpTokenToVariable();
330
+ }
331
+ async function doGenerateTotpTokenToVariable() {
332
+ let secretKey = process.env.PLAYQ_TOTP_SECRET_KEY || secret;
333
+ if (!secretKey) {
334
+ throw new Error('❌ PLAYQ_TOTP_SECRET_KEY not found in environment variables or in options');
335
+ }
336
+ if (secretKey.startsWith("enc.")) {
337
+ secretKey = global_1.vars.replaceVariables(`#{${secretKey}}`);
338
+ }
339
+ const totpHelper = new totpHelper_1.TOTPHelper(secretKey);
340
+ // Generate and return token
341
+ const token = totpHelper.generateToken();
342
+ global_1.vars.setValue(varName, token);
343
+ }
344
+ }
345
+ /**
346
+ * Alias: wait
347
+ * Wrapper to maintain compatibility for step names mapping.
348
+ */
349
+ async function wait(ms) {
350
+ await new Promise((resolve) => setTimeout(resolve, ms));
351
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @file commActions.ts
3
+ *
4
+ * Communication actions gateway for logging, attachments, and utilities.
5
+ * Exposes a stable public surface while implementations live under ./comm/*.
6
+ *
7
+ * Key Features:
8
+ * - Allure-friendly logging and attachment helpers
9
+ * - Error context utilities for diagnostics
10
+ * - Backward-compatible re-exports via gateway
11
+ *
12
+ * Authors: Renish Kozhithottathil [Lead Automation Principal, NCS]
13
+ * Version: v1.0.0
14
+ *
15
+ * Note: This file adheres to the PlayQ Enterprise Automation Standards.
16
+ */
17
+ export * from './comm/commonActions';
18
+ export * from './comm/utilityActions';
@@ -0,0 +1,34 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * @file commActions.ts
19
+ *
20
+ * Communication actions gateway for logging, attachments, and utilities.
21
+ * Exposes a stable public surface while implementations live under ./comm/*.
22
+ *
23
+ * Key Features:
24
+ * - Allure-friendly logging and attachment helpers
25
+ * - Error context utilities for diagnostics
26
+ * - Backward-compatible re-exports via gateway
27
+ *
28
+ * Authors: Renish Kozhithottathil [Lead Automation Principal, NCS]
29
+ * Version: v1.0.0
30
+ *
31
+ * Note: This file adheres to the PlayQ Enterprise Automation Standards.
32
+ */
33
+ __exportStar(require("./comm/commonActions"), exports);
34
+ __exportStar(require("./comm/utilityActions"), exports);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ const global_1 = require("../../global");
5
+ // commonActions.ts
6
+ (0, cucumber_1.Given)("Comm: Wait for milliseconds -seconds: {param}", async function (seconds) {
7
+ await global_1.comm.waitInMilliSeconds(parseInt(seconds));
8
+ });
9
+ (0, cucumber_1.Given)("Comm: Comment -text: {param}", async function (comment) {
10
+ await global_1.comm.comment(comment);
11
+ });
12
+ (0, cucumber_1.Given)("Comm: Encrypt password -text: {param} -options: {param}", async function (encryptedText, options) {
13
+ await global_1.comm.encryptPassword(encryptedText, options);
14
+ });
15
+ (0, cucumber_1.Given)("Comm: Encrypt text -text: {param} -options: {param}", async function (encryptedText, options) {
16
+ await global_1.comm.encryptText(encryptedText, options);
17
+ });
18
+ (0, cucumber_1.Given)("Comm: Encrypt password -text: {param} and store in -variable: {param} -options: {param}", async function (textToEncrypt, varToStore, options) {
19
+ await global_1.comm.encryptPasswordAndStore(textToEncrypt, varToStore, options);
20
+ });
21
+ (0, cucumber_1.Given)("Comm: Encrypt text -text: {param} and store in -variable: {param} -options: {param}", async function (textToEncrypt, varToStore, options) {
22
+ console.log('Text to encrypt:', textToEncrypt);
23
+ await global_1.comm.encryptTextAndStore(textToEncrypt, varToStore, options);
24
+ });
25
+ (0, cucumber_1.Given)("Comm: Decrypt -text: {param} and store in -variable: {param} -options: {param}", async function (encryptedText, varName, options) {
26
+ await global_1.comm.decrypt(encryptedText, varName, options);
27
+ });
28
+ (0, cucumber_1.Given)("Comm: Get random from list -arrayList: {param}", async function (list) {
29
+ const arrayList = JSON.parse(list);
30
+ await global_1.comm.getRandomFromList(arrayList);
31
+ });
32
+ (0, cucumber_1.Given)("Comm: Remove leading zero from date -text: {param}", async function (dateText) {
33
+ await global_1.comm.removeLeadingZeroFromMonthAndDate(dateText);
34
+ });
35
+ (0, cucumber_1.Given)("Comm: Write JSON to file -filePath: {param} -data: {param} -options: {param}", async function (filePath, data, options) {
36
+ await global_1.comm.writeJsonToFile(filePath, data, options);
37
+ });
38
+ (0, cucumber_1.Given)("Comm: Attach log -message: {param} -mimeType: {param} -msgType: {param}", async function (message, mimeType, msgType) {
39
+ await global_1.comm.attachLog(message, mimeType, msgType);
40
+ });
41
+ (0, cucumber_1.Given)("Comm: Store -value: {param} in -variable: {param} -options: {param}", async function (value, varName, options) {
42
+ await global_1.comm.storeValue(value, varName, options);
43
+ });
44
+ // utilityActions.ts
45
+ (0, cucumber_1.Given)("Comm: To Dollar Amount -value: {param}", async function (value) {
46
+ const formatted = await global_1.comm.toDollarAmount(Number(value));
47
+ await global_1.comm.attachLog(`Formatted dollars: ${formatted}`, 'text/plain', 'COMM');
48
+ });
49
+ // TOTP token generation
50
+ (0, cucumber_1.Given)("Comm: Generate TOTP Token to variable -varName: {param} -options: {param}", async function (varName, options) {
51
+ await global_1.comm.generateTotpTokenToVariable(varName, options);
52
+ });
53
+ // utilityActions.ts (alias wait)
54
+ (0, cucumber_1.Given)("Comm: Wait -ms: {param}", async function (ms) {
55
+ const value = parseInt(String(ms));
56
+ await global_1.comm.wait(value);
57
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ (0, cucumber_1.Given)("Step Group: {param} {param}", async function (stepGroupName, stepGroupDesc) {
5
+ console.error(`❌ Step Group not available: ${stepGroupName} | ${stepGroupDesc}`);
6
+ });
7
+ (0, cucumber_1.Given)("- Step Group - START: {param} Desc: {param}", async function (stepGroupName, stepGroupDesc) {
8
+ console.log(`-> Step Group [START]: ${stepGroupName} | ${stepGroupDesc}`);
9
+ });
10
+ (0, cucumber_1.Given)("- Step Group - END: {string}", async function (stepGroupName) {
11
+ console.log(`-> Step Group [END]: ${stepGroupName}`);
12
+ });
13
+ (0, cucumber_1.Given)("Step Group: tests", async function (stepGroupName, stepGroupDesc) {
14
+ console.error(`❌ Step Group not available: ${stepGroupName} | ${stepGroupDesc}`);
15
+ });
@@ -0,0 +1,61 @@
1
+ import { Page } from "@playwright/test";
2
+ /**
3
+ * Web: Accept Alert -options: {param}
4
+ *
5
+ * Waits for a browser alert and accepts it. Attaches the alert text and optionally captures a screenshot.
6
+ *
7
+ * @param page - Playwright Page instance
8
+ * @param options - Optional JSON string or object:
9
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
10
+ * - screenshot: [boolean] Capture screenshot after handling the alert (default: false)
11
+ * - screenshotText: [string] Description for screenshot (default: "")
12
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
13
+ * @throws Error if page is not initialized or alert does not appear within timeout
14
+ */
15
+ export declare function acceptAlert(page: Page, options?: string | Record<string, any>): Promise<void>;
16
+ /**
17
+ * Web: Dismiss Alert -options: {param}
18
+ *
19
+ * Waits for a browser alert and dismisses it. Attaches the alert text and optionally captures a screenshot.
20
+ *
21
+ * @param page - Playwright Page instance
22
+ * @param options - Optional JSON string or object:
23
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
24
+ * - screenshot: [boolean] Capture screenshot after handling the alert (default: false)
25
+ * - screenshotText: [string] Description for screenshot (default: "")
26
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
27
+ * @throws Error if page is not initialized or alert does not appear within timeout
28
+ */
29
+ export declare function dismissAlert(page: Page, options?: string | Record<string, any>): Promise<void>;
30
+ /**
31
+ * Web: Fill Alert -text: {param} -options: {param}
32
+ *
33
+ * Waits for a prompt alert and fills it with the provided text. Attaches the alert text and optionally captures a screenshot.
34
+ *
35
+ * @param page - Playwright Page instance
36
+ * @param text - Text to send to alert prompt
37
+ * @param options - Optional JSON string or object:
38
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
39
+ * - screenshot: [boolean] Capture screenshot after handling the alert (default: false)
40
+ * - screenshotText: [string] Description for screenshot (default: "")
41
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
42
+ * @throws Error if page is not initialized or alert does not appear within timeout
43
+ */
44
+ export declare function fillAlert(page: Page, text: string, options?: string | Record<string, any>): Promise<void>;
45
+ /**
46
+ * Web: See Alert Text -expected: {param} -options: {param}
47
+ *
48
+ * Verifies the next alert message matches the expected text. Supports partial match and case-insensitive comparison.
49
+ *
50
+ * @param page - Playwright Page instance
51
+ * @param expected - Expected alert text
52
+ * @param options - Optional JSON string or object:
53
+ * - actionTimeout: [number] Timeout to wait for alert (default: config or 10000)
54
+ * - partialMatch: [boolean] If true, checks substring instead of exact match (default: false)
55
+ * - ignoreCase: [boolean] Case-insensitive comparison (default: false)
56
+ * - assert: [boolean] If false, logs failure but does not throw (default: true)
57
+ * - screenshot: [boolean] Capture screenshot after verification (default: false)
58
+ * - screenshotText: [string] Description for screenshot (default: "")
59
+ * - screenshotFullPage: [boolean] Full page screenshot (default: true)
60
+ */
61
+ export declare function seeAlertText(page: Page, expected: string, options?: string | Record<string, any>): Promise<void>;