@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,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webFixture = void 0;
4
+ const browserManager_1 = require("../browsers/browserManager");
5
+ // Inline runner detection to avoid external alias dependency
6
+ function isPlaywrightRunner() { return process.env.TEST_RUNNER === 'playwright'; }
7
+ const pages = new Map();
8
+ const frames = new Map();
9
+ let currentPage;
10
+ let currentFrame;
11
+ let logger;
12
+ let currentPageName = "main";
13
+ let browser;
14
+ let context;
15
+ let _world = null;
16
+ let smartIQData = [];
17
+ exports.webFixture = {
18
+ pages,
19
+ frames,
20
+ async launchBrowser() {
21
+ browser = await (0, browserManager_1.invokeBrowser)();
22
+ },
23
+ async newContext(options) {
24
+ if (!options) {
25
+ options = {
26
+ recordVideo: {
27
+ dir: "test-results/videos",
28
+ },
29
+ };
30
+ }
31
+ context = await browser.newContext(options);
32
+ return context;
33
+ },
34
+ async newPage(name = "main") {
35
+ const page = await context.newPage();
36
+ pages.set(name, page);
37
+ currentPage = page;
38
+ currentPageName = name;
39
+ return page;
40
+ },
41
+ getBrowser() {
42
+ return browser;
43
+ },
44
+ getContext() {
45
+ return context;
46
+ },
47
+ getCurrentPage() {
48
+ return currentPage;
49
+ },
50
+ setCurrentPage(name) {
51
+ currentPage = pages.get(name);
52
+ currentPageName = name;
53
+ },
54
+ async closeContext() {
55
+ if (context) {
56
+ await context.close();
57
+ }
58
+ },
59
+ async closeAll() {
60
+ try {
61
+ if (context) {
62
+ // Close all pages explicitly
63
+ const allPages = context.pages();
64
+ for (const page of allPages) {
65
+ try {
66
+ // If tracing is on, stop and save
67
+ if (context.tracing && context.tracing.stop) {
68
+ await context.tracing.stop({ path: `test-results/trace/trace.zip` });
69
+ }
70
+ await page.close();
71
+ }
72
+ catch (err) {
73
+ // Swallow errors silently
74
+ }
75
+ }
76
+ await context.close();
77
+ }
78
+ if (browser) {
79
+ await browser.close();
80
+ }
81
+ }
82
+ catch (err) {
83
+ // Swallow errors silently
84
+ }
85
+ },
86
+ setWorld(world) {
87
+ _world = world;
88
+ },
89
+ getWorld() {
90
+ if (isPlaywrightRunner()) {
91
+ console.warn('⚠️ Skipping getWorld() in Playwright Runner');
92
+ return null;
93
+ }
94
+ if (!_world) {
95
+ throw new Error("❌ Cucumber World context not set. Did you forget to call webFixture.setWorld(this) in your step?");
96
+ }
97
+ return _world;
98
+ },
99
+ // other frame helpers remain the same
100
+ setPlaywrightPage(page) {
101
+ console.log('✅ Playwright page set in webFixture');
102
+ currentPage = page;
103
+ },
104
+ // SmartIQ Imeplementation
105
+ getSmartIQData() {
106
+ return smartIQData;
107
+ },
108
+ setSmartIQData(data) {
109
+ smartIQData = data;
110
+ }
111
+ };
112
+ async function createContextWithDefaults(scenarioName) {
113
+ const ctx = await browser.newContext({
114
+ recordVideo: {
115
+ dir: "test-results/videos",
116
+ },
117
+ });
118
+ await ctx.tracing.start({
119
+ name: scenarioName,
120
+ title: scenarioName,
121
+ sources: true,
122
+ screenshots: true,
123
+ snapshots: true,
124
+ });
125
+ return ctx;
126
+ }
127
+ // import { Page, Frame } from "@playwright/test";
128
+ // import { Logger } from "winston";
129
+ // import { invokeBrowser } from "@helper/browsers/browserManager";
130
+ // const pages = new Map<string, Page>();
131
+ // const frames = new Map<string, Frame>();
132
+ // let currentPage: Page | undefined;
133
+ // let currentFrame: Frame | undefined;
134
+ // let logger: Logger;
135
+ // let currentPageName: string = "main";
136
+ // export const uiFixture = {
137
+ // pages,
138
+ // frames,
139
+ // setPage(page: Page) {
140
+ // pages.set(currentPageName, page);
141
+ // },
142
+ // setPageWithName(name: string, page: Page) {
143
+ // pages.set(name, page);
144
+ // currentPage = page;
145
+ // currentPageName = name;
146
+ // },
147
+ // getPage(name: string): Page | undefined {
148
+ // return pages.get(name);
149
+ // },
150
+ // setCurrentPage(name: string) {
151
+ // currentPage = pages.get(name);
152
+ // currentPageName = name;
153
+ // },
154
+ // getCurrentPage(): Page | undefined {
155
+ // return currentPage;
156
+ // },
157
+ // getCurrentPageName(): string {
158
+ // return currentPageName;
159
+ // },
160
+ // setFrame(name: string, frame: Frame) {
161
+ // frames.set(name, frame);
162
+ // currentFrame = frame;
163
+ // },
164
+ // getFrame(name: string): Frame | undefined {
165
+ // return frames.get(name);
166
+ // },
167
+ // setCurrentFrame(name: string) {
168
+ // currentFrame = frames.get(name);
169
+ // },
170
+ // getCurrentFrame(): Frame | undefined {
171
+ // return currentFrame;
172
+ // },
173
+ // setLogger(log: Logger) {
174
+ // logger = log;
175
+ // },
176
+ // getLogger(): Logger {
177
+ // return logger;
178
+ // }
179
+ // };
180
+ // import { Page } from "@playwright/test";
181
+ // import { Logger } from "winston";
182
+ // export const fixture = {
183
+ // // @ts-ignore
184
+ // page: undefined as Page,
185
+ // logger: undefined as Logger
186
+ // }
@@ -0,0 +1,2 @@
1
+ import type { Page, Locator } from "playwright";
2
+ export declare function webLocResolver(type: string, selector: string, pageArg: Page, overridePattern?: string, timeout?: number, smartAiRefresh?: 'before' | 'after' | ''): Promise<Locator>;
@@ -0,0 +1,144 @@
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.webLocResolver = webLocResolver;
37
+ const vars = __importStar(require("../bundle/vars"));
38
+ // Access project-provided engines dynamically at call time to avoid module init ordering issues
39
+ function getEngines() { return globalThis.engines || {}; }
40
+ // import { smartAI} from "@project/engines/smartAi/smartAiEngine";
41
+ async function webLocResolver(type, selector, pageArg, overridePattern, timeout, smartAiRefresh = '') {
42
+ var _a, _b, _c, _d, _e;
43
+ console.log(`🔍 Resolving locator: ${selector}`);
44
+ const page = pageArg;
45
+ const isPlaywrightPrefixed = selector.startsWith("xpath=") || selector.startsWith("xpath =") || selector.startsWith("css=") || selector.startsWith("css =");
46
+ if (isPlaywrightPrefixed) {
47
+ // const rawSelector = selector.replace(/^xpath=|^css=|^xpath =|^xpath=\\|^xpath =\\|^css =/, "");
48
+ // Normalize escaped forward slashes first, then remove prefix
49
+ const rawSelector = selector
50
+ .replace(/^xpath=\\|^xpath =\\/, "xpath=") // normalize `xpath=\` to `xpath=`
51
+ .replace(/^xpath=|^xpath =|^css=|^css =/, "") // remove the actual prefix
52
+ .replace(/\\\//g, "/"); // replace escaped slashes with normal ones
53
+ console.log("📍 Detected Playwright-prefixed selector. Returning raw locator.");
54
+ return page.locator(rawSelector);
55
+ }
56
+ const isPlaywrightChainedPrefixed = selector.startsWith("chain=") || selector.startsWith("chain =");
57
+ if (isPlaywrightChainedPrefixed) {
58
+ const rawSelector = selector.replace(/^chain=|^chain =/, "");
59
+ console.log("📍 Detected Playwright-prefixed chained selector. Returning raw locator.");
60
+ return page.locator(rawSelector);
61
+ }
62
+ const isXPath = selector.trim().startsWith("//") || selector.trim().startsWith("(");
63
+ const isCSS = selector.includes(">") ||
64
+ selector.startsWith(".") ||
65
+ selector.includes("#");
66
+ const isChained = selector.includes(">>");
67
+ const isResourceLocator = selector.startsWith("loc.");
68
+ if ((isXPath || isCSS || isChained) && !isResourceLocator) {
69
+ console.log("📍 Detected XPath/CSS/Chained. Returning locator directly.");
70
+ return page.locator(selector);
71
+ }
72
+ if (isResourceLocator) {
73
+ const parts = selector.split(".");
74
+ if (parts.length < 3) {
75
+ throw new Error(`❌ Invalid locator format: "${selector}". Expected format: loc.(ts|json).<page>.<field>`);
76
+ }
77
+ const [, locType, pageName, fieldName] = parts;
78
+ if (selector.startsWith("loc.json.")) {
79
+ const [, , fileName, pageName, fieldName] = selector.split(".");
80
+ const jsonLocatorMap = await Promise.resolve(`${`@resources/locators/json/${fileName}.json`}`).then(s => __importStar(require(s)));
81
+ const pageObj = jsonLocatorMap === null || jsonLocatorMap === void 0 ? void 0 : jsonLocatorMap[pageName];
82
+ if (!pageObj)
83
+ throw new Error(`❌ Page "${pageName}" not found in ${fileName}.json`);
84
+ const locatorString = pageObj[fieldName];
85
+ if (!locatorString)
86
+ throw new Error(`❌ Field "${fieldName}" not found in ${fileName}.json[${pageName}]`);
87
+ console.log(`🧩 Resolved locator string from loc.json.${fileName}.${pageName}.${fieldName} -> ${locatorString}`);
88
+ return page.locator(await vars.replaceVariables(locatorString));
89
+ }
90
+ if (selector.startsWith("loc.ts.")) {
91
+ const [, , fileName, pageName, fieldName] = selector.split(".");
92
+ // First try globalThis.loc if available
93
+ const globalLoc = globalThis.loc;
94
+ if ((_b = (_a = globalLoc === null || globalLoc === void 0 ? void 0 : globalLoc[fileName]) === null || _a === void 0 ? void 0 : _a[pageName]) === null || _b === void 0 ? void 0 : _b[fieldName]) {
95
+ // console.log(`✅ Found locator in globalThis.loc for loc.ts.${fileName}.${pageName}.${fieldName}`);
96
+ return globalLoc[fileName][pageName][fieldName](page);
97
+ }
98
+ }
99
+ if (selector.startsWith("loc.")) {
100
+ const [, fileName, pageName, fieldName] = selector.split(".");
101
+ // First try globalThis.loc if available
102
+ const globalLoc = globalThis.loc;
103
+ if ((_d = (_c = globalLoc === null || globalLoc === void 0 ? void 0 : globalLoc[fileName]) === null || _c === void 0 ? void 0 : _c[pageName]) === null || _d === void 0 ? void 0 : _d[fieldName]) {
104
+ // console.log(`✅ Found locator in globalThis.loc for loc.ts.${fileName}.${pageName}.${fieldName}`);
105
+ return globalLoc[fileName][pageName][fieldName](page);
106
+ }
107
+ }
108
+ throw new Error(`❌ Unknown locator source type "${locType}". Use loc. or locator.`);
109
+ }
110
+ if (overridePattern && overridePattern.toLowerCase() === '-no-check-') {
111
+ console.log("📍 '-no-check-' detected. Skipping locator resolution.");
112
+ return undefined; // or even better, throw a custom signal or null to trigger fallback
113
+ }
114
+ // SmartAI (guard if engine missing)
115
+ const isSmartAiEnabled = String(vars.getConfigValue('smartAi.enable')).toLowerCase().trim() === 'true';
116
+ if (isSmartAiEnabled) {
117
+ const smartAiEngine = (_e = getEngines()) === null || _e === void 0 ? void 0 : _e.smartAi;
118
+ if (typeof smartAiEngine === 'function') {
119
+ return await smartAiEngine(page, type, selector, smartAiRefresh);
120
+ }
121
+ else {
122
+ console.warn('⚠️ SmartAI enabled but engines.smartAi not available/function. Falling back.');
123
+ }
124
+ }
125
+ // Fallback to locatorPattern (locPattern)
126
+ const isPatternEnabled = String(vars.getConfigValue('patternIq.enable')).toLowerCase().trim() === 'true';
127
+ console.log('PatternIQ enabled?', isPatternEnabled);
128
+ if (isPatternEnabled) {
129
+ const eng = getEngines();
130
+ try {
131
+ console.log('PatternIQ engines keys:', Object.keys(eng || {}));
132
+ }
133
+ catch { }
134
+ const patternEngine = (eng === null || eng === void 0 ? void 0 : eng.patternIq) || (eng && eng.engines && eng.engines.patternIq);
135
+ if (typeof patternEngine === 'function') {
136
+ return await patternEngine(page, type, selector, overridePattern, timeout);
137
+ }
138
+ else {
139
+ console.warn('⚠️ PatternIQ enabled but engines.patternIq not available/function. Falling back to default locator.');
140
+ }
141
+ }
142
+ // Fallback to default locator
143
+ return page.locator(selector);
144
+ }
File without changes
@@ -0,0 +1,25 @@
1
+ // src/helper/report/allureStepLogger.ts
2
+ // import { step, attachment, owner, issue } from 'allure-js-commons';
3
+ // import { isCucumberRunner } from '@config/runner';
4
+ // import { webFixture } from '@helper/fixtures/webFixture';
5
+ // /**
6
+ // * Logs a step to Allure or attaches it in Cucumber world.
7
+ // *
8
+ // * @param stepName Description of the step
9
+ // * @param stepFn Function to execute within the step
10
+ // */
11
+ // export async function logStep(stepName: string, stepFn: () => Promise<void>) {
12
+ // if (isCucumberRunner()) {
13
+ // const world = webFixture.getWorld();
14
+ // try {
15
+ // await world.attach(`🟡 Step: ${stepName}`, 'text/plain');
16
+ // await stepFn();
17
+ // await world.attach(`✅ Passed: ${stepName}`, 'text/plain');
18
+ // } catch (err: any) {
19
+ // await world.attach(`❌ Failed: ${stepName} - ${err.message}`, 'text/plain');
20
+ // throw err;
21
+ // }
22
+ // } else {
23
+ // await allure.step(stepName, stepFn);
24
+ // }
25
+ // }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const inputPath = 'test-results/cucumber-report.json';
8
+ const outputPath = 'test-results/cucumber-report-custom.json';
9
+ function extractReplacements(embeddings) {
10
+ const replacements = {};
11
+ embeddings === null || embeddings === void 0 ? void 0 : embeddings.forEach(embed => {
12
+ const data = embed === null || embed === void 0 ? void 0 : embed.data;
13
+ const match = data === null || data === void 0 ? void 0 : data.match(/Replaced: \|\\?"(.*?)\\?"\|-with-\|(.*?)\|/);
14
+ if (match) {
15
+ const original = match[1];
16
+ const replaced = match[2];
17
+ replacements[original] = replaced;
18
+ }
19
+ });
20
+ return replacements;
21
+ }
22
+ function updateStepName(step) {
23
+ const replacements = extractReplacements(step.embeddings || []);
24
+ for (const [original, replaced] of Object.entries(replacements)) {
25
+ const quotedOriginal = `"${original}"`;
26
+ const quotedReplaced = `"${replaced}"`;
27
+ step.name = step.name.replace(quotedOriginal, quotedReplaced);
28
+ }
29
+ }
30
+ function processReport() {
31
+ const raw = fs_1.default.readFileSync(inputPath, 'utf-8');
32
+ if (!raw || !raw.trim()) {
33
+ console.warn("⚠️ customiseReport: Empty or invalid JSON input. Skipping processing.");
34
+ return;
35
+ }
36
+ const report = JSON.parse(raw);
37
+ for (const feature of report) {
38
+ for (const scenario of feature.elements || []) {
39
+ for (const step of scenario.steps || []) {
40
+ updateStepName(step);
41
+ // Check for soft assertion failures in embeddings
42
+ if (Array.isArray(step.embeddings) &&
43
+ step.embeddings.some((embed) => typeof embed.data === "string" &&
44
+ embed.data.includes("Soft Assertion: [Failed]"))) {
45
+ if (!step.result)
46
+ step.result = {};
47
+ step.result.status = "failed";
48
+ }
49
+ }
50
+ }
51
+ }
52
+ fs_1.default.writeFileSync(outputPath, JSON.stringify(report, null, 2), 'utf-8');
53
+ console.log(`✅ Updated report written to ${outputPath}`);
54
+ }
55
+ processReport();
@@ -0,0 +1 @@
1
+ declare const fs: any;
@@ -0,0 +1,14 @@
1
+ const fs = require("fs-extra");
2
+ try {
3
+ fs.ensureDirSync("test-results/screenshots");
4
+ fs.emptyDirSync("test-results/screenshots");
5
+ fs.ensureDirSync("test-results/videos");
6
+ fs.emptyDirSync("test-results/videos");
7
+ fs.ensureDirSync("test-results/trace");
8
+ fs.emptyDirSync("test-results/trace");
9
+ // Do NOT clean the whole test-results folder!
10
+ // fs.emptyDirSync("test-results");
11
+ }
12
+ catch (error) {
13
+ console.log("⚠️ Folder setup failed! " + error);
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,102 @@
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
+ const report = require("multiple-cucumber-html-reporter");
37
+ const fs = __importStar(require("fs"));
38
+ const os = __importStar(require("os"));
39
+ const jsonPath = "test-results/cucumber-report.json";
40
+ if (!fs.existsSync(jsonPath)) {
41
+ console.warn("⚠️ cucumber-report.json not found.");
42
+ const files = fs.readdirSync("test-results");
43
+ console.warn("📁 test-results folder contains:", files);
44
+ }
45
+ else {
46
+ // 💡 Load JSON, patch paths, save back
47
+ const raw = fs.readFileSync(jsonPath, "utf-8");
48
+ const data = JSON.parse(raw);
49
+ data.forEach((feature) => {
50
+ var _a;
51
+ if ((_a = feature.uri) === null || _a === void 0 ? void 0 : _a.startsWith("_TEMP/execution/")) {
52
+ feature.uri = feature.uri.replace("_TEMP/execution/", "");
53
+ }
54
+ });
55
+ fs.writeFileSync(jsonPath, JSON.stringify(data, null, 2)); // Save the cleaned version
56
+ }
57
+ // Removing "_TEMP/execution/" from cucumber-report.html
58
+ const htmlReportPath = "test-results/cucumber-report.html";
59
+ if (fs.existsSync(htmlReportPath)) {
60
+ let html = fs.readFileSync(htmlReportPath, "utf-8");
61
+ // Use split/join for wide Node compatibility (avoid String.replaceAll requirement)
62
+ const updatedHtml = html.split("_TEMP/execution/").join("");
63
+ fs.writeFileSync(htmlReportPath, updatedHtml, "utf-8");
64
+ console.log("🧼 Cleaned cucumber-report.html by removing '_TEMP/execution/'");
65
+ }
66
+ else {
67
+ console.warn("⚠️ cucumber-report.html not found.");
68
+ }
69
+ if (fs.existsSync(jsonPath)) {
70
+ fs.unlinkSync(jsonPath);
71
+ console.log(`🗑️ Removed existing ${jsonPath}`);
72
+ }
73
+ // Fetching the system details
74
+ const platformName = os.platform();
75
+ const platformVersion = os.release();
76
+ const deviceName = os.hostname();
77
+ report.generate({
78
+ jsonDir: "test-results",
79
+ reportPath: "test-results/reports/",
80
+ reportName: "Playwright Automation Report",
81
+ pageTitle: "BookCart App test report",
82
+ displayDuration: false,
83
+ metadata: {
84
+ browser: {
85
+ name: "chrome",
86
+ version: "112",
87
+ },
88
+ device: deviceName,
89
+ platform: {
90
+ name: platformName,
91
+ version: platformVersion,
92
+ },
93
+ },
94
+ customData: {
95
+ title: "Test Info",
96
+ data: [
97
+ { label: "Project", value: "Book Cart Application" },
98
+ { label: "Release", value: "1.2.3" },
99
+ { label: "Cycle", value: "Smoke-1" },
100
+ ],
101
+ },
102
+ });
@@ -0,0 +1,10 @@
1
+ type DataFormat = 'json' | 'excel' | 'csv';
2
+ /**
3
+ * Reads test data from .json, .xlsx, or .csv
4
+ *
5
+ * @param file - Filename (without extension), e.g., "login"
6
+ * @param format - File format: "json" | "excel" | "csv"
7
+ * @param sheetName - (optional) Sheet name for Excel files
8
+ */
9
+ export declare function getTestData(file: string, format?: DataFormat, sheetName?: string): any[];
10
+ export {};
@@ -0,0 +1,73 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getTestData = getTestData;
40
+ const fs_1 = __importDefault(require("fs"));
41
+ const path_1 = __importDefault(require("path"));
42
+ const XLSX = __importStar(require("@e965/xlsx"));
43
+ /**
44
+ * Reads test data from .json, .xlsx, or .csv
45
+ *
46
+ * @param file - Filename (without extension), e.g., "login"
47
+ * @param format - File format: "json" | "excel" | "csv"
48
+ * @param sheetName - (optional) Sheet name for Excel files
49
+ */
50
+ function getTestData(file, format = 'json', sheetName) {
51
+ const basePath = path_1.default.resolve(`resources/test-data`);
52
+ switch (format) {
53
+ case 'json': {
54
+ const jsonPath = path_1.default.join(basePath, `${file}.json`);
55
+ const raw = fs_1.default.readFileSync(jsonPath, 'utf-8');
56
+ return JSON.parse(raw);
57
+ }
58
+ case 'excel': {
59
+ const xlsxPath = path_1.default.join(basePath, `${file}.xlsx`);
60
+ const workbook = XLSX.readFile(xlsxPath);
61
+ const sheet = workbook.Sheets[sheetName || workbook.SheetNames[0]];
62
+ return XLSX.utils.sheet_to_json(sheet);
63
+ }
64
+ case 'csv': {
65
+ const csvPath = path_1.default.join(basePath, `${file}.csv`);
66
+ const fileData = fs_1.default.readFileSync(csvPath, 'utf-8');
67
+ const worksheet = XLSX.read(fileData, { type: 'string' }).Sheets['Sheet1'];
68
+ return XLSX.utils.sheet_to_json(worksheet);
69
+ }
70
+ default:
71
+ throw new Error(`Unsupported format: ${format}`);
72
+ }
73
+ }
@@ -0,0 +1,4 @@
1
+ import { transports } from "winston";
2
+ export declare function options(scenarioName: string): {
3
+ transports: transports.FileTransportInstance[];
4
+ };