pomwright 1.3.0 → 1.5.0

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 (117) hide show
  1. package/AGENTS.md +37 -0
  2. package/CHANGELOG.md +193 -0
  3. package/README.md +316 -34
  4. package/dist/index.d.mts +1058 -132
  5. package/dist/index.d.ts +1058 -132
  6. package/dist/index.js +2309 -185
  7. package/dist/index.mjs +2304 -185
  8. package/docs/{get-locator-methods-explanation.md → v1/get-locator-methods-explanation.md} +0 -16
  9. package/docs/v1-to-v2-migration/bridge-migration-guide.md +159 -0
  10. package/docs/v1-to-v2-migration/direct-migration-guide.md +238 -0
  11. package/docs/v1-to-v2-migration/v1-to-v2-comparison.md +547 -0
  12. package/docs/v2/PageObject.md +293 -0
  13. package/docs/v2/composing-locator-modules.md +93 -0
  14. package/docs/v2/locator-registry.md +693 -0
  15. package/docs/v2/logging.md +168 -0
  16. package/docs/v2/overview.md +515 -0
  17. package/docs/v2/session-storage.md +160 -0
  18. package/index.ts +61 -9
  19. package/intTestV2/.env +0 -0
  20. package/intTestV2/fixtures/testApp.fixtures.ts +43 -0
  21. package/intTestV2/package.json +22 -0
  22. package/intTestV2/page-object-models/testApp/pages/iframe/iframe.locatorSchema.ts +24 -0
  23. package/intTestV2/page-object-models/testApp/pages/iframe/iframe.page.ts +17 -0
  24. package/intTestV2/page-object-models/testApp/pages/testPage.locatorSchema.ts +32 -0
  25. package/intTestV2/page-object-models/testApp/pages/testPage.page.ts +119 -0
  26. package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.locatorSchema.ts +29 -0
  27. package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.page.ts +48 -0
  28. package/intTestV2/page-object-models/testApp/pages/testPath/testPath.locatorSchema.ts +9 -0
  29. package/intTestV2/page-object-models/testApp/pages/testPath/testPath.page.ts +23 -0
  30. package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.locatorSchema.ts +114 -0
  31. package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.page.ts +23 -0
  32. package/intTestV2/page-object-models/testApp/testApp.base.ts +20 -0
  33. package/intTestV2/playwright.config.ts +54 -0
  34. package/intTestV2/server.js +216 -0
  35. package/intTestV2/test-data/staticPage/index.html +280 -0
  36. package/intTestV2/test-data/staticPage/w3images/avatar2.png +0 -0
  37. package/intTestV2/test-data/staticPage/w3images/avatar3.png +0 -0
  38. package/intTestV2/test-data/staticPage/w3images/avatar5.png +0 -0
  39. package/intTestV2/test-data/staticPage/w3images/avatar6.png +0 -0
  40. package/intTestV2/test-data/staticPage/w3images/forest.jpg +0 -0
  41. package/intTestV2/test-data/staticPage/w3images/lights.jpg +0 -0
  42. package/intTestV2/test-data/staticPage/w3images/mountains.jpg +0 -0
  43. package/intTestV2/test-data/staticPage/w3images/nature.jpg +0 -0
  44. package/intTestV2/test-data/staticPage/w3images/snow.jpg +0 -0
  45. package/intTestV2/tests/locatorRegistry/add/add.describe.spec.ts +54 -0
  46. package/intTestV2/tests/locatorRegistry/add/add.filter.spec.ts +143 -0
  47. package/intTestV2/tests/locatorRegistry/add/add.frameLocator.spec.ts +23 -0
  48. package/intTestV2/tests/locatorRegistry/add/add.getByAltText.spec.ts +23 -0
  49. package/intTestV2/tests/locatorRegistry/add/add.getById.spec.ts +45 -0
  50. package/intTestV2/tests/locatorRegistry/add/add.getByLabel.spec.ts +23 -0
  51. package/intTestV2/tests/locatorRegistry/add/add.getByPlaceholder.spec.ts +23 -0
  52. package/intTestV2/tests/locatorRegistry/add/add.getByRole.spec.ts +23 -0
  53. package/intTestV2/tests/locatorRegistry/add/add.getByTestId.spec.ts +23 -0
  54. package/intTestV2/tests/locatorRegistry/add/add.getByText.spec.ts +23 -0
  55. package/intTestV2/tests/locatorRegistry/add/add.getByTitle.spec.ts +23 -0
  56. package/intTestV2/tests/locatorRegistry/add/add.locator.spec.ts +23 -0
  57. package/intTestV2/tests/locatorRegistry/add/add.reuseExisting.spec.ts +66 -0
  58. package/intTestV2/tests/locatorRegistry/add/add.reuseReusable.spec.ts +311 -0
  59. package/intTestV2/tests/locatorRegistry/add/add.spec.ts +159 -0
  60. package/intTestV2/tests/locatorRegistry/filter.cycle.spec.ts +39 -0
  61. package/intTestV2/tests/locatorRegistry/getLocator/getLocator.spec.ts +253 -0
  62. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.clearSteps.spec.ts +105 -0
  63. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.describe.spec.ts +23 -0
  64. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.filter.spec.ts +368 -0
  65. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getLocator.spec.ts +56 -0
  66. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getNestedLocator.spec.ts +175 -0
  67. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.nth.spec.ts +60 -0
  68. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.remove.spec.ts +32 -0
  69. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.replace.spec.ts +24 -0
  70. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.spec.ts +110 -0
  71. package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.update.spec.ts +322 -0
  72. package/intTestV2/tests/locatorRegistry/getNestedLocator/getNestedLocator.spec.ts +412 -0
  73. package/intTestV2/tests/locatorRegistry/registry/registry.binding.spec.ts +50 -0
  74. package/intTestV2/tests/locatorRegistry/validation/validation.locatorSchemaPath.spec.ts +115 -0
  75. package/intTestV2/tests/locatorRegistry/validation/validation.sub-path.spec.ts +45 -0
  76. package/intTestV2/tests/step/step.spec.ts +49 -0
  77. package/intTestV2/tests/testApp/color.spec.ts +15 -0
  78. package/intTestV2/tests/testApp/iframe.spec.ts +57 -0
  79. package/intTestV2/tests/testApp/testFilters.spec.ts +24 -0
  80. package/intTestV2/tests/testApp/testPage.spec.ts +161 -0
  81. package/intTestV2/tests/testApp/testPath.spec.ts +18 -0
  82. package/pack-build.sh +11 -0
  83. package/pack-test-v2.sh +36 -0
  84. package/package.json +10 -3
  85. package/playwright.base.ts +42 -0
  86. package/skills/README.md +56 -0
  87. package/skills/pomwright-v1-5-bridge-migration/SKILL.md +40 -0
  88. package/skills/pomwright-v1-5-bridge-migration/references/call-site-migration.md +178 -0
  89. package/skills/pomwright-v1-5-bridge-migration/references/schema-translation.md +183 -0
  90. package/skills/pomwright-v2-migration/SKILL.md +63 -0
  91. package/skills/pomwright-v2-migration/references/call-site-migration.md +265 -0
  92. package/skills/pomwright-v2-migration/references/class-migration.md +266 -0
  93. package/skills/pomwright-v2-migration/references/fixture-and-helpers.md +423 -0
  94. package/skills/pomwright-v2-migration/references/locator-registration.md +344 -0
  95. package/srcV2/fixture/base.fixtures.ts +23 -0
  96. package/srcV2/helpers/navigation.ts +153 -0
  97. package/srcV2/helpers/playwrightReportLogger.ts +196 -0
  98. package/srcV2/helpers/sessionStorage.ts +251 -0
  99. package/srcV2/helpers/stepDecorator.ts +106 -0
  100. package/srcV2/locators/index.ts +15 -0
  101. package/srcV2/locators/locatorQueryBuilder.ts +427 -0
  102. package/srcV2/locators/locatorRegistrationBuilder.ts +558 -0
  103. package/srcV2/locators/locatorRegistry.ts +541 -0
  104. package/srcV2/locators/locatorUpdateBuilder.ts +602 -0
  105. package/srcV2/locators/reusableLocatorBuilder.ts +200 -0
  106. package/srcV2/locators/types.ts +256 -0
  107. package/srcV2/locators/utils.ts +309 -0
  108. package/srcV2/locators/v1SchemaTranslator.ts +178 -0
  109. package/srcV2/pageObject.ts +105 -0
  110. /package/docs/{BaseApi-explanation.md → v1/BaseApi-explanation.md} +0 -0
  111. /package/docs/{BasePage-explanation.md → v1/BasePage-explanation.md} +0 -0
  112. /package/docs/{LocatorSchema-explanation.md → v1/LocatorSchema-explanation.md} +0 -0
  113. /package/docs/{LocatorSchemaPath-explanation.md → v1/LocatorSchemaPath-explanation.md} +0 -0
  114. /package/docs/{PlaywrightReportLogger-explanation.md → v1/PlaywrightReportLogger-explanation.md} +0 -0
  115. /package/docs/{intro-to-using-pomwright.md → v1/intro-to-using-pomwright.md} +0 -0
  116. /package/docs/{sessionStorage-methods-explanation.md → v1/sessionStorage-methods-explanation.md} +0 -0
  117. /package/docs/{tips-folder-structure.md → v1/tips-folder-structure.md} +0 -0
package/dist/index.js CHANGED
@@ -22,19 +22,18 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  BaseApi: () => BaseApi,
24
24
  BasePage: () => BasePage,
25
+ BasePageV1toV2: () => BasePageV1toV2,
25
26
  GetByMethod: () => GetByMethod,
26
27
  GetLocatorBase: () => GetLocatorBase,
28
+ PageObject: () => PageObject,
27
29
  PlaywrightReportLogger: () => PlaywrightReportLogger,
28
- test: () => test3
30
+ SessionStorage: () => SessionStorage2,
31
+ createRegistryWithAccessors: () => createRegistryWithAccessors,
32
+ step: () => step,
33
+ test: () => test5
29
34
  });
30
35
  module.exports = __toCommonJS(index_exports);
31
36
 
32
- // src/basePage.ts
33
- var import_test3 = require("@playwright/test");
34
-
35
- // src/helpers/getLocatorBase.ts
36
- var import_test = require("@playwright/test");
37
-
38
37
  // src/helpers/locatorSchema.interface.ts
39
38
  var GetByMethod = /* @__PURE__ */ ((GetByMethod2) => {
40
39
  GetByMethod2["role"] = "role";
@@ -107,6 +106,414 @@ function getLocatorSchemaDummy() {
107
106
  return locatorSchemaDummy;
108
107
  }
109
108
 
109
+ // src/helpers/deprecationWarnings.ts
110
+ var warnedDeprecationsByScope = /* @__PURE__ */ new WeakMap();
111
+ var getWarningScope = (logger) => {
112
+ if (!logger) {
113
+ return globalThis;
114
+ }
115
+ const maybeSharedLogEntries = logger.sharedLogEntry;
116
+ if (Array.isArray(maybeSharedLogEntries)) {
117
+ return maybeSharedLogEntries;
118
+ }
119
+ return logger;
120
+ };
121
+ var warnDeprecationOncePerTest = (key, message, logger) => {
122
+ const warningScope = getWarningScope(logger);
123
+ const warnedDeprecations = warnedDeprecationsByScope.get(warningScope) ?? /* @__PURE__ */ new Set();
124
+ if (warnedDeprecations.has(key)) {
125
+ return;
126
+ }
127
+ warnedDeprecations.add(key);
128
+ warnedDeprecationsByScope.set(warningScope, warnedDeprecations);
129
+ logger?.warn(message);
130
+ };
131
+
132
+ // src/api/baseApi.ts
133
+ var BaseApi = class {
134
+ baseUrl;
135
+ apiName;
136
+ log;
137
+ request;
138
+ constructor(baseUrl, apiName, context, pwrl) {
139
+ this.baseUrl = baseUrl;
140
+ this.apiName = apiName;
141
+ this.log = pwrl.getNewChildLogger(apiName);
142
+ this.request = context;
143
+ const classDeprecationMessage = "[POMWright] BaseApi is depricated and will be removed in 2.0.0 with no replacement. If you need a base API class, you can use the v1 pomwright/src/api/baseApi.ts implementation for reference to implement your own.";
144
+ warnDeprecationOncePerTest(`${this.constructor.name}-class-deprecation`, classDeprecationMessage, this.log);
145
+ }
146
+ };
147
+
148
+ // src/basePage.ts
149
+ var import_test3 = require("@playwright/test");
150
+
151
+ // src/helpers/getLocatorBase.ts
152
+ var import_test = require("@playwright/test");
153
+
154
+ // srcV2/locators/utils.ts
155
+ var formatLocatorSchemaPathForError = (path) => {
156
+ const json = JSON.stringify(path);
157
+ return json.slice(1, -1);
158
+ };
159
+ var RUNTIME_WHITESPACE_REGEX = /[\s\u0085]/u;
160
+ var validateLocatorSchemaPath = (path) => {
161
+ if (!path) {
162
+ throw new Error("LocatorSchemaPath string cannot be empty");
163
+ }
164
+ if (RUNTIME_WHITESPACE_REGEX.test(path)) {
165
+ const escaped = formatLocatorSchemaPathForError(path);
166
+ throw new Error(`LocatorSchemaPath string cannot contain whitespace chars: ${escaped}`);
167
+ }
168
+ if (path.startsWith(".")) {
169
+ throw new Error(`LocatorSchemaPath string cannot start with a dot: ${path}`);
170
+ }
171
+ if (path.endsWith(".")) {
172
+ throw new Error(`LocatorSchemaPath string cannot end with a dot: ${path}`);
173
+ }
174
+ if (path.includes("..")) {
175
+ throw new Error(`LocatorSchemaPath string cannot contain consecutive dots: ${path}`);
176
+ }
177
+ };
178
+ var expandSchemaPath = (path) => {
179
+ validateLocatorSchemaPath(path);
180
+ const parts = path.split(".");
181
+ return parts.map((_part, index) => parts.slice(0, index + 1).join("."));
182
+ };
183
+ var cssEscape = (value) => {
184
+ return value.replace(/([\\"'#.:;,?*+<>{}[\\]()])/g, "\\$1");
185
+ };
186
+ var normalizeSteps = (steps) => steps ? steps.map((step2) => ({ ...step2 })) : [];
187
+ function normalizeIdValue(id) {
188
+ if (typeof id !== "string") {
189
+ return id;
190
+ }
191
+ if (id.startsWith("#")) {
192
+ return id.slice(1);
193
+ }
194
+ if (id.startsWith("id=")) {
195
+ return id.slice("id=".length);
196
+ }
197
+ return id;
198
+ }
199
+ var stringifyForLog = (value) => {
200
+ const seen = /* @__PURE__ */ new WeakSet();
201
+ return JSON.stringify(
202
+ value,
203
+ (_key, current) => {
204
+ if (typeof current === "object" && current !== null) {
205
+ if (seen.has(current)) {
206
+ return "[Circular]";
207
+ }
208
+ seen.add(current);
209
+ }
210
+ if (current instanceof RegExp) {
211
+ return { type: "RegExp", source: current.source, flags: current.flags };
212
+ }
213
+ return current;
214
+ },
215
+ 2
216
+ );
217
+ };
218
+ var applyIndexSelector = (locator, selector) => {
219
+ if (selector === void 0 || selector === null) {
220
+ return locator;
221
+ }
222
+ if (selector === "first") {
223
+ return locator.first();
224
+ }
225
+ if (selector === "last") {
226
+ return locator.last();
227
+ }
228
+ return locator.nth(selector);
229
+ };
230
+ var createLocator = (target, definition) => {
231
+ switch (definition.type) {
232
+ case "role":
233
+ return target.getByRole(definition.role, definition.options);
234
+ case "text":
235
+ return target.getByText(definition.text, definition.options);
236
+ case "label":
237
+ return target.getByLabel(definition.text, definition.options);
238
+ case "placeholder":
239
+ return target.getByPlaceholder(definition.text, definition.options);
240
+ case "altText":
241
+ return target.getByAltText(definition.text, definition.options);
242
+ case "title":
243
+ return target.getByTitle(definition.text, definition.options);
244
+ case "locator":
245
+ return target.locator(definition.selector, definition.options);
246
+ case "frameLocator":
247
+ return target.frameLocator(definition.selector);
248
+ case "testId":
249
+ return target.getByTestId(definition.testId);
250
+ case "id": {
251
+ if (typeof definition.id === "string") {
252
+ const normalized = normalizeIdValue(definition.id);
253
+ return target.locator(`#${cssEscape(normalized ?? "")}`);
254
+ }
255
+ const pattern = definition.id.source;
256
+ const safePattern = cssEscape(pattern);
257
+ return target.locator(`[id*="${safePattern}"]`);
258
+ }
259
+ default: {
260
+ const exhaustive = definition;
261
+ return exhaustive;
262
+ }
263
+ }
264
+ };
265
+ var cloneLocatorStrategyDefinition = (definition) => {
266
+ switch (definition.type) {
267
+ case "role":
268
+ return {
269
+ type: "role",
270
+ role: definition.role,
271
+ ...definition.options ? { options: { ...definition.options } } : {}
272
+ };
273
+ case "text":
274
+ return {
275
+ type: "text",
276
+ text: definition.text,
277
+ ...definition.options ? { options: { ...definition.options } } : {}
278
+ };
279
+ case "label":
280
+ return {
281
+ type: "label",
282
+ text: definition.text,
283
+ ...definition.options ? { options: { ...definition.options } } : {}
284
+ };
285
+ case "placeholder":
286
+ return {
287
+ type: "placeholder",
288
+ text: definition.text,
289
+ ...definition.options ? { options: { ...definition.options } } : {}
290
+ };
291
+ case "altText":
292
+ return {
293
+ type: "altText",
294
+ text: definition.text,
295
+ ...definition.options ? { options: { ...definition.options } } : {}
296
+ };
297
+ case "title":
298
+ return {
299
+ type: "title",
300
+ text: definition.text,
301
+ ...definition.options ? { options: { ...definition.options } } : {}
302
+ };
303
+ case "locator":
304
+ return {
305
+ type: "locator",
306
+ selector: definition.selector,
307
+ ...definition.options ? { options: { ...definition.options } } : {}
308
+ };
309
+ case "frameLocator":
310
+ return { type: "frameLocator", selector: definition.selector };
311
+ case "testId":
312
+ return { type: "testId", testId: definition.testId };
313
+ case "id":
314
+ return { type: "id", id: definition.id };
315
+ default: {
316
+ const exhaustive = definition;
317
+ return exhaustive;
318
+ }
319
+ }
320
+ };
321
+ var applyDefinitionPatch = (seed, patch) => {
322
+ const base2 = cloneLocatorStrategyDefinition(seed);
323
+ switch (patch.type) {
324
+ case "locator": {
325
+ const selector = patch.selector !== void 0 ? patch.selector : base2.selector;
326
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
327
+ return { type: "locator", selector, ...options ? { options } : {} };
328
+ }
329
+ case "role": {
330
+ const role = patch.role ?? base2.role;
331
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
332
+ return { type: "role", role, ...options ? { options } : {} };
333
+ }
334
+ case "text": {
335
+ const text = patch.text ?? base2.text;
336
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
337
+ return { type: "text", text, ...options ? { options } : {} };
338
+ }
339
+ case "label": {
340
+ const text = patch.text ?? base2.text;
341
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
342
+ return { type: "label", text, ...options ? { options } : {} };
343
+ }
344
+ case "placeholder": {
345
+ const text = patch.text ?? base2.text;
346
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
347
+ return { type: "placeholder", text, ...options ? { options } : {} };
348
+ }
349
+ case "altText": {
350
+ const text = patch.text ?? base2.text;
351
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
352
+ return { type: "altText", text, ...options ? { options } : {} };
353
+ }
354
+ case "title": {
355
+ const text = patch.text ?? base2.text;
356
+ const options = patch.options || base2.options ? { ...base2.options, ...patch.options } : void 0;
357
+ return { type: "title", text, ...options ? { options } : {} };
358
+ }
359
+ case "frameLocator": {
360
+ const selector = patch.selector !== void 0 ? patch.selector : base2.selector;
361
+ return { type: "frameLocator", selector };
362
+ }
363
+ case "testId": {
364
+ const testId = patch.testId !== void 0 ? patch.testId : base2.testId;
365
+ return { type: "testId", testId };
366
+ }
367
+ case "id": {
368
+ const id = patch.id !== void 0 ? normalizeIdValue(patch.id) ?? base2.id : base2.id;
369
+ return { type: "id", id };
370
+ }
371
+ default: {
372
+ const exhaustive = patch;
373
+ return exhaustive;
374
+ }
375
+ }
376
+ };
377
+ var isFrameLocatorDefinition = (definition) => definition.type === "frameLocator";
378
+ var isLocatorInstance = (value) => {
379
+ return !!value && typeof value === "object" && typeof value.filter === "function";
380
+ };
381
+
382
+ // srcV2/locators/v1SchemaTranslator.ts
383
+ var getRegistryLookup = (registry) => registry;
384
+ var logMissingDefinition = (path, field) => {
385
+ console.warn(
386
+ `[POMWright] Skipping v2 translation for "${path}" because "${field}" is missing. Rewrite this locator in defineLocators() using the v2 registry.`
387
+ );
388
+ };
389
+ var logLocatorInstanceWarning = (path) => {
390
+ console.warn(
391
+ `[POMWright] Skipping v2 translation for "${path}" because v1 LocatorSchema.locator is a Locator instance. Rewrite this path in defineLocators() to avoid runtime gaps during migration.`
392
+ );
393
+ };
394
+ var addV1SchemaToV2Registry = (registry, locatorSchema) => {
395
+ const path = locatorSchema.locatorSchemaPath;
396
+ validateLocatorSchemaPath(path);
397
+ const registryWithLookup = getRegistryLookup(registry);
398
+ const existing = registryWithLookup.getIfExists?.(path);
399
+ if (existing) {
400
+ return;
401
+ }
402
+ console.info(
403
+ `[POMWright] LocatorSchemaPath "${path}" is not registered in the v2 registry. Translating and adding v1 schema to v2 Locator Registry; update this path to use registry.add in defineLocators().`
404
+ );
405
+ const registration = registry.add(path);
406
+ if (!registration) {
407
+ return;
408
+ }
409
+ let postDefinition = null;
410
+ switch (locatorSchema.locatorMethod) {
411
+ case "role" /* role */: {
412
+ if (!locatorSchema.role) {
413
+ logMissingDefinition(path, "role");
414
+ return;
415
+ }
416
+ postDefinition = registration.getByRole(locatorSchema.role, locatorSchema.roleOptions);
417
+ break;
418
+ }
419
+ case "text" /* text */: {
420
+ if (!locatorSchema.text) {
421
+ logMissingDefinition(path, "text");
422
+ return;
423
+ }
424
+ postDefinition = registration.getByText(locatorSchema.text, locatorSchema.textOptions);
425
+ break;
426
+ }
427
+ case "label" /* label */: {
428
+ if (!locatorSchema.label) {
429
+ logMissingDefinition(path, "label");
430
+ return;
431
+ }
432
+ postDefinition = registration.getByLabel(locatorSchema.label, locatorSchema.labelOptions);
433
+ break;
434
+ }
435
+ case "placeholder" /* placeholder */: {
436
+ if (!locatorSchema.placeholder) {
437
+ logMissingDefinition(path, "placeholder");
438
+ return;
439
+ }
440
+ postDefinition = registration.getByPlaceholder(locatorSchema.placeholder, locatorSchema.placeholderOptions);
441
+ break;
442
+ }
443
+ case "altText" /* altText */: {
444
+ if (!locatorSchema.altText) {
445
+ logMissingDefinition(path, "altText");
446
+ return;
447
+ }
448
+ postDefinition = registration.getByAltText(locatorSchema.altText, locatorSchema.altTextOptions);
449
+ break;
450
+ }
451
+ case "title" /* title */: {
452
+ if (!locatorSchema.title) {
453
+ logMissingDefinition(path, "title");
454
+ return;
455
+ }
456
+ postDefinition = registration.getByTitle(locatorSchema.title, locatorSchema.titleOptions);
457
+ break;
458
+ }
459
+ case "locator" /* locator */: {
460
+ if (!locatorSchema.locator) {
461
+ logMissingDefinition(path, "locator");
462
+ return;
463
+ }
464
+ if (isLocatorInstance(locatorSchema.locator)) {
465
+ logLocatorInstanceWarning(path);
466
+ return;
467
+ }
468
+ postDefinition = registration.locator(locatorSchema.locator, locatorSchema.locatorOptions);
469
+ break;
470
+ }
471
+ case "frameLocator" /* frameLocator */: {
472
+ if (!locatorSchema.frameLocator) {
473
+ logMissingDefinition(path, "frameLocator");
474
+ return;
475
+ }
476
+ postDefinition = registration.frameLocator(locatorSchema.frameLocator);
477
+ break;
478
+ }
479
+ case "testId" /* testId */: {
480
+ if (!locatorSchema.testId) {
481
+ logMissingDefinition(path, "testId");
482
+ return;
483
+ }
484
+ postDefinition = registration.getByTestId(locatorSchema.testId);
485
+ break;
486
+ }
487
+ case "dataCy" /* dataCy */: {
488
+ if (!locatorSchema.dataCy) {
489
+ logMissingDefinition(path, "dataCy");
490
+ return;
491
+ }
492
+ postDefinition = registration.locator(`[data-cy="${locatorSchema.dataCy}"]`);
493
+ break;
494
+ }
495
+ case "id" /* id */: {
496
+ if (!locatorSchema.id) {
497
+ logMissingDefinition(path, "id");
498
+ return;
499
+ }
500
+ postDefinition = registration.getById(locatorSchema.id);
501
+ break;
502
+ }
503
+ default: {
504
+ const exhaustive = locatorSchema.locatorMethod;
505
+ return exhaustive;
506
+ }
507
+ }
508
+ if (!postDefinition) {
509
+ return;
510
+ }
511
+ if (locatorSchema.filter && locatorSchema.locatorMethod !== "frameLocator" /* frameLocator */) {
512
+ const filter = locatorSchema.filter;
513
+ postDefinition.filter(filter);
514
+ }
515
+ };
516
+
110
517
  // src/helpers/getBy.locator.ts
111
518
  var GetBy = class {
112
519
  constructor(page, pwrl) {
@@ -271,7 +678,6 @@ var GetBy = class {
271
678
  // src/helpers/getLocatorBase.ts
272
679
  var REQUIRED_PROPERTIES_FOR_LOCATOR_SCHEMA_WITH_METHODS = [
273
680
  "update",
274
- "updates",
275
681
  "addFilter",
276
682
  "getNestedLocator",
277
683
  "getLocator",
@@ -378,41 +784,6 @@ var GetLocatorBase = class {
378
784
  schemasMap.set(subPath, updatedSchema);
379
785
  }
380
786
  }
381
- /**
382
- * applyUpdate:
383
- * Applies updates to a single schema within the schemasMap.
384
- */
385
- applyUpdate(schemasMap, locatorSchemaPath, updateData) {
386
- const schema = schemasMap.get(locatorSchemaPath);
387
- if (schema) {
388
- const updatedSchema = this.deepMerge(schema, updateData);
389
- if (this.isLocatorSchemaWithMethods(schema)) {
390
- Object.assign(schema, updatedSchema);
391
- } else {
392
- throw new Error("Invalid LocatorSchema object provided for update method.");
393
- }
394
- }
395
- }
396
- /**
397
- * applyUpdates:
398
- * Applies multiple updates to multiple schemas in the chain, identified by their path indexes.
399
- */
400
- applyUpdates(schemasMap, pathIndexPairs, updatesData) {
401
- for (const [index, updateAtIndex] of Object.entries(updatesData)) {
402
- const path = pathIndexPairs[Number.parseInt(index)]?.path;
403
- if (path && updateAtIndex) {
404
- const schema = schemasMap.get(path);
405
- if (schema) {
406
- const updatedSchema = this.deepMerge(schema, updateAtIndex);
407
- if (this.isLocatorSchemaWithMethods(schema)) {
408
- Object.assign(schema, updatedSchema);
409
- } else {
410
- schemasMap.set(path, updatedSchema);
411
- }
412
- }
413
- }
414
- }
415
- }
416
787
  /**
417
788
  * createLocatorSchema:
418
789
  * Creates a fresh LocatorSchema object by merging provided schemaDetails with a required locatorSchemaPath.
@@ -443,6 +814,10 @@ Attempted to Add Schema: ${JSON.stringify(newLocatorSchema, null, 2)}`
443
814
  );
444
815
  }
445
816
  this.locatorSchemas.set(locatorSchemaPath, () => newLocatorSchema);
817
+ const v2Registry = this.pageObjectClass.locatorRegistry;
818
+ if (v2Registry) {
819
+ addV1SchemaToV2Registry(v2Registry, newLocatorSchema);
820
+ }
446
821
  }
447
822
  /**
448
823
  * safeGetLocatorSchema:
@@ -454,7 +829,7 @@ Attempted to Add Schema: ${JSON.stringify(newLocatorSchema, null, 2)}`
454
829
  /**
455
830
  * extractPathsFromSchema:
456
831
  * Splits a path into incremental sub-paths and associates them with optional indices.
457
- * Used by updates and getNestedLocator methods.
832
+ * Used by getNestedLocator methods.
458
833
  */
459
834
  extractPathsFromSchema = (paths, indices = {}) => {
460
835
  const schemaParts = paths.split(".");
@@ -636,27 +1011,14 @@ Attempted to Add Schema: ${JSON.stringify(newLocatorSchema, null, 2)}`
636
1011
  Note: "iFrame locators evaluation not implemented"
637
1012
  });
638
1013
  } else {
639
- const elementsData = await this.evaluateAndGetAttributes(currentLocator);
1014
+ const elementCount = await currentLocator.count();
640
1015
  resultsArray.push({
641
1016
  currentLocatorString: `${currentLocator}`,
642
- resolved: elementsData.length > 0,
643
- elementCount: elementsData.length,
644
- elementsResolvedTo: elementsData
1017
+ resolved: elementCount > 0,
1018
+ elementCount
645
1019
  });
646
1020
  }
647
1021
  };
648
- /**
649
- * evaluateAndGetAttributes:
650
- * Extracts tagName and attributes from all elements matched by the locator for debugging purposes.
651
- */
652
- evaluateAndGetAttributes = async (pwLocator) => {
653
- return await pwLocator.evaluateAll(
654
- (objects) => objects.map((el) => {
655
- const elementAttributes = el.hasAttributes() ? Object.fromEntries(Array.from(el.attributes).map(({ name, value }) => [name, value])) : {};
656
- return { tagName: el.tagName, attributes: elementAttributes };
657
- })
658
- );
659
- };
660
1022
  };
661
1023
  var WithMethodsClass = class extends GetLocatorBase {
662
1024
  constructor(pageObjectClass, log, locatorSubstring, schemasMap) {
@@ -668,30 +1030,18 @@ var WithMethodsClass = class extends GetLocatorBase {
668
1030
  locatorSchemaPath;
669
1031
  /**
670
1032
  * init:
671
- * Assigns the locatorSchemaPath and binds methods (update, updates, addFilter, getNestedLocator, getLocator)
1033
+ * Assigns the locatorSchemaPath and binds methods (update, addFilter, getNestedLocator, getLocator)
672
1034
  * directly on the locatorSchemaCopy. Returns the modified copy, now fully chainable and type-safe.
673
1035
  */
674
1036
  init(locatorSchemaPath, locatorSchemaCopy) {
675
1037
  this.locatorSchemaPath = locatorSchemaPath;
676
1038
  const self = this;
677
- locatorSchemaCopy.update = function(a, b) {
1039
+ locatorSchemaCopy.update = function(subPath, updates) {
678
1040
  const fullPath = this.locatorSchemaPath;
679
- if (b === void 0) {
680
- const updates = a;
681
- self.applyUpdate(self.schemasMap, self.locatorSchemaPath, updates);
682
- } else {
683
- const subPath = a;
684
- const updates = b;
685
- if (!(subPath === fullPath || fullPath.startsWith(`${subPath}.`))) {
686
- throw new Error(`Invalid sub-path: '${subPath}' is not a valid sub-path of '${fullPath}'.`);
687
- }
688
- self.applyUpdateToSubPath(self.schemasMap, subPath, updates);
1041
+ if (!(subPath === fullPath || fullPath.startsWith(`${subPath}.`))) {
1042
+ throw new Error(`Invalid sub-path: '${subPath}' is not a valid sub-path of '${fullPath}'.`);
689
1043
  }
690
- return this;
691
- };
692
- locatorSchemaCopy.updates = function(indexedUpdates) {
693
- const pathIndexPairs = self.extractPathsFromSchema(self.locatorSchemaPath);
694
- self.applyUpdates(self.schemasMap, pathIndexPairs, indexedUpdates);
1044
+ self.applyUpdateToSubPath(self.schemasMap, subPath, updates);
695
1045
  return this;
696
1046
  };
697
1047
  locatorSchemaCopy.addFilter = function(subPath, filterData) {
@@ -723,46 +1073,33 @@ ${allowedPaths.join(",\n")}`
723
1073
  {}
724
1074
  );
725
1075
  }
726
- const keys = Object.keys(arg);
727
- const isNumberKey = keys.every((key) => /^\d+$/.test(key));
728
1076
  const numericIndices = {};
729
- if (isNumberKey) {
730
- for (const [key, value] of Object.entries(arg)) {
731
- const index = Number(key);
732
- if (typeof value === "number" && value >= 0) {
733
- numericIndices[index] = value;
734
- } else if (value !== null) {
735
- throw new Error(`Invalid index value at key '${key}': Expected a positive number or null.`);
736
- }
737
- }
738
- } else {
739
- const pathIndexPairs = self.extractPathsFromSchema(self.locatorSchemaPath);
740
- const pathToIndexMap = new Map(pathIndexPairs.map((pair, idx) => [pair.path, idx]));
741
- for (const [subPath, value] of Object.entries(arg)) {
742
- if (!self.schemasMap.has(subPath)) {
743
- const validPaths = Array.from(self.schemasMap.keys());
744
- throw new Error(
745
- `Invalid sub-path '${subPath}' in getNestedLocator. Allowed sub-paths are:
1077
+ const pathIndexPairs = self.extractPathsFromSchema(self.locatorSchemaPath);
1078
+ const pathToIndexMap = new Map(pathIndexPairs.map((pair, idx) => [pair.path, idx]));
1079
+ for (const [subPath, value] of Object.entries(arg)) {
1080
+ if (!self.schemasMap.has(subPath)) {
1081
+ const validPaths = Array.from(self.schemasMap.keys());
1082
+ throw new Error(
1083
+ `Invalid sub-path '${subPath}' in getNestedLocator. Allowed sub-paths are:
746
1084
  ${validPaths.join(",\n")}`
747
- );
748
- }
749
- if (!pathToIndexMap.has(subPath)) {
750
- const validPaths = pathIndexPairs.map((p) => p.path).filter((path) => self.schemasMap.has(path));
751
- throw new Error(
752
- `Invalid sub-path '${subPath}' in getNestedLocator. Allowed sub-paths are:
1085
+ );
1086
+ }
1087
+ if (!pathToIndexMap.has(subPath)) {
1088
+ const validPaths = pathIndexPairs.map((p) => p.path).filter((path) => self.schemasMap.has(path));
1089
+ throw new Error(
1090
+ `Invalid sub-path '${subPath}' in getNestedLocator. Allowed sub-paths are:
753
1091
  ${validPaths.join(",\n")}`
754
- );
755
- }
756
- const numericIndex = pathToIndexMap.get(subPath);
757
- if (numericIndex === void 0) {
758
- throw new Error(`Sub-path '${subPath}' not found in pathToIndexMap.`);
759
- }
760
- if (value !== null && (typeof value !== "number" || value < 0)) {
761
- throw new Error(`Invalid index for sub-path '${subPath}': Expected a positive number or null.`);
762
- }
763
- if (value !== null) {
764
- numericIndices[numericIndex] = value;
765
- }
1092
+ );
1093
+ }
1094
+ const numericIndex = pathToIndexMap.get(subPath);
1095
+ if (numericIndex === void 0) {
1096
+ throw new Error(`Sub-path '${subPath}' not found in pathToIndexMap.`);
1097
+ }
1098
+ if (value !== null && (typeof value !== "number" || value < 0)) {
1099
+ throw new Error(`Invalid index for sub-path '${subPath}': Expected a positive number or null.`);
1100
+ }
1101
+ if (value !== null) {
1102
+ numericIndices[numericIndex] = value;
766
1103
  }
767
1104
  }
768
1105
  return await self.buildNestedLocator(
@@ -987,6 +1324,8 @@ var BasePage = class {
987
1324
  this.fullUrl = this.constructFullUrl(baseUrl, urlPath);
988
1325
  this.pocName = pocName;
989
1326
  this.log = pwrl.getNewChildLogger(pocName);
1327
+ const classDeprecationMessage = "[POMWright] BasePage is depricated and will be removed in 2.0.0. Migrate to v2, preferably directly to PageObject or through the transitional bridge BasePageV1toV2 and then to PageObject.";
1328
+ warnDeprecationOncePerTest(`${this.constructor.name}-class-deprecation`, classDeprecationMessage, this.log);
990
1329
  this.locators = new GetLocatorBase(
991
1330
  this,
992
1331
  this.log.getNewChildLogger("GetLocator"),
@@ -1107,72 +1446,1828 @@ var WithSubPathValidation = class extends GetLocatorBase {
1107
1446
  }
1108
1447
  };
1109
1448
 
1110
- // src/fixture/base.fixtures.ts
1449
+ // src/basePageV1toV2.ts
1111
1450
  var import_test4 = require("@playwright/test");
1112
1451
 
1113
- // src/helpers/playwrightReportLogger.ts
1114
- var PlaywrightReportLogger = class _PlaywrightReportLogger {
1115
- // Initializes the logger with shared log level, log entries, and a context name.
1116
- constructor(sharedLogLevel, sharedLogEntry, contextName) {
1117
- this.sharedLogLevel = sharedLogLevel;
1118
- this.sharedLogEntry = sharedLogEntry;
1119
- this.contextName = contextName;
1452
+ // srcV2/locators/locatorUpdateBuilder.ts
1453
+ var parseUpdateArguments = (primaryOrOptions, options, optionsProvided) => {
1454
+ let primary;
1455
+ let parsedOptions;
1456
+ let hasOptions = optionsProvided ?? false;
1457
+ if (options !== void 0) {
1458
+ parsedOptions = options;
1459
+ hasOptions = true;
1120
1460
  }
1121
- contextName;
1122
- logLevels = ["debug", "info", "warn", "error"];
1123
- /**
1124
- * Creates a child logger with a new contextual name, sharing the same log level and log entries with the parent logger.
1125
- *
1126
- * The root loggers log "level" is referenced by all child loggers and their child loggers and so on...
1127
- * Changing the log "level" of one, will change it for all.
1128
- */
1129
- getNewChildLogger(prefix) {
1130
- return new _PlaywrightReportLogger(this.sharedLogLevel, this.sharedLogEntry, `${this.contextName} -> ${prefix}`);
1461
+ if (primaryOrOptions !== void 0) {
1462
+ const treatAsOptions = !hasOptions && options === void 0 && typeof primaryOrOptions === "object" && !(primaryOrOptions instanceof RegExp);
1463
+ if (treatAsOptions) {
1464
+ parsedOptions = primaryOrOptions;
1465
+ hasOptions = true;
1466
+ } else {
1467
+ primary = primaryOrOptions;
1468
+ }
1131
1469
  }
1132
- /**
1133
- * Logs a message with the specified log level, prefix, and additional arguments if the current log level permits.
1134
- */
1135
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1136
- log(level, message, ...args) {
1137
- const logLevelIndex = this.logLevels.indexOf(level);
1138
- if (logLevelIndex < this.getCurrentLogLevelIndex()) {
1139
- return;
1470
+ return { primary, options: parsedOptions, hasOptions };
1471
+ };
1472
+ var mergeOptions = (currentOptions, updates) => {
1473
+ if (updates && "options" in updates) {
1474
+ const updateOptions = updates.options;
1475
+ if (updateOptions && typeof updateOptions === "object") {
1476
+ return {
1477
+ ...typeof currentOptions === "object" && currentOptions !== null ? currentOptions : {},
1478
+ ...updateOptions
1479
+ };
1140
1480
  }
1141
- this.sharedLogEntry.push({
1142
- timestamp: /* @__PURE__ */ new Date(),
1143
- logLevel: level,
1144
- prefix: this.contextName,
1145
- message: `${message}
1146
-
1147
- ${args.join("\n\n")}`
1148
- });
1481
+ return updateOptions;
1149
1482
  }
1150
- /**
1151
- * Logs a debug-level message with the specified message and arguments.
1152
- */
1153
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1154
- debug(message, ...args) {
1155
- this.log("debug", message, ...args);
1483
+ return currentOptions;
1484
+ };
1485
+ var mergeLocatorDefinition = (current, updates, path, preferredSource, baseline) => {
1486
+ if (!updates || typeof updates !== "object" || !("type" in updates)) {
1487
+ throw new Error(`Locator update for "${path}" requires a "type" property.`);
1156
1488
  }
1157
- /**
1158
- * Logs a info-level message with the specified message and arguments.
1159
- */
1160
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1161
- info(message, ...args) {
1162
- this.log("info", message, ...args);
1489
+ const source = (targetType) => {
1490
+ if (current.type === targetType) {
1491
+ return current;
1492
+ }
1493
+ if (preferredSource?.type === targetType) {
1494
+ return preferredSource;
1495
+ }
1496
+ if (baseline?.type === targetType) {
1497
+ return baseline;
1498
+ }
1499
+ return void 0;
1500
+ };
1501
+ switch (updates.type) {
1502
+ case "role": {
1503
+ const roleSource = source("role");
1504
+ const role = updates.role ?? roleSource?.role;
1505
+ if (role === void 0) {
1506
+ throw new Error(`Locator update for "${path}" of type "role" requires a "role" value.`);
1507
+ }
1508
+ const options = mergeOptions(roleSource?.options, updates);
1509
+ return options !== void 0 ? { type: "role", role, options } : { type: "role", role };
1510
+ }
1511
+ case "text": {
1512
+ const textSource = source("text");
1513
+ const text = updates.text ?? textSource?.text;
1514
+ if (text === void 0) {
1515
+ throw new Error(`Locator update for "${path}" of type "text" requires a "text" value.`);
1516
+ }
1517
+ const options = mergeOptions(textSource?.options, updates);
1518
+ return options !== void 0 ? { type: "text", text, options } : { type: "text", text };
1519
+ }
1520
+ case "label": {
1521
+ const textSource = source("label");
1522
+ const text = updates.text ?? textSource?.text;
1523
+ if (text === void 0) {
1524
+ throw new Error(`Locator update for "${path}" of type "label" requires a "text" value.`);
1525
+ }
1526
+ const options = mergeOptions(textSource?.options, updates);
1527
+ return options !== void 0 ? { type: "label", text, options } : { type: "label", text };
1528
+ }
1529
+ case "placeholder": {
1530
+ const textSource = source("placeholder");
1531
+ const text = updates.text ?? textSource?.text;
1532
+ if (text === void 0) {
1533
+ throw new Error(`Locator update for "${path}" of type "placeholder" requires a "text" value.`);
1534
+ }
1535
+ const options = mergeOptions(textSource?.options, updates);
1536
+ return options !== void 0 ? { type: "placeholder", text, options } : { type: "placeholder", text };
1537
+ }
1538
+ case "altText": {
1539
+ const textSource = source("altText");
1540
+ const text = updates.text ?? textSource?.text;
1541
+ if (text === void 0) {
1542
+ throw new Error(`Locator update for "${path}" of type "altText" requires a "text" value.`);
1543
+ }
1544
+ const options = mergeOptions(textSource?.options, updates);
1545
+ return options !== void 0 ? { type: "altText", text, options } : { type: "altText", text };
1546
+ }
1547
+ case "title": {
1548
+ const textSource = source("title");
1549
+ const text = updates.text ?? textSource?.text;
1550
+ if (text === void 0) {
1551
+ throw new Error(`Locator update for "${path}" of type "title" requires a "text" value.`);
1552
+ }
1553
+ const options = mergeOptions(textSource?.options, updates);
1554
+ return options !== void 0 ? { type: "title", text, options } : { type: "title", text };
1555
+ }
1556
+ case "locator": {
1557
+ const selectorSource = source("locator");
1558
+ const selector = updates.selector ?? selectorSource?.selector;
1559
+ if (selector === void 0) {
1560
+ throw new Error(`Locator update for "${path}" of type "locator" requires a "selector" value.`);
1561
+ }
1562
+ const options = mergeOptions(selectorSource?.options, updates);
1563
+ return options !== void 0 ? { type: "locator", selector, options } : { type: "locator", selector };
1564
+ }
1565
+ case "frameLocator": {
1566
+ const selectorSource = source("frameLocator");
1567
+ const selector = updates.selector ?? selectorSource?.selector;
1568
+ if (selector === void 0) {
1569
+ throw new Error(`Locator update for "${path}" of type "frameLocator" requires a "selector" value.`);
1570
+ }
1571
+ return { type: "frameLocator", selector };
1572
+ }
1573
+ case "testId": {
1574
+ const testIdSource = source("testId");
1575
+ const testId = updates.testId ?? testIdSource?.testId;
1576
+ if (testId === void 0) {
1577
+ throw new Error(`Locator update for "${path}" of type "testId" requires a "testId" value.`);
1578
+ }
1579
+ return { type: "testId", testId };
1580
+ }
1581
+ case "id": {
1582
+ const idSource = source("id");
1583
+ const rawId = updates.id ?? idSource?.id;
1584
+ const id = normalizeIdValue(rawId);
1585
+ if (id === void 0) {
1586
+ throw new Error(`Locator update for "${path}" of type "id" requires an "id" value.`);
1587
+ }
1588
+ return { type: "id", id };
1589
+ }
1590
+ default: {
1591
+ const exhaustive = updates;
1592
+ return exhaustive;
1593
+ }
1163
1594
  }
1164
- /**
1165
- * Logs a warn-level message with the specified message and arguments.
1166
- */
1167
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1168
- warn(message, ...args) {
1169
- this.log("warn", message, ...args);
1595
+ };
1596
+ var buildReplacementDefinition = (updates, path) => {
1597
+ if (!updates || typeof updates !== "object" || !("type" in updates)) {
1598
+ throw new Error(`Locator replace for "${path}" requires a "type" property.`);
1170
1599
  }
1171
- /**
1172
- * Logs a error-level message with the specified message and arguments.
1173
- */
1174
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1175
- error(message, ...args) {
1600
+ switch (updates.type) {
1601
+ case "role": {
1602
+ const { role, options } = updates;
1603
+ if (role === void 0) {
1604
+ throw new Error(`Locator replace for "${path}" of type "role" requires a "role" value.`);
1605
+ }
1606
+ return options !== void 0 ? { type: "role", role, options } : { type: "role", role };
1607
+ }
1608
+ case "text": {
1609
+ const { text, options } = updates;
1610
+ if (text === void 0) {
1611
+ throw new Error(`Locator replace for "${path}" of type "text" requires a "text" value.`);
1612
+ }
1613
+ return options !== void 0 ? { type: "text", text, options } : { type: "text", text };
1614
+ }
1615
+ case "label": {
1616
+ const { text, options } = updates;
1617
+ if (text === void 0) {
1618
+ throw new Error(`Locator replace for "${path}" of type "label" requires a "text" value.`);
1619
+ }
1620
+ return options !== void 0 ? { type: "label", text, options } : { type: "label", text };
1621
+ }
1622
+ case "placeholder": {
1623
+ const { text, options } = updates;
1624
+ if (text === void 0) {
1625
+ throw new Error(`Locator replace for "${path}" of type "placeholder" requires a "text" value.`);
1626
+ }
1627
+ return options !== void 0 ? { type: "placeholder", text, options } : { type: "placeholder", text };
1628
+ }
1629
+ case "altText": {
1630
+ const { text, options } = updates;
1631
+ if (text === void 0) {
1632
+ throw new Error(`Locator replace for "${path}" of type "altText" requires a "text" value.`);
1633
+ }
1634
+ return options !== void 0 ? { type: "altText", text, options } : { type: "altText", text };
1635
+ }
1636
+ case "title": {
1637
+ const { text, options } = updates;
1638
+ if (text === void 0) {
1639
+ throw new Error(`Locator replace for "${path}" of type "title" requires a "text" value.`);
1640
+ }
1641
+ return options !== void 0 ? { type: "title", text, options } : { type: "title", text };
1642
+ }
1643
+ case "locator": {
1644
+ const { selector, options } = updates;
1645
+ if (selector === void 0) {
1646
+ throw new Error(`Locator replace for "${path}" of type "locator" requires a "selector" value.`);
1647
+ }
1648
+ return options !== void 0 ? { type: "locator", selector, options } : { type: "locator", selector };
1649
+ }
1650
+ case "frameLocator": {
1651
+ const { selector } = updates;
1652
+ if (selector === void 0) {
1653
+ throw new Error(`Locator replace for "${path}" of type "frameLocator" requires a "selector" value.`);
1654
+ }
1655
+ return { type: "frameLocator", selector };
1656
+ }
1657
+ case "testId": {
1658
+ const { testId } = updates;
1659
+ if (testId === void 0) {
1660
+ throw new Error(`Locator replace for "${path}" of type "testId" requires a "testId" value.`);
1661
+ }
1662
+ return { type: "testId", testId };
1663
+ }
1664
+ case "id": {
1665
+ const rawId = updates.id;
1666
+ const id = normalizeIdValue(rawId);
1667
+ if (id === void 0) {
1668
+ throw new Error(`Locator replace for "${path}" of type "id" requires an "id" value.`);
1669
+ }
1670
+ return { type: "id", id };
1671
+ }
1672
+ default: {
1673
+ const exhaustive = updates;
1674
+ return exhaustive;
1675
+ }
1676
+ }
1677
+ };
1678
+ var LocatorUpdateBuilder = class {
1679
+ constructor(parent, subPath, mode = "update") {
1680
+ this.parent = parent;
1681
+ this.subPath = subPath;
1682
+ this.mode = mode;
1683
+ }
1684
+ /**
1685
+ * Defines or patches a `getByRole` locator strategy for the target subpath. In `update` mode the
1686
+ * `role` and `options` arguments are optional (PATCH semantics); in `replace` mode they follow
1687
+ * Playwright requirements (POST semantics) and `role` is required.
1688
+ *
1689
+ * @example
1690
+ * ```ts
1691
+ * getLocatorSchema("form.button")
1692
+ * .update("form.button")
1693
+ * .getByRole({ name: "Save" })
1694
+ * .getNestedLocator();
1695
+ * ```
1696
+ */
1697
+ getByRole(...args) {
1698
+ const [roleOrOptions, options] = args;
1699
+ const {
1700
+ primary: role,
1701
+ options: parsedOptions,
1702
+ hasOptions
1703
+ } = parseUpdateArguments(
1704
+ roleOrOptions,
1705
+ options,
1706
+ args.length >= 2
1707
+ );
1708
+ const definition = {
1709
+ type: "role",
1710
+ ...role !== void 0 ? { role } : {},
1711
+ ...hasOptions ? { options: parsedOptions } : {}
1712
+ };
1713
+ return this.commit(definition);
1714
+ }
1715
+ /**
1716
+ * Defines or patches a `getByText` locator strategy for the target subpath. In `update` mode,
1717
+ * text/options are optional; in `replace` mode text is required.
1718
+ *
1719
+ * @example
1720
+ * ```ts
1721
+ * getLocatorSchema("banner.message")
1722
+ * .replace("banner.message")
1723
+ * .getByText(/Updated/, { exact: false })
1724
+ * .getNestedLocator();
1725
+ * ```
1726
+ */
1727
+ getByText(...args) {
1728
+ const [textOrOptions, options] = args;
1729
+ const {
1730
+ primary: text,
1731
+ options: parsedOptions,
1732
+ hasOptions
1733
+ } = parseUpdateArguments(
1734
+ textOrOptions,
1735
+ options,
1736
+ args.length >= 2
1737
+ );
1738
+ const definition = {
1739
+ type: "text",
1740
+ ...text !== void 0 ? { text } : {},
1741
+ ...hasOptions ? { options: parsedOptions } : {}
1742
+ };
1743
+ return this.commit(definition);
1744
+ }
1745
+ /**
1746
+ * Defines or patches a `getByLabel` locator strategy for the target subpath. In `update` mode the
1747
+ * label text/options are optional; in `replace` mode text is required.
1748
+ *
1749
+ * @example
1750
+ * ```ts
1751
+ * getLocatorSchema("form.email").update("form.email").getByLabel({ exact: true }).getNestedLocator();
1752
+ * ```
1753
+ */
1754
+ getByLabel(...args) {
1755
+ const [textOrOptions, options] = args;
1756
+ const {
1757
+ primary: text,
1758
+ options: parsedOptions,
1759
+ hasOptions
1760
+ } = parseUpdateArguments(
1761
+ textOrOptions,
1762
+ options,
1763
+ args.length >= 2
1764
+ );
1765
+ const definition = {
1766
+ type: "label",
1767
+ ...text !== void 0 ? { text } : {},
1768
+ ...hasOptions ? { options: parsedOptions } : {}
1769
+ };
1770
+ return this.commit(definition);
1771
+ }
1772
+ /**
1773
+ * Defines or patches a `getByPlaceholder` locator strategy for the target subpath. In `update`
1774
+ * mode text/options are optional; in `replace` mode text is required.
1775
+ *
1776
+ * @example
1777
+ * ```ts
1778
+ * getLocatorSchema("form.search").update("form.search").getByPlaceholder({ exact: true }).getNestedLocator();
1779
+ * ```
1780
+ */
1781
+ getByPlaceholder(...args) {
1782
+ const [textOrOptions, options] = args;
1783
+ const {
1784
+ primary: text,
1785
+ options: parsedOptions,
1786
+ hasOptions
1787
+ } = parseUpdateArguments(
1788
+ textOrOptions,
1789
+ options,
1790
+ args.length >= 2
1791
+ );
1792
+ const definition = {
1793
+ type: "placeholder",
1794
+ ...text !== void 0 ? { text } : {},
1795
+ ...hasOptions ? { options: parsedOptions } : {}
1796
+ };
1797
+ return this.commit(definition);
1798
+ }
1799
+ /**
1800
+ * Defines or patches a `getByAltText` locator strategy for the target subpath. In `update` mode
1801
+ * text/options are optional; in `replace` mode text is required.
1802
+ *
1803
+ * @example
1804
+ * ```ts
1805
+ * getLocatorSchema("image.logo").replace("image.logo").getByAltText("Logo").getNestedLocator();
1806
+ * ```
1807
+ */
1808
+ getByAltText(...args) {
1809
+ const [textOrOptions, options] = args;
1810
+ const {
1811
+ primary: text,
1812
+ options: parsedOptions,
1813
+ hasOptions
1814
+ } = parseUpdateArguments(
1815
+ textOrOptions,
1816
+ options,
1817
+ args.length >= 2
1818
+ );
1819
+ const definition = {
1820
+ type: "altText",
1821
+ ...text !== void 0 ? { text } : {},
1822
+ ...hasOptions ? { options: parsedOptions } : {}
1823
+ };
1824
+ return this.commit(definition);
1825
+ }
1826
+ /**
1827
+ * Defines or patches a `getByTitle` locator strategy for the target subpath. In `update` mode
1828
+ * text/options are optional; in `replace` mode text is required.
1829
+ *
1830
+ * @example
1831
+ * ```ts
1832
+ * getLocatorSchema("icon.info").update("icon.info").getByTitle({ exact: true }).getNestedLocator();
1833
+ * ```
1834
+ */
1835
+ getByTitle(...args) {
1836
+ const [textOrOptions, options] = args;
1837
+ const {
1838
+ primary: text,
1839
+ options: parsedOptions,
1840
+ hasOptions
1841
+ } = parseUpdateArguments(
1842
+ textOrOptions,
1843
+ options,
1844
+ args.length >= 2
1845
+ );
1846
+ const definition = {
1847
+ type: "title",
1848
+ ...text !== void 0 ? { text } : {},
1849
+ ...hasOptions ? { options: parsedOptions } : {}
1850
+ };
1851
+ return this.commit(definition);
1852
+ }
1853
+ /**
1854
+ * Defines or patches a `locator` strategy for the target subpath. In `update` mode selector and
1855
+ * options are optional and merge with the existing definition; in `replace` mode selector is
1856
+ * required.
1857
+ *
1858
+ * @example
1859
+ * ```ts
1860
+ * getLocatorSchema("list.items")
1861
+ * .replace("list.items")
1862
+ * .locator("ul > li", { hasText: /Row/ })
1863
+ * .getNestedLocator();
1864
+ * ```
1865
+ */
1866
+ locator(...args) {
1867
+ const [selectorOrOptions, options] = args;
1868
+ const {
1869
+ primary: selector,
1870
+ options: parsedOptions,
1871
+ hasOptions
1872
+ } = parseUpdateArguments(
1873
+ selectorOrOptions,
1874
+ options,
1875
+ args.length >= 2
1876
+ );
1877
+ const definition = {
1878
+ type: "locator",
1879
+ ...selector !== void 0 ? { selector } : {},
1880
+ ...hasOptions ? { options: parsedOptions } : {}
1881
+ };
1882
+ return this.commit(definition);
1883
+ }
1884
+ /**
1885
+ * Defines or patches a `frameLocator` strategy for the target subpath. In `update` mode the
1886
+ * selector is optional and, when omitted, inherits the existing selector; in `replace` mode the
1887
+ * selector is required.
1888
+ *
1889
+ * @example
1890
+ * ```ts
1891
+ * getLocatorSchema("frame.login").replace("frame.login").frameLocator("iframe.auth").getNestedLocator();
1892
+ * ```
1893
+ */
1894
+ frameLocator(...args) {
1895
+ const [selector] = args;
1896
+ const definition = {
1897
+ type: "frameLocator",
1898
+ ...selector !== void 0 ? { selector } : {}
1899
+ };
1900
+ return this.commit(definition);
1901
+ }
1902
+ /**
1903
+ * Defines or patches a `getByTestId` locator strategy for the target subpath. In `update` mode
1904
+ * `testId` is optional and merges with existing options; in `replace` mode it is required.
1905
+ *
1906
+ * @example
1907
+ * ```ts
1908
+ * getLocatorSchema("card.title").update("card.title").getByTestId().getNestedLocator();
1909
+ * ```
1910
+ */
1911
+ getByTestId(...args) {
1912
+ const [testId] = args;
1913
+ const definition = {
1914
+ type: "testId",
1915
+ ...testId !== void 0 ? { testId } : {}
1916
+ };
1917
+ return this.commit(definition);
1918
+ }
1919
+ /**
1920
+ * Defines or patches an `id` locator strategy for the target subpath. In `update` mode the id is
1921
+ * optional and will be normalized if provided; in `replace` mode the id is required.
1922
+ *
1923
+ * @example
1924
+ * ```ts
1925
+ * getLocatorSchema("modal.close").update("modal.close").getById().getNestedLocator();
1926
+ * ```
1927
+ */
1928
+ getById(...args) {
1929
+ const [idValue] = args;
1930
+ const id = idValue !== void 0 ? normalizeIdValue(idValue) : void 0;
1931
+ const definition = {
1932
+ type: "id",
1933
+ ...id !== void 0 ? { id } : {}
1934
+ };
1935
+ return this.commit(definition);
1936
+ }
1937
+ commit(definition) {
1938
+ return this.mode === "replace" ? this.parent.applyReplacement(this.subPath, definition) : this.parent.applyUpdate(this.subPath, definition);
1939
+ }
1940
+ };
1941
+
1942
+ // srcV2/locators/locatorQueryBuilder.ts
1943
+ var LocatorQueryBuilder = class {
1944
+ constructor(registry, path) {
1945
+ this.registry = registry;
1946
+ this.path = path;
1947
+ const chain = expandSchemaPath(path);
1948
+ let hasTerminal = false;
1949
+ for (const part of chain) {
1950
+ const record = this.registry.getIfExists(part);
1951
+ if (!record) {
1952
+ continue;
1953
+ }
1954
+ const clonedDefinition = cloneLocatorStrategyDefinition(record.definition);
1955
+ this.definitions.set(part, clonedDefinition);
1956
+ this.ensureTypeCache(part, clonedDefinition);
1957
+ const recordSteps = normalizeSteps(
1958
+ record.steps
1959
+ );
1960
+ this.steps.set(part, recordSteps);
1961
+ if (record.description !== void 0) {
1962
+ this.descriptions.set(part, record.description);
1963
+ }
1964
+ if (part === path) {
1965
+ hasTerminal = true;
1966
+ }
1967
+ }
1968
+ if (!hasTerminal) {
1969
+ throw new Error(`No locator schema registered for path "${path}".`);
1970
+ }
1971
+ }
1972
+ definitions = /* @__PURE__ */ new Map();
1973
+ perPathTypeCache = /* @__PURE__ */ new Map();
1974
+ steps = /* @__PURE__ */ new Map();
1975
+ descriptions = /* @__PURE__ */ new Map();
1976
+ tombstones = /* @__PURE__ */ new Set();
1977
+ update(subPath) {
1978
+ const resolvedSubPath = subPath ?? this.path;
1979
+ this.ensureSubPath(resolvedSubPath);
1980
+ return new LocatorUpdateBuilder(
1981
+ this,
1982
+ resolvedSubPath
1983
+ );
1984
+ }
1985
+ filter(...args) {
1986
+ const hasExplicitSubPath = args.length === 2;
1987
+ const [subPathOrFilter, maybeFilter] = args;
1988
+ const resolvedSubPath = hasExplicitSubPath ? subPathOrFilter : this.path;
1989
+ const filter = hasExplicitSubPath ? maybeFilter : subPathOrFilter;
1990
+ this.ensureSubPath(resolvedSubPath);
1991
+ const existing = this.steps.get(resolvedSubPath) ?? [];
1992
+ existing.push({ kind: "filter", filter });
1993
+ this.steps.set(resolvedSubPath, existing);
1994
+ return this;
1995
+ }
1996
+ clearSteps(subPath) {
1997
+ const resolvedSubPath = subPath ?? this.path;
1998
+ this.ensureSubPath(resolvedSubPath);
1999
+ this.steps.set(resolvedSubPath, []);
2000
+ return this;
2001
+ }
2002
+ nth(...args) {
2003
+ const hasExplicitSubPath = args.length === 2;
2004
+ const [subPathOrIndex, maybeIndex] = args;
2005
+ const resolvedSubPath = hasExplicitSubPath ? subPathOrIndex : this.path;
2006
+ const index = hasExplicitSubPath ? maybeIndex : subPathOrIndex;
2007
+ this.ensureSubPath(resolvedSubPath);
2008
+ const existing = this.steps.get(resolvedSubPath) ?? [];
2009
+ existing.push({ kind: "index", index });
2010
+ this.steps.set(resolvedSubPath, existing);
2011
+ return this;
2012
+ }
2013
+ /**
2014
+ * Adds or overrides the description for the terminal path of this builder. The description is
2015
+ * applied only to the resolved terminal locator and does not mutate registry state.
2016
+ *
2017
+ * @example
2018
+ * ```ts
2019
+ * getLocatorSchema("section.button")
2020
+ * .describe("Save button")
2021
+ * .getNestedLocator();
2022
+ * ```
2023
+ */
2024
+ describe(description) {
2025
+ this.ensureSubPath(this.path);
2026
+ this.descriptions.set(this.path, description);
2027
+ return this;
2028
+ }
2029
+ /** @internal */
2030
+ applyUpdate(subPath, updates) {
2031
+ this.ensureSubPath(subPath);
2032
+ if (!this.definitions.has(subPath) && this.tombstones.has(subPath)) {
2033
+ const baseline2 = this.registry.get(subPath).definition;
2034
+ const baselineClone = cloneLocatorStrategyDefinition(baseline2);
2035
+ this.definitions.set(subPath, baselineClone);
2036
+ this.steps.set(subPath, []);
2037
+ this.tombstones.delete(subPath);
2038
+ }
2039
+ const current = this.definitions.get(subPath);
2040
+ if (!current) {
2041
+ throw new Error(`No locator schema registered for sub-path "${subPath}".`);
2042
+ }
2043
+ const baseline = this.registry.get(subPath).definition;
2044
+ const cacheForPath = this.ensureTypeCache(subPath, cloneLocatorStrategyDefinition(baseline));
2045
+ const cachedDefinition = cacheForPath.get(updates.type);
2046
+ const merged = mergeLocatorDefinition(current, updates, subPath, cachedDefinition, baseline);
2047
+ const mergedClone = cloneLocatorStrategyDefinition(merged);
2048
+ cacheForPath.set(mergedClone.type, mergedClone);
2049
+ this.definitions.set(subPath, mergedClone);
2050
+ return this;
2051
+ }
2052
+ replace(subPath) {
2053
+ const resolvedSubPath = subPath ?? this.path;
2054
+ this.ensureSubPath(resolvedSubPath);
2055
+ return new LocatorUpdateBuilder(
2056
+ this,
2057
+ resolvedSubPath,
2058
+ "replace"
2059
+ );
2060
+ }
2061
+ /** @internal */
2062
+ applyReplacement(subPath, updates) {
2063
+ this.ensureSubPath(subPath);
2064
+ if (this.tombstones.has(subPath) && !this.definitions.has(subPath)) {
2065
+ this.steps.set(subPath, []);
2066
+ this.tombstones.delete(subPath);
2067
+ }
2068
+ const nextDefinition = buildReplacementDefinition(updates, subPath);
2069
+ const cloned = cloneLocatorStrategyDefinition(nextDefinition);
2070
+ const cacheForPath = this.ensureTypeCache(subPath, cloned);
2071
+ cacheForPath.set(cloned.type, cloneLocatorStrategyDefinition(cloned));
2072
+ this.definitions.set(subPath, cloned);
2073
+ return this;
2074
+ }
2075
+ remove(subPath) {
2076
+ const resolvedSubPath = subPath ?? this.path;
2077
+ this.ensureSubPath(resolvedSubPath);
2078
+ this.definitions.delete(resolvedSubPath);
2079
+ this.steps.delete(resolvedSubPath);
2080
+ this.perPathTypeCache.delete(resolvedSubPath);
2081
+ this.descriptions.delete(resolvedSubPath);
2082
+ this.tombstones.add(resolvedSubPath);
2083
+ return this;
2084
+ }
2085
+ /**
2086
+ * Resolves and returns the Playwright {@link Locator} for the terminal path of this builder,
2087
+ * applying only the terminal definition and its steps. Throws if the terminal path has been
2088
+ * removed or is otherwise missing.
2089
+ *
2090
+ * @example
2091
+ * ```ts
2092
+ * const locator = getLocatorSchema("form.submit").getLocator();
2093
+ * ```
2094
+ */
2095
+ getLocator() {
2096
+ const definition = this.definitions.get(this.path);
2097
+ if (!definition) {
2098
+ throw new Error(`No locator schema registered for path "${this.path}".`);
2099
+ }
2100
+ const stepsForPath = this.steps.get(this.path) ?? [];
2101
+ const definitions = /* @__PURE__ */ new Map([[this.path, definition]]);
2102
+ const steps = /* @__PURE__ */ new Map([
2103
+ [
2104
+ this.path,
2105
+ normalizeSteps(stepsForPath)
2106
+ ]
2107
+ ]);
2108
+ const { locator } = this.registry.buildLocatorChain(
2109
+ this.path,
2110
+ definitions,
2111
+ steps,
2112
+ this.tombstones,
2113
+ this.descriptions.get(this.path)
2114
+ );
2115
+ if (!locator) {
2116
+ throw new Error(`Unable to resolve direct locator for path "${this.path}".`);
2117
+ }
2118
+ return locator;
2119
+ }
2120
+ /**
2121
+ * Resolves the chained Playwright {@link Locator} for this builder’s root path, traversing each
2122
+ * registered segment and applying recorded steps. Throws if any required segment is missing.
2123
+ *
2124
+ * @example
2125
+ * ```ts
2126
+ * const nested = getLocatorSchema("list.item")
2127
+ * .filter("list", { hasText: "List" })
2128
+ * .getNestedLocator();
2129
+ * ```
2130
+ */
2131
+ getNestedLocator() {
2132
+ const { locator } = this.resolve();
2133
+ if (!locator) {
2134
+ throw new Error(`Unable to resolve nested locator for path "${this.path}".`);
2135
+ }
2136
+ return locator;
2137
+ }
2138
+ ensureSubPath(subPath) {
2139
+ if (!this.definitions.has(subPath) && !this.tombstones.has(subPath)) {
2140
+ throw new Error(`"${subPath}" is not a valid sub-path of "${this.path}".`);
2141
+ }
2142
+ }
2143
+ resolve() {
2144
+ return this.registry.buildLocatorChain(
2145
+ this.path,
2146
+ this.definitions,
2147
+ this.steps,
2148
+ this.tombstones,
2149
+ this.descriptions.get(this.path)
2150
+ );
2151
+ }
2152
+ ensureTypeCache(subPath, baseline) {
2153
+ if (!this.perPathTypeCache.has(subPath)) {
2154
+ this.perPathTypeCache.set(
2155
+ subPath,
2156
+ /* @__PURE__ */ new Map([
2157
+ [baseline.type, cloneLocatorStrategyDefinition(baseline)]
2158
+ ])
2159
+ );
2160
+ }
2161
+ return this.perPathTypeCache.get(subPath);
2162
+ }
2163
+ };
2164
+
2165
+ // srcV2/locators/locatorRegistrationBuilder.ts
2166
+ var LocatorRegistrationBuilder = class {
2167
+ constructor(registry, path, seed) {
2168
+ this.registry = registry;
2169
+ this.path = path;
2170
+ if (seed?.initialSteps) {
2171
+ this.steps = normalizeSteps(seed.initialSteps);
2172
+ }
2173
+ if (seed?.initialDefinition) {
2174
+ this.definition = seed.initialDefinition;
2175
+ this.seededDefinition = true;
2176
+ } else {
2177
+ this.seededDefinition = false;
2178
+ }
2179
+ this.reuseType = seed?.reuseType;
2180
+ this.description = seed?.initialDescription;
2181
+ }
2182
+ steps = [];
2183
+ definition;
2184
+ description;
2185
+ registered = false;
2186
+ reuseType;
2187
+ seededDefinition;
2188
+ overrideApplied = false;
2189
+ postDefinitionView;
2190
+ persistSeededDefinition() {
2191
+ if (this.seededDefinition && !this.registered) {
2192
+ this.persist();
2193
+ }
2194
+ return this;
2195
+ }
2196
+ /**
2197
+ * Records a Playwright-style filter on the locator being registered. Filters are applied in the
2198
+ * order they are chained and can include `has`/`hasNot` locator references. Requires that a
2199
+ * locator strategy has already been set for this registration.
2200
+ *
2201
+ * @example
2202
+ * ```ts
2203
+ * registry.add("list.item").locator("li").filter({ hasText: /Row/ });
2204
+ * ```
2205
+ */
2206
+ filter(filter) {
2207
+ this.applyFilter(filter);
2208
+ return this.getPostDefinitionView();
2209
+ }
2210
+ /**
2211
+ * Adds an index selector for the locator being registered. Indices are applied in the order they
2212
+ * are chained and require a locator definition to have been set first.
2213
+ *
2214
+ * @example
2215
+ * ```ts
2216
+ * registry.add("table.rows").locator("tr").nth(0);
2217
+ * ```
2218
+ */
2219
+ nth(index) {
2220
+ this.applyIndex(index);
2221
+ return this.getPostDefinitionView();
2222
+ }
2223
+ describe(description) {
2224
+ this.description = description;
2225
+ this.persist();
2226
+ return this.getPostDefinitionView();
2227
+ }
2228
+ getByRole(roleOrOptions, options) {
2229
+ const definition = typeof roleOrOptions === "string" ? options !== void 0 ? { type: "role", role: roleOrOptions, options } : { type: "role", role: roleOrOptions } : { type: "role", options: roleOrOptions };
2230
+ return this.commit(definition);
2231
+ }
2232
+ getByText(textOrOptions, options) {
2233
+ const definition = typeof textOrOptions === "string" || textOrOptions instanceof RegExp ? options !== void 0 ? { type: "text", text: textOrOptions, options } : { type: "text", text: textOrOptions } : { type: "text", options: textOrOptions };
2234
+ return this.commit(definition);
2235
+ }
2236
+ getByLabel(textOrOptions, options) {
2237
+ const definition = typeof textOrOptions === "string" || textOrOptions instanceof RegExp ? options !== void 0 ? { type: "label", text: textOrOptions, options } : { type: "label", text: textOrOptions } : { type: "label", options: textOrOptions };
2238
+ return this.commit(definition);
2239
+ }
2240
+ getByPlaceholder(textOrOptions, options) {
2241
+ const definition = typeof textOrOptions === "string" || textOrOptions instanceof RegExp ? options !== void 0 ? { type: "placeholder", text: textOrOptions, options } : { type: "placeholder", text: textOrOptions } : { type: "placeholder", options: textOrOptions };
2242
+ return this.commit(definition);
2243
+ }
2244
+ getByAltText(textOrOptions, options) {
2245
+ const definition = typeof textOrOptions === "string" || textOrOptions instanceof RegExp ? options !== void 0 ? { type: "altText", text: textOrOptions, options } : { type: "altText", text: textOrOptions } : { type: "altText", options: textOrOptions };
2246
+ return this.commit(definition);
2247
+ }
2248
+ getByTitle(textOrOptions, options) {
2249
+ const definition = typeof textOrOptions === "string" || textOrOptions instanceof RegExp ? options !== void 0 ? { type: "title", text: textOrOptions, options } : { type: "title", text: textOrOptions } : { type: "title", options: textOrOptions };
2250
+ return this.commit(definition);
2251
+ }
2252
+ locator(selectorOrOptions, options) {
2253
+ const definition = typeof selectorOrOptions === "string" ? options !== void 0 ? { type: "locator", selector: selectorOrOptions, options } : { type: "locator", selector: selectorOrOptions } : { type: "locator", options: selectorOrOptions };
2254
+ return this.commit(definition);
2255
+ }
2256
+ /**
2257
+ * Uses Playwright `frameLocator` semantics to define the locator strategy, entering the targeted
2258
+ * frame for subsequent chained locators. When seeded, `selector` may be omitted to retain the
2259
+ * existing selector while overriding options elsewhere.
2260
+ *
2261
+ * @example
2262
+ * ```ts
2263
+ * registry.add("frame.login").frameLocator("iframe.auth");
2264
+ * ```
2265
+ */
2266
+ frameLocator(selector) {
2267
+ const definition = selector ? { type: "frameLocator", selector } : { type: "frameLocator" };
2268
+ return this.commit(definition);
2269
+ }
2270
+ /**
2271
+ * Uses Playwright `getByTestId` semantics to define the locator strategy. When seeded, omitting
2272
+ * the argument inherits the seeded `testId` while allowing options from other overrides.
2273
+ *
2274
+ * @example
2275
+ * ```ts
2276
+ * registry.add("card.title").getByTestId("card-title");
2277
+ * ```
2278
+ */
2279
+ getByTestId(testId) {
2280
+ const definition = testId ? { type: "testId", testId } : { type: "testId" };
2281
+ return this.commit(definition);
2282
+ }
2283
+ /**
2284
+ * Targets elements by `id`, normalizing string or RegExp input. When seeded, the argument can be
2285
+ * omitted to inherit the seeded id.
2286
+ *
2287
+ * @example
2288
+ * ```ts
2289
+ * registry.add("modal.close").getById("close-modal");
2290
+ * ```
2291
+ */
2292
+ getById(id) {
2293
+ const definition = id ? { type: "id", id: normalizeIdValue(id) } : { type: "id" };
2294
+ return this.commit(definition);
2295
+ }
2296
+ commit(definition) {
2297
+ this.ensureDefinitionAllowedWithRollback(definition);
2298
+ const mergedDefinition = this.seededDefinition ? applyDefinitionPatch(this.definition, definition) : definition;
2299
+ this.definition = mergedDefinition;
2300
+ if (this.reuseType && this.seededDefinition) {
2301
+ this.overrideApplied = true;
2302
+ }
2303
+ this.persist();
2304
+ return this.getPostDefinitionView();
2305
+ }
2306
+ applyFilter(filter) {
2307
+ this.ensureDefinition();
2308
+ this.steps.push({ kind: "filter", filter });
2309
+ this.persist();
2310
+ }
2311
+ applyIndex(index) {
2312
+ this.ensureDefinition();
2313
+ this.steps.push({ kind: "index", index });
2314
+ this.persist();
2315
+ }
2316
+ ensureDefinitionAllowedWithRollback(definition) {
2317
+ if (this.seededDefinition) {
2318
+ if (definition.type !== this.reuseType) {
2319
+ this.rollbackSeededRegistration();
2320
+ throw new Error(
2321
+ `The locator definition for "${this.path}" must use the "${this.reuseType}" strategy when reusing a locator.`
2322
+ );
2323
+ }
2324
+ if (this.overrideApplied) {
2325
+ throw new Error(
2326
+ `A locator definition for "${this.path}" was already provided from reuse; only one matching override is allowed.`
2327
+ );
2328
+ }
2329
+ return;
2330
+ }
2331
+ if (this.definition) {
2332
+ throw new Error(
2333
+ `A locator definition for "${this.path}" has already been provided; only one locator type can be set for a registration.`
2334
+ );
2335
+ }
2336
+ }
2337
+ ensureDefinition() {
2338
+ if (!this.definition) {
2339
+ throw new Error(`A locator definition must be provided before applying filters or indices for "${this.path}".`);
2340
+ }
2341
+ }
2342
+ persist() {
2343
+ if (!this.definition) {
2344
+ throw new Error(`No locator schema definition provided for path "${this.path}".`);
2345
+ }
2346
+ const record = {
2347
+ locatorSchemaPath: this.path,
2348
+ definition: this.definition,
2349
+ steps: normalizeSteps(this.steps),
2350
+ ...this.description !== void 0 ? { description: this.description } : {}
2351
+ };
2352
+ if (this.registered) {
2353
+ this.registry.replace(this.path, record);
2354
+ } else {
2355
+ this.registry.register(this.path, record);
2356
+ this.registered = true;
2357
+ }
2358
+ }
2359
+ rollbackSeededRegistration() {
2360
+ if (this.seededDefinition && this.registered) {
2361
+ this.registry.unregister(this.path);
2362
+ this.registered = false;
2363
+ }
2364
+ }
2365
+ getPostDefinitionView() {
2366
+ if (this.postDefinitionView) {
2367
+ return this.postDefinitionView;
2368
+ }
2369
+ const view = {
2370
+ filter: (filter) => {
2371
+ this.applyFilter(filter);
2372
+ return view;
2373
+ },
2374
+ nth: (index) => {
2375
+ this.applyIndex(index);
2376
+ return view;
2377
+ },
2378
+ describe: (description) => {
2379
+ this.description = description;
2380
+ this.persist();
2381
+ return view;
2382
+ }
2383
+ };
2384
+ this.postDefinitionView = view;
2385
+ return view;
2386
+ }
2387
+ };
2388
+
2389
+ // srcV2/locators/reusableLocatorBuilder.ts
2390
+ var ReusableLocatorBuilder = class {
2391
+ stepsList;
2392
+ definitionValue;
2393
+ descriptionValue;
2394
+ type;
2395
+ constructor(definition, steps = []) {
2396
+ this.definitionValue = definition;
2397
+ this.type = definition.type;
2398
+ this.stepsList = normalizeSteps(steps);
2399
+ }
2400
+ filter(filter) {
2401
+ this.stepsList.push({ kind: "filter", filter });
2402
+ return this;
2403
+ }
2404
+ nth(index) {
2405
+ this.stepsList.push({ kind: "index", index });
2406
+ return this;
2407
+ }
2408
+ describe(description) {
2409
+ this.descriptionValue = description;
2410
+ return this;
2411
+ }
2412
+ get definition() {
2413
+ return this.definitionValue;
2414
+ }
2415
+ get steps() {
2416
+ return normalizeSteps(this.stepsList);
2417
+ }
2418
+ get description() {
2419
+ return this.descriptionValue;
2420
+ }
2421
+ };
2422
+ var ReusableLocatorFactory = class {
2423
+ getByRole(role, options) {
2424
+ const definition = options !== void 0 ? { type: "role", role, options } : { type: "role", role };
2425
+ return this.create(definition);
2426
+ }
2427
+ getByText(text, options) {
2428
+ const definition = options !== void 0 ? { type: "text", text, options } : { type: "text", text };
2429
+ return this.create(definition);
2430
+ }
2431
+ getByLabel(text, options) {
2432
+ const definition = options !== void 0 ? { type: "label", text, options } : { type: "label", text };
2433
+ return this.create(definition);
2434
+ }
2435
+ getByPlaceholder(text, options) {
2436
+ const definition = options !== void 0 ? { type: "placeholder", text, options } : { type: "placeholder", text };
2437
+ return this.create(definition);
2438
+ }
2439
+ getByAltText(text, options) {
2440
+ const definition = options !== void 0 ? { type: "altText", text, options } : { type: "altText", text };
2441
+ return this.create(definition);
2442
+ }
2443
+ getByTitle(text, options) {
2444
+ const definition = options !== void 0 ? { type: "title", text, options } : { type: "title", text };
2445
+ return this.create(definition);
2446
+ }
2447
+ locator(selector, options) {
2448
+ const definition = options !== void 0 ? { type: "locator", selector, options } : { type: "locator", selector };
2449
+ return this.create(definition);
2450
+ }
2451
+ frameLocator(selector) {
2452
+ return this.create({ type: "frameLocator", selector });
2453
+ }
2454
+ getByTestId(testId) {
2455
+ return this.create({ type: "testId", testId });
2456
+ }
2457
+ getById(id) {
2458
+ return this.create({ type: "id", id: normalizeIdValue(id) });
2459
+ }
2460
+ create(definition) {
2461
+ return new ReusableLocatorBuilder(definition);
2462
+ }
2463
+ };
2464
+
2465
+ // srcV2/locators/locatorRegistry.ts
2466
+ var LocatorRegistryInternal = class {
2467
+ constructor(page) {
2468
+ this.page = page;
2469
+ this.createReusable = new ReusableLocatorFactory();
2470
+ }
2471
+ schemas = /* @__PURE__ */ new Map();
2472
+ /**
2473
+ * Factory for reusable locator seeds that capture a locator strategy plus any chained
2474
+ * `filter`/`nth` steps without registering them. Pass the resulting seed to
2475
+ * {@link LocatorRegistryInternal.add} via `{ reuse }` to register a path that inherits the
2476
+ * stored definition and steps.
2477
+ *
2478
+ * @example
2479
+ * ```ts
2480
+ * const seed = registry.createReusable.getByRole("heading", { level: 2 }).filter({ hasText: /Summary/ });
2481
+ * registry.add("hero.title", { reuse: seed }).getByRole({ name: "Summary" });
2482
+ * ```
2483
+ */
2484
+ createReusable;
2485
+ normalizeRecord(record) {
2486
+ return {
2487
+ locatorSchemaPath: record.locatorSchemaPath,
2488
+ definition: record.definition,
2489
+ steps: normalizeSteps(record.steps),
2490
+ ...record.description !== void 0 ? { description: record.description } : {}
2491
+ };
2492
+ }
2493
+ cloneRecordForReuse(record, path) {
2494
+ return {
2495
+ locatorSchemaPath: path,
2496
+ definition: cloneLocatorStrategyDefinition(record.definition),
2497
+ steps: normalizeSteps(record.steps),
2498
+ ...record.description !== void 0 ? { description: record.description } : {}
2499
+ };
2500
+ }
2501
+ add(path, options) {
2502
+ const reuse = options?.reuse;
2503
+ if (!reuse) {
2504
+ return new LocatorRegistrationBuilder(
2505
+ this,
2506
+ path
2507
+ );
2508
+ }
2509
+ if (typeof reuse === "string") {
2510
+ const sourceRecord = this.get(reuse);
2511
+ const cloned = this.cloneRecordForReuse(sourceRecord, path);
2512
+ this.register(path, cloned);
2513
+ return void 0;
2514
+ }
2515
+ const reusedRecord = this.cloneRecordForReuse(
2516
+ {
2517
+ locatorSchemaPath: path,
2518
+ definition: reuse.definition,
2519
+ steps: reuse.steps,
2520
+ description: reuse.description
2521
+ },
2522
+ path
2523
+ );
2524
+ return new LocatorRegistrationBuilder(
2525
+ this,
2526
+ path,
2527
+ {
2528
+ initialDefinition: reusedRecord.definition,
2529
+ initialSteps: reusedRecord.steps,
2530
+ reuseType: reusedRecord.definition.type,
2531
+ initialDescription: reusedRecord.description
2532
+ }
2533
+ ).persistSeededDefinition();
2534
+ }
2535
+ register(path, record) {
2536
+ validateLocatorSchemaPath(path);
2537
+ if (this.schemas.has(path)) {
2538
+ const existing = this.schemas.get(path);
2539
+ if (!existing) {
2540
+ throw new Error(`A locator schema with the path "${path}" already exists.`);
2541
+ }
2542
+ const errorDetails = stringifyForLog({
2543
+ existing,
2544
+ attempted: record
2545
+ });
2546
+ throw new Error(`A locator schema with the path "${path}" already exists.
2547
+ Existing Schema: ${errorDetails}`);
2548
+ }
2549
+ this.schemas.set(path, this.normalizeRecord(record));
2550
+ }
2551
+ replace(path, record) {
2552
+ validateLocatorSchemaPath(path);
2553
+ if (!this.schemas.has(path)) {
2554
+ throw new Error(`No locator schema registered for path "${path}".`);
2555
+ }
2556
+ this.schemas.set(path, this.normalizeRecord(record));
2557
+ }
2558
+ get(path) {
2559
+ const record = this.schemas.get(path);
2560
+ if (!record) {
2561
+ throw new Error(`No locator schema registered for path "${path}".`);
2562
+ }
2563
+ return {
2564
+ locatorSchemaPath: record.locatorSchemaPath,
2565
+ definition: record.definition,
2566
+ steps: normalizeSteps(record.steps),
2567
+ ...record.description !== void 0 ? { description: record.description } : {}
2568
+ };
2569
+ }
2570
+ unregister(path) {
2571
+ this.schemas.delete(path);
2572
+ }
2573
+ getIfExists(path) {
2574
+ const record = this.schemas.get(path);
2575
+ if (!record) {
2576
+ return void 0;
2577
+ }
2578
+ return {
2579
+ locatorSchemaPath: record.locatorSchemaPath,
2580
+ definition: record.definition,
2581
+ steps: normalizeSteps(record.steps),
2582
+ ...record.description !== void 0 ? { description: record.description } : {}
2583
+ };
2584
+ }
2585
+ resolveFilterLocator(locatorReference, context) {
2586
+ if (isLocatorInstance(locatorReference)) {
2587
+ return locatorReference;
2588
+ }
2589
+ if (typeof locatorReference === "string") {
2590
+ return this.getLocatorWithContext(locatorReference, context);
2591
+ }
2592
+ throw new Error(
2593
+ `Unsupported filter reference while resolving "${context.rootPath}". Filter has/hasNot supports Playwright Locator instances or registry path strings.`
2594
+ );
2595
+ }
2596
+ createResolutionContext(rootPath) {
2597
+ return {
2598
+ rootPath,
2599
+ resolvingPaths: /* @__PURE__ */ new Set()
2600
+ };
2601
+ }
2602
+ getLocatorWithContext(path, context) {
2603
+ if (context.resolvingPaths.has(path)) {
2604
+ throw new Error(`Detected cyclic filter reference while resolving "${context.rootPath}": "${path}".`);
2605
+ }
2606
+ context.resolvingPaths.add(path);
2607
+ try {
2608
+ const record = this.get(path);
2609
+ const definitions = /* @__PURE__ */ new Map([[path, record.definition]]);
2610
+ const steps = /* @__PURE__ */ new Map([[path, normalizeSteps(record.steps)]]);
2611
+ const { locator } = this.buildLocatorChain(path, definitions, steps, void 0, record.description, context);
2612
+ if (!locator) {
2613
+ throw new Error(`Unable to resolve direct locator for path "${path}".`);
2614
+ }
2615
+ return locator;
2616
+ } finally {
2617
+ context.resolvingPaths.delete(path);
2618
+ }
2619
+ }
2620
+ resolveFiltersForTarget(filters, context) {
2621
+ if (!filters || filters.length === 0) {
2622
+ return [];
2623
+ }
2624
+ const resolved = [];
2625
+ for (const filter of filters) {
2626
+ if (filter && typeof filter === "object" && ("has" in filter || "hasNot" in filter)) {
2627
+ const { has, hasNot, ...rest } = filter;
2628
+ const normalizedFilter = {
2629
+ ...rest
2630
+ };
2631
+ if (has !== void 0) {
2632
+ normalizedFilter.has = this.resolveFilterLocator(has, context);
2633
+ }
2634
+ if (hasNot !== void 0) {
2635
+ normalizedFilter.hasNot = this.resolveFilterLocator(hasNot, context);
2636
+ }
2637
+ resolved.push(normalizedFilter);
2638
+ continue;
2639
+ }
2640
+ resolved.push(filter);
2641
+ }
2642
+ return resolved;
2643
+ }
2644
+ /**
2645
+ * Returns a mutable query builder clone for the provided path. Use the builder to add or clear
2646
+ * `filter`/`nth` steps, or to `update`/`replace` locator definitions before resolving locators.
2647
+ * Changes affect only the builder clone; the registry’s stored schema remains untouched.
2648
+ *
2649
+ * @example
2650
+ * ```ts
2651
+ * const builder = registry
2652
+ * .getLocatorSchema("section.button")
2653
+ * .filter("section.button", { hasText: /Save/ })
2654
+ * .nth("section", 0);
2655
+ * const locator = builder.getNestedLocator();
2656
+ * ```
2657
+ */
2658
+ getLocatorSchema(path) {
2659
+ return new LocatorQueryBuilder(this, path);
2660
+ }
2661
+ /**
2662
+ * Resolves the Playwright {@link Locator} for the provided path, applying only the terminal
2663
+ * definition and its recorded steps (no ancestor chaining). Throws if the path is not registered.
2664
+ *
2665
+ * @example
2666
+ * ```ts
2667
+ * const button = registry.getLocator("form.submit");
2668
+ * await button.click();
2669
+ * ```
2670
+ */
2671
+ getLocator(path) {
2672
+ return this.getLocatorSchema(path).getLocator();
2673
+ }
2674
+ /**
2675
+ * Resolves a chained Playwright {@link Locator} for a nested path, traversing each registered
2676
+ * segment and applying their steps in order. Throws if any segment in the chain is missing.
2677
+ *
2678
+ * @example
2679
+ * ```ts
2680
+ * const nested = registry.getNestedLocator("list.item");
2681
+ * await expect(nested).toBeVisible();
2682
+ * ```
2683
+ */
2684
+ getNestedLocator(path) {
2685
+ return this.getLocatorSchema(path).getNestedLocator();
2686
+ }
2687
+ buildLocatorChain(path, definitions, steps, tombstones, terminalDescription, context) {
2688
+ const resolutionContext = context ?? this.createResolutionContext(path);
2689
+ const chain = expandSchemaPath(path);
2690
+ const registeredChain = chain.filter((part) => definitions.has(part));
2691
+ if (tombstones?.has(path) || !definitions.has(path)) {
2692
+ throw new Error(`No locator schema registered for path "${path}".`);
2693
+ }
2694
+ let currentTarget = this.page;
2695
+ let lastLocator = null;
2696
+ const debugSteps = [];
2697
+ const lastIndex = registeredChain.length - 1;
2698
+ for (const [index, part] of registeredChain.entries()) {
2699
+ const isTerminalStep = index === lastIndex;
2700
+ const definition = definitions.get(part);
2701
+ if (tombstones?.has(part)) {
2702
+ if (isTerminalStep) {
2703
+ throw new Error(`No locator schema registered for path "${path}".`);
2704
+ }
2705
+ continue;
2706
+ }
2707
+ if (!definition) {
2708
+ throw new Error(`Missing locator definition for "${part}" while resolving "${path}".`);
2709
+ }
2710
+ if (isFrameLocatorDefinition(definition)) {
2711
+ const frameLocator = createLocator(currentTarget, definition);
2712
+ const isTerminalStep2 = index === lastIndex;
2713
+ if (isTerminalStep2) {
2714
+ const ownerLocator = frameLocator.owner();
2715
+ currentTarget = ownerLocator;
2716
+ lastLocator = ownerLocator;
2717
+ } else {
2718
+ currentTarget = frameLocator;
2719
+ lastLocator = frameLocator;
2720
+ }
2721
+ if (isTerminalStep2 && terminalDescription && isLocatorInstance(lastLocator)) {
2722
+ lastLocator = lastLocator.describe(terminalDescription);
2723
+ currentTarget = lastLocator;
2724
+ }
2725
+ debugSteps.push({ path: part, definition, appliedFilters: [], recordedSteps: [] });
2726
+ continue;
2727
+ }
2728
+ const locatorResult = createLocator(currentTarget, definition);
2729
+ const recordedSteps = steps.get(part) ?? [];
2730
+ let resolvedLocator = locatorResult;
2731
+ const appliedFilters = [];
2732
+ let appliedIndex;
2733
+ for (const step2 of recordedSteps) {
2734
+ if (step2.kind === "filter") {
2735
+ const [resolvedFilter] = this.resolveFiltersForTarget([step2.filter], resolutionContext);
2736
+ if (resolvedFilter) {
2737
+ resolvedLocator = resolvedLocator.filter(resolvedFilter);
2738
+ appliedFilters.push(resolvedFilter);
2739
+ }
2740
+ } else {
2741
+ appliedIndex = step2.index ?? null;
2742
+ resolvedLocator = applyIndexSelector(resolvedLocator, appliedIndex ?? void 0);
2743
+ }
2744
+ }
2745
+ if (isTerminalStep && terminalDescription) {
2746
+ resolvedLocator = resolvedLocator.describe(terminalDescription);
2747
+ }
2748
+ currentTarget = resolvedLocator;
2749
+ lastLocator = resolvedLocator;
2750
+ debugSteps.push({
2751
+ path: part,
2752
+ definition,
2753
+ appliedFilters,
2754
+ index: appliedIndex,
2755
+ recordedSteps
2756
+ });
2757
+ }
2758
+ return { locator: lastLocator, steps: debugSteps };
2759
+ }
2760
+ };
2761
+ var createRegistryWithAccessors = (page) => {
2762
+ const _assertValidPaths = true;
2763
+ const registryInstance = new LocatorRegistryInternal(page);
2764
+ const add = registryInstance.add.bind(registryInstance);
2765
+ const getLocator = registryInstance.getLocator.bind(registryInstance);
2766
+ const getNestedLocator = registryInstance.getNestedLocator.bind(registryInstance);
2767
+ const getLocatorSchema = registryInstance.getLocatorSchema.bind(registryInstance);
2768
+ const registry = registryInstance;
2769
+ return { registry, add, getLocator, getNestedLocator, getLocatorSchema };
2770
+ };
2771
+
2772
+ // src/basePageV1toV2.ts
2773
+ var BasePageV1toV2 = class {
2774
+ /** Provides Playwright page methods */
2775
+ page;
2776
+ /** Playwright TestInfo contains information about currently running test, available to any test function */
2777
+ testInfo;
2778
+ /** Selectors can be used to install custom selector engines.*/
2779
+ selector;
2780
+ /** The base URL of the Page Object Class */
2781
+ baseUrl;
2782
+ /** The URL path of the Page Object Class */
2783
+ urlPath;
2784
+ /** The full URL of the Page Object Class */
2785
+ fullUrl;
2786
+ /** The name of the Page Object Class */
2787
+ pocName;
2788
+ /** The Page Object Class' PlaywrightReportLogger instance, prefixed with its name. Log levels: debug, info, warn, and error. */
2789
+ log;
2790
+ /** The SessionStorage class provides methods for setting and getting session storage data in Playwright.*/
2791
+ sessionStorage;
2792
+ /**
2793
+ * locators:
2794
+ * An instance of GetLocatorBase that handles schema management and provides getLocatorSchema calls.
2795
+ * Initially, LocatorSubstring is undefined. Once getLocatorSchema(path) is called,
2796
+ * we get a chainable object typed with LocatorSubstring = P.
2797
+ */
2798
+ locators;
2799
+ /**
2800
+ * v2 locator registry and accessors, used for migration to the fluent registry DSL.
2801
+ */
2802
+ locatorRegistry;
2803
+ add;
2804
+ getLocator;
2805
+ getLocatorSchema;
2806
+ getNestedLocator;
2807
+ constructor(page, testInfo, baseUrl, urlPath, pocName, pwrl, locatorSubstring) {
2808
+ this.page = page;
2809
+ this.testInfo = testInfo;
2810
+ this.selector = import_test4.selectors;
2811
+ this.baseUrl = baseUrl;
2812
+ this.urlPath = urlPath;
2813
+ this.fullUrl = this.constructFullUrl(baseUrl, urlPath);
2814
+ this.pocName = pocName;
2815
+ this.log = pwrl.getNewChildLogger(pocName);
2816
+ const classDeprecationMessage = "[POMWright] BasePageV1toV2 is a transitional bridge and will be removed in 2.0.0. Prefer PageObject for new work and migrate existing classes to PageObject.";
2817
+ warnDeprecationOncePerTest(`${this.constructor.name}-class-deprecation`, classDeprecationMessage, this.log);
2818
+ const { registry, add, getLocator, getNestedLocator, getLocatorSchema } = createRegistryWithAccessors(page);
2819
+ this.locatorRegistry = registry;
2820
+ this.add = add;
2821
+ this.getLocator = getLocator;
2822
+ this.getLocatorSchema = getLocatorSchema;
2823
+ this.getNestedLocator = getNestedLocator;
2824
+ this.defineLocators();
2825
+ this.locators = new GetLocatorBase(
2826
+ this,
2827
+ this.log.getNewChildLogger("GetLocator"),
2828
+ locatorSubstring
2829
+ );
2830
+ const initLocatorSchemasDeprecationMessage = "[POMWright] initLocatorSchemas is deprecated and will be removed in 2.0.0. Define locators with the v2 registry DSL in defineLocators instead.";
2831
+ warnDeprecationOncePerTest(
2832
+ `${this.constructor.name}-initLocatorSchemas-deprecation`,
2833
+ initLocatorSchemasDeprecationMessage,
2834
+ this.log
2835
+ );
2836
+ this.initLocatorSchemas();
2837
+ this.sessionStorage = new SessionStorage(this.page, this.pocName);
2838
+ }
2839
+ /**
2840
+ * constructFullUrl:
2841
+ * Combines baseUrl and urlPath, handling both strings and RegExps.
2842
+ * Ensures a flexible approach to URL matching (string or regex-based).
2843
+ */
2844
+ constructFullUrl(baseUrl, urlPath) {
2845
+ const escapeStringForRegExp = (str) => str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
2846
+ if (typeof baseUrl === "string" && typeof urlPath === "string") {
2847
+ return `${baseUrl}${urlPath}`;
2848
+ }
2849
+ if (typeof baseUrl === "string" && urlPath instanceof RegExp) {
2850
+ return new RegExp(`^${escapeStringForRegExp(baseUrl)}${urlPath.source}`);
2851
+ }
2852
+ if (baseUrl instanceof RegExp && typeof urlPath === "string") {
2853
+ return new RegExp(`${baseUrl.source}${escapeStringForRegExp(urlPath)}$`);
2854
+ }
2855
+ if (baseUrl instanceof RegExp && urlPath instanceof RegExp) {
2856
+ return new RegExp(`${baseUrl.source}${urlPath.source}`);
2857
+ }
2858
+ throw new Error("Invalid baseUrl or urlPath types. Expected string or RegExp.");
2859
+ }
2860
+ };
2861
+
2862
+ // srcV2/helpers/navigation.ts
2863
+ var import_test5 = require("@playwright/test");
2864
+ var DEFAULT_WAIT_UNTIL = "load";
2865
+ var DEFAULT_LOAD_STATE = "load";
2866
+ var Navigation = class {
2867
+ constructor(page, baseUrl, urlPath, fullUrl, label, actions = null, defaultOptions) {
2868
+ this.page = page;
2869
+ this.baseUrl = baseUrl;
2870
+ this.urlPath = urlPath;
2871
+ this.fullUrl = fullUrl;
2872
+ this.label = label;
2873
+ this.pageActionsToPerform = actions ?? [];
2874
+ this.defaultOptions = defaultOptions;
2875
+ }
2876
+ pageActionsToPerform;
2877
+ defaultOptions;
2878
+ resolveWaitUntil(options) {
2879
+ return options?.waitUntil ?? this.defaultOptions?.waitUntil ?? DEFAULT_WAIT_UNTIL;
2880
+ }
2881
+ resolveWaitForLoadState(options) {
2882
+ return options?.waitForLoadState ?? this.defaultOptions?.waitForLoadState ?? DEFAULT_LOAD_STATE;
2883
+ }
2884
+ async executeActions() {
2885
+ for (const action of this.pageActionsToPerform) {
2886
+ await action();
2887
+ }
2888
+ }
2889
+ /**
2890
+ * Navigate to a provided URL or URL path. If the input starts with "/", the POC's baseUrl is used as a prefix.
2891
+ * Available only when baseUrl and urlPath are strings.
2892
+ */
2893
+ async goto(urlPathOrUrl, options) {
2894
+ const waitUntil = this.resolveWaitUntil(options);
2895
+ if (typeof this.baseUrl !== "string" || typeof this.urlPath !== "string") {
2896
+ throw new Error("goto() is not supported when baseUrl or urlPath is a RegExp.");
2897
+ }
2898
+ await import_test5.test.step(`${this.label}: Navigate to the provided URL or URL Path`, async () => {
2899
+ const targetUrl = urlPathOrUrl.startsWith("/") ? `${this.baseUrl}${urlPathOrUrl}` : urlPathOrUrl;
2900
+ await this.page.goto(targetUrl, { waitUntil });
2901
+ });
2902
+ }
2903
+ /**
2904
+ * Navigate to this page's fullUrl and run any post-navigation actions.
2905
+ * Available only when fullUrl is a string.
2906
+ */
2907
+ async gotoThisPage(options) {
2908
+ if (typeof this.fullUrl !== "string") {
2909
+ throw new Error("gotoThisPage() is not supported when fullUrl is a RegExp.");
2910
+ }
2911
+ const waitUntil = this.resolveWaitUntil(options);
2912
+ const fullUrl = this.fullUrl;
2913
+ await import_test5.test.step(`${this.label}: Navigate to this Page`, async () => {
2914
+ await this.page.goto(fullUrl, { waitUntil });
2915
+ await this.executeActions();
2916
+ });
2917
+ }
2918
+ /**
2919
+ * Expect to be on this page. Works with both string and RegExp fullUrl values.
2920
+ * Uses waitUntil from navigation options when waiting for URL.
2921
+ */
2922
+ async expectThisPage(options) {
2923
+ const waitUntil = this.resolveWaitUntil(options);
2924
+ await import_test5.test.step(`${this.label}: Expect this Page`, async () => {
2925
+ await this.page.waitForURL(this.fullUrl, { waitUntil });
2926
+ await (0, import_test5.expect)(async () => {
2927
+ if (this.fullUrl instanceof RegExp) {
2928
+ (0, import_test5.expect)(this.page.url(), `expected '${this.fullUrl}', found '${this.page.url()}'`).toMatch(this.fullUrl);
2929
+ } else {
2930
+ (0, import_test5.expect)(this.page.url(), `expected '${this.fullUrl}', found '${this.page.url()}'`).toBe(this.fullUrl);
2931
+ }
2932
+ }).toPass();
2933
+ await this.executeActions();
2934
+ });
2935
+ }
2936
+ /**
2937
+ * Expect to be on any other page (i.e. not this page).
2938
+ * Uses waitForLoadState from navigation options before validating URL.
2939
+ */
2940
+ async expectAnotherPage(options) {
2941
+ const waitForLoadState = this.resolveWaitForLoadState(options);
2942
+ await import_test5.test.step(`${this.label}: Expect any other Page`, async () => {
2943
+ await this.page.waitForLoadState(waitForLoadState);
2944
+ if (this.fullUrl instanceof RegExp) {
2945
+ await import_test5.expect.poll(async () => this.page.url(), {
2946
+ message: `expected url to not match '${this.fullUrl}'`
2947
+ }).not.toMatch(this.fullUrl);
2948
+ } else {
2949
+ await import_test5.expect.poll(async () => this.page.url(), {
2950
+ message: `expected url to not be '${this.fullUrl}', found '${this.page.url()}'`
2951
+ }).not.toBe(this.fullUrl);
2952
+ }
2953
+ });
2954
+ }
2955
+ };
2956
+ function createNavigation(page, baseUrl, urlPath, fullUrl, label, actions = null, defaultOptions) {
2957
+ const navigation = new Navigation(page, baseUrl, urlPath, fullUrl, label, actions, defaultOptions);
2958
+ return navigation;
2959
+ }
2960
+
2961
+ // srcV2/helpers/sessionStorage.ts
2962
+ var import_test6 = require("@playwright/test");
2963
+ var SessionStorage2 = class {
2964
+ // Initializes the class with a Playwright Page object and an optional label for step titles.
2965
+ constructor(page, options = {}) {
2966
+ this.page = page;
2967
+ this.options = options;
2968
+ }
2969
+ // Defines an object to hold states to be set in session storage, allowing any value type.
2970
+ queuedStates = {};
2971
+ // Indicates if the session storage manipulation has been initiated.
2972
+ isInitiated = false;
2973
+ getStepLabel(methodName) {
2974
+ const prefix = this.options.label ? `${this.options.label}.` : "";
2975
+ return `${prefix}SessionStorage.${methodName}:`;
2976
+ }
2977
+ async hasContext() {
2978
+ return await this.page.evaluate(() => {
2979
+ return typeof window !== "undefined" && window.sessionStorage !== void 0;
2980
+ });
2981
+ }
2982
+ async waitForContextAvailability() {
2983
+ try {
2984
+ const contextExists = await this.hasContext();
2985
+ if (contextExists) {
2986
+ return;
2987
+ }
2988
+ } catch (_e) {
2989
+ }
2990
+ await new Promise((resolve) => {
2991
+ const handler = async (frame) => {
2992
+ if (frame !== this.page.mainFrame()) {
2993
+ return;
2994
+ }
2995
+ try {
2996
+ const contextExists = await this.hasContext();
2997
+ if (!contextExists) {
2998
+ return;
2999
+ }
3000
+ } catch (_e) {
3001
+ return;
3002
+ }
3003
+ this.page.off("framenavigated", handler);
3004
+ resolve();
3005
+ };
3006
+ this.page.on("framenavigated", handler);
3007
+ });
3008
+ }
3009
+ async ensureContext({ waitForContext = false } = {}) {
3010
+ try {
3011
+ const contextExists = await this.hasContext();
3012
+ if (contextExists) {
3013
+ return;
3014
+ }
3015
+ } catch (_e) {
3016
+ }
3017
+ if (!waitForContext) {
3018
+ throw new Error("SessionStorage context is not available.");
3019
+ }
3020
+ await this.waitForContextAvailability();
3021
+ }
3022
+ /** Writes states to session storage. Accepts an object with key-value pairs representing the states. */
3023
+ async writeToSessionStorage(states) {
3024
+ await this.page.evaluate((storage) => {
3025
+ for (const [key, value] of Object.entries(storage)) {
3026
+ window.sessionStorage.setItem(key, JSON.stringify(value));
3027
+ }
3028
+ }, states);
3029
+ }
3030
+ /** Reads all states from session storage and returns them as an object. */
3031
+ async readFromSessionStorage() {
3032
+ const storage = await this.page.evaluate(() => {
3033
+ const storage2 = {};
3034
+ for (let i = 0; i < sessionStorage.length; i++) {
3035
+ const key = sessionStorage.key(i);
3036
+ if (key !== null) {
3037
+ const item = sessionStorage.getItem(key);
3038
+ try {
3039
+ storage2[key] = item ? JSON.parse(item) : null;
3040
+ } catch (_e) {
3041
+ storage2[key] = item;
3042
+ }
3043
+ }
3044
+ }
3045
+ return storage2;
3046
+ });
3047
+ return storage;
3048
+ }
3049
+ /**
3050
+ * Sets the specified states in session storage.
3051
+ * Optionally waits for the next main-frame navigation to establish a valid context before writing,
3052
+ * and reloads the page after setting the data.
3053
+ *
3054
+ * Parameters:
3055
+ * states: Object representing the states to set in session storage.
3056
+ * reload: Boolean indicating whether to reload the page after setting the session storage data.
3057
+ * waitForContext: Boolean indicating whether to wait for a main-frame navigation and a valid context.
3058
+ */
3059
+ async set(states, options = {}) {
3060
+ await import_test6.test.step(this.getStepLabel("set"), async () => {
3061
+ await this.ensureContext({ waitForContext: options.waitForContext });
3062
+ await this.writeToSessionStorage(states);
3063
+ if (options.reload) {
3064
+ await this.page.reload();
3065
+ }
3066
+ });
3067
+ }
3068
+ /**
3069
+ * Queues states to be set in the sessionStorage before the next navigation occurs.
3070
+ * Handles different scenarios based on multiple calls made before the navigation occurs.
3071
+ *
3072
+ * 1. No Context, Single Call: Queues and sets states upon the next navigation.
3073
+ * 2. No Context, Multiple Calls: Merges states from multiple calls and sets them upon the next navigation.
3074
+ * 3. With Context: Still queues until the next navigation.
3075
+ *
3076
+ * Parameters:
3077
+ * states: Object representing the states to queue for setting in session storage.
3078
+ */
3079
+ async setOnNextNavigation(states) {
3080
+ this.queuedStates = { ...this.queuedStates, ...states };
3081
+ const populateStorage = async () => {
3082
+ await import_test6.test.step(this.getStepLabel("setOnNextNavigation"), async () => {
3083
+ await this.writeToSessionStorage(this.queuedStates);
3084
+ });
3085
+ this.queuedStates = {};
3086
+ };
3087
+ if (!this.isInitiated) {
3088
+ this.isInitiated = true;
3089
+ const handler = async (frame) => {
3090
+ if (frame !== this.page.mainFrame()) {
3091
+ return;
3092
+ }
3093
+ await populateStorage();
3094
+ this.page.off("framenavigated", handler);
3095
+ this.isInitiated = false;
3096
+ };
3097
+ this.page.on("framenavigated", handler);
3098
+ }
3099
+ }
3100
+ async get(keys, options = {}) {
3101
+ let result = {};
3102
+ await import_test6.test.step(this.getStepLabel("get"), async () => {
3103
+ await this.ensureContext(options);
3104
+ const allData = await this.readFromSessionStorage();
3105
+ if (keys && keys.length > 0) {
3106
+ for (const key of keys) {
3107
+ if (Object.hasOwn(allData, key)) {
3108
+ const value = allData[key];
3109
+ if (value !== void 0) {
3110
+ result[key] = value;
3111
+ }
3112
+ }
3113
+ }
3114
+ } else {
3115
+ result = allData;
3116
+ }
3117
+ });
3118
+ return result;
3119
+ }
3120
+ async clear(keyOrOptions, options = {}) {
3121
+ const { keys, waitForContext } = (() => {
3122
+ if (Array.isArray(keyOrOptions)) {
3123
+ return { keys: keyOrOptions, waitForContext: options.waitForContext };
3124
+ }
3125
+ if (typeof keyOrOptions === "string") {
3126
+ return { keys: [keyOrOptions], waitForContext: options.waitForContext };
3127
+ }
3128
+ if (keyOrOptions) {
3129
+ return { keys: void 0, waitForContext: keyOrOptions.waitForContext };
3130
+ }
3131
+ return { keys: void 0, waitForContext: options.waitForContext };
3132
+ })();
3133
+ await import_test6.test.step(this.getStepLabel("clear"), async () => {
3134
+ await this.ensureContext({ waitForContext });
3135
+ if (!keys || keys.length === 0) {
3136
+ await this.page.evaluate(() => sessionStorage.clear());
3137
+ return;
3138
+ }
3139
+ await this.page.evaluate((keysToClear) => {
3140
+ for (const key of keysToClear) {
3141
+ sessionStorage.removeItem(key);
3142
+ }
3143
+ }, keys);
3144
+ });
3145
+ }
3146
+ };
3147
+
3148
+ // srcV2/pageObject.ts
3149
+ var PageObject = class {
3150
+ page;
3151
+ baseUrl;
3152
+ urlPath;
3153
+ fullUrl;
3154
+ label;
3155
+ sessionStorage;
3156
+ navigation;
3157
+ locatorRegistry;
3158
+ add;
3159
+ getLocator;
3160
+ getLocatorSchema;
3161
+ getNestedLocator;
3162
+ constructor(page, baseUrl, urlPath, options) {
3163
+ this.page = page;
3164
+ this.baseUrl = baseUrl;
3165
+ this.urlPath = urlPath;
3166
+ this.fullUrl = this.composeFullUrl(baseUrl, urlPath);
3167
+ const label = options?.label ?? this.constructor.name;
3168
+ this.label = label;
3169
+ const { registry, add, getLocator, getNestedLocator, getLocatorSchema } = createRegistryWithAccessors(page);
3170
+ this.locatorRegistry = registry;
3171
+ this.add = add;
3172
+ this.getLocator = getLocator;
3173
+ this.getLocatorSchema = getLocatorSchema;
3174
+ this.getNestedLocator = getNestedLocator;
3175
+ this.sessionStorage = new SessionStorage2(page, { label });
3176
+ this.defineLocators();
3177
+ this.navigation = createNavigation(
3178
+ this.page,
3179
+ this.baseUrl,
3180
+ this.urlPath,
3181
+ this.fullUrl,
3182
+ this.label,
3183
+ this.pageActionsToPerformAfterNavigation(),
3184
+ options?.navOptions
3185
+ );
3186
+ }
3187
+ composeFullUrl(baseUrl, urlPath) {
3188
+ const escapeRegex = (value) => value.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
3189
+ if (typeof baseUrl === "string" && typeof urlPath === "string") {
3190
+ return `${baseUrl}${urlPath}`;
3191
+ }
3192
+ if (typeof baseUrl === "string" && urlPath instanceof RegExp) {
3193
+ return new RegExp(`^${escapeRegex(baseUrl)}${urlPath.source}`);
3194
+ }
3195
+ if (baseUrl instanceof RegExp && typeof urlPath === "string") {
3196
+ return new RegExp(`${baseUrl.source}${escapeRegex(urlPath)}$`);
3197
+ }
3198
+ if (baseUrl instanceof RegExp && urlPath instanceof RegExp) {
3199
+ return new RegExp(`${baseUrl.source}${urlPath.source}`);
3200
+ }
3201
+ throw new Error("Invalid baseUrl or urlPath types. Expected string or RegExp.");
3202
+ }
3203
+ };
3204
+
3205
+ // srcV2/fixture/base.fixtures.ts
3206
+ var import_test7 = require("@playwright/test");
3207
+
3208
+ // srcV2/helpers/playwrightReportLogger.ts
3209
+ var PlaywrightReportLogger = class _PlaywrightReportLogger {
3210
+ // Initializes the logger with shared log level, log entries, and a context name.
3211
+ constructor(sharedLogLevel, sharedLogEntry, contextName) {
3212
+ this.sharedLogLevel = sharedLogLevel;
3213
+ this.sharedLogEntry = sharedLogEntry;
3214
+ this.contextName = contextName;
3215
+ }
3216
+ contextName;
3217
+ logLevels = ["debug", "info", "warn", "error"];
3218
+ /**
3219
+ * Creates a child logger with a new contextual name, sharing the same log level and log entries with the parent logger.
3220
+ *
3221
+ * The root loggers log "level" is referenced by all child loggers and their child loggers and so on...
3222
+ * Changing the log "level" of one, will change it for all.
3223
+ */
3224
+ getNewChildLogger(prefix) {
3225
+ return new _PlaywrightReportLogger(this.sharedLogLevel, this.sharedLogEntry, `${this.contextName} -> ${prefix}`);
3226
+ }
3227
+ /**
3228
+ * Logs a message with the specified log level, prefix, and additional arguments if the current log level permits.
3229
+ */
3230
+ // biome-ignore lint/suspicious/noExplicitAny: logger accepts arbitrary payloads for debug output.
3231
+ log(level, message, ...args) {
3232
+ const logLevelIndex = this.logLevels.indexOf(level);
3233
+ if (logLevelIndex < this.getCurrentLogLevelIndex()) {
3234
+ return;
3235
+ }
3236
+ this.sharedLogEntry.push({
3237
+ timestamp: /* @__PURE__ */ new Date(),
3238
+ logLevel: level,
3239
+ prefix: this.contextName,
3240
+ message: `${message}
3241
+
3242
+ ${args.join("\n\n")}`
3243
+ });
3244
+ }
3245
+ /**
3246
+ * Logs a debug-level message with the specified message and arguments.
3247
+ */
3248
+ // biome-ignore lint/suspicious/noExplicitAny: logger accepts arbitrary payloads for debug output.
3249
+ debug(message, ...args) {
3250
+ this.log("debug", message, ...args);
3251
+ }
3252
+ /**
3253
+ * Logs a info-level message with the specified message and arguments.
3254
+ */
3255
+ // biome-ignore lint/suspicious/noExplicitAny: logger accepts arbitrary payloads for debug output.
3256
+ info(message, ...args) {
3257
+ this.log("info", message, ...args);
3258
+ }
3259
+ /**
3260
+ * Logs a warn-level message with the specified message and arguments.
3261
+ */
3262
+ // biome-ignore lint/suspicious/noExplicitAny: logger accepts arbitrary payloads for debug output.
3263
+ warn(message, ...args) {
3264
+ this.log("warn", message, ...args);
3265
+ }
3266
+ /**
3267
+ * Logs a error-level message with the specified message and arguments.
3268
+ */
3269
+ // biome-ignore lint/suspicious/noExplicitAny: logger accepts arbitrary payloads for debug output.
3270
+ error(message, ...args) {
1176
3271
  this.log("error", message, ...args);
1177
3272
  }
1178
3273
  /**
@@ -1251,9 +3346,9 @@ ${args.join("\n\n")}`
1251
3346
  }
1252
3347
  };
1253
3348
 
1254
- // src/fixture/base.fixtures.ts
1255
- var test3 = import_test4.test.extend({
1256
- // biome-ignore lint/correctness/noEmptyPattern: <Playwright does not support the use of _, thus we must provide an empty object {}>
3349
+ // srcV2/fixture/base.fixtures.ts
3350
+ var test5 = import_test7.test.extend({
3351
+ // biome-ignore lint/correctness/noEmptyPattern: Playwright does not support the use of _
1257
3352
  log: async ({}, use, testInfo) => {
1258
3353
  const contextName = "TestCase";
1259
3354
  const sharedLogEntry = [];
@@ -1264,25 +3359,54 @@ var test3 = import_test4.test.extend({
1264
3359
  }
1265
3360
  });
1266
3361
 
1267
- // src/api/baseApi.ts
1268
- var BaseApi = class {
1269
- baseUrl;
1270
- apiName;
1271
- log;
1272
- request;
1273
- constructor(baseUrl, apiName, context, pwrl) {
1274
- this.baseUrl = baseUrl;
1275
- this.apiName = apiName;
1276
- this.log = pwrl.getNewChildLogger(apiName);
1277
- this.request = context;
3362
+ // srcV2/helpers/stepDecorator.ts
3363
+ var import_test8 = require("@playwright/test");
3364
+ var isMethodDecoratorArgs = (args) => args.length === 3 && typeof args[0] === "object" && (typeof args[1] === "string" || typeof args[1] === "symbol");
3365
+ var isStage3MethodDecoratorArgs = (args) => args.length === 2 && typeof args[0] === "function" && args[1] !== null && typeof args[1] === "object";
3366
+ var normalizeStepArguments = (args) => {
3367
+ const [titleOrOptions, maybeOptions] = args;
3368
+ const title = typeof titleOrOptions === "string" ? titleOrOptions : void 0;
3369
+ const options = typeof titleOrOptions === "string" ? maybeOptions : titleOrOptions;
3370
+ return { title, options };
3371
+ };
3372
+ var createWrappedMethod = (original, methodName, title, options) => function(...methodArgs) {
3373
+ const rawClassName = this.constructor?.name ?? "";
3374
+ const className = rawClassName && rawClassName !== "Object" ? rawClassName : "Anonymous";
3375
+ const resolvedTitle = title ?? `${className}.${String(methodName)}`;
3376
+ return import_test8.test.step(resolvedTitle, () => original.apply(this, methodArgs), options);
3377
+ };
3378
+ var createStepDecorator = ({ title, options }) => (valueOrTarget, contextOrKey, descriptor) => {
3379
+ if (typeof valueOrTarget === "function" && isStage3MethodDecoratorArgs([valueOrTarget, contextOrKey])) {
3380
+ const [original2, context] = [valueOrTarget, contextOrKey];
3381
+ return createWrappedMethod(original2, context.name, title, options);
1278
3382
  }
3383
+ if (!descriptor || typeof descriptor.value !== "function") {
3384
+ throw new Error("@step decorator can only be applied to methods.");
3385
+ }
3386
+ const original = descriptor.value;
3387
+ descriptor.value = createWrappedMethod(original, contextOrKey, title, options);
3388
+ return descriptor;
1279
3389
  };
3390
+ function step(...args) {
3391
+ if (isStage3MethodDecoratorArgs(args)) {
3392
+ return createStepDecorator(normalizeStepArguments([]))(...args);
3393
+ }
3394
+ if (isMethodDecoratorArgs(args)) {
3395
+ return createStepDecorator(normalizeStepArguments([]))(...args);
3396
+ }
3397
+ return createStepDecorator(normalizeStepArguments(args));
3398
+ }
1280
3399
  // Annotate the CommonJS export names for ESM import in node:
1281
3400
  0 && (module.exports = {
1282
3401
  BaseApi,
1283
3402
  BasePage,
3403
+ BasePageV1toV2,
1284
3404
  GetByMethod,
1285
3405
  GetLocatorBase,
3406
+ PageObject,
1286
3407
  PlaywrightReportLogger,
3408
+ SessionStorage,
3409
+ createRegistryWithAccessors,
3410
+ step,
1287
3411
  test
1288
3412
  });