@checksum-ai/runtime 1.1.25 → 1.1.27

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.
package/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  PlaywrightWorkerOptions,
9
9
  Locator,
10
10
  FrameLocator,
11
+ Dialog,
11
12
  } from "@playwright/test";
12
13
 
13
14
  interface ChecksumAIMethod {
@@ -17,13 +18,18 @@ interface ChecksumAIMethod {
17
18
 
18
19
  type EnumValues<T> = T[keyof T];
19
20
 
20
- export interface CompoundSelectorLocatorInterface extends PWLocators {}
21
21
  export interface IVariablesStore {
22
22
  [key: string]: any;
23
23
  }
24
24
 
25
+ type ModifyLocatorMethodToChecksumLocator<T> = {
26
+ [K in keyof T]: T[K] extends (...args: any[]) => Locator // Check if the property is a function returning Locator
27
+ ? (...args: Parameters<T[K]>) => ChecksumLocator // Change its return type to ChecksumLocator
28
+ : T[K]; // Keep the rest of the fields as they are
29
+ };
30
+
25
31
  export interface IChecksumPage
26
- extends Omit<Page, "frameLocator">,
32
+ extends Omit<ModifyLocatorMethodToChecksumLocator<Page>, "frameLocator">,
27
33
  CompoundSelectionInterface,
28
34
  FrameLocatorOwner {
29
35
  checksumSelector: (id: string) => IChecksumPage;
@@ -32,21 +38,14 @@ export interface IChecksumPage
32
38
  resolveAssetsFolder: (assets: string[]) => string[];
33
39
  getPage(index: number): Promise<IChecksumPage>;
34
40
  reauthenticate: (role: string) => Promise<void>;
35
- locator(
36
- selector: string,
37
- options?: {
38
- has?: Locator;
39
- hasNot?: Locator;
40
- hasNotText?: string | RegExp;
41
- hasText?: string | RegExp;
42
- }
43
- ): ChecksumLocator;
41
+ waitForDialog: (timeout?: number) => Promise<Dialog>;
44
42
  }
45
43
 
46
44
  export interface CompoundSelectionInterface {
47
45
  /**
48
46
  * Will create a compound selection that selects elements by grouping multiple locators as anchors
49
- * and finding the target elements from their common root parent
47
+ * and finding the target elements, if specified, from their common root parent.
48
+ * If no target is provided, the compound selection will return a locator to the common parents that were calculated from the anchors.
50
49
  *
51
50
  * **Usage example**
52
51
  *
@@ -57,21 +56,23 @@ export interface CompoundSelectionInterface {
57
56
  * ]).first().click();
58
57
  * ```
59
58
  *
60
- * @param anchors Method that returns array of locators to group and calculate the common parent from.
61
- * The method receives the base locator as an argument, which is the locator that the compound selection is called on.
59
+ * @param anchors Method that returns array of locators and/or text context, to group and calculate the common parent from.
60
+ * The method receives the base locator as an argument, which is the relative locator or page that the compound selection is called on.
62
61
  * The method should return an array of locators or strings that point at the anchor elements.
63
62
  * @param target [optional] Method that returns the relative locator or string content that will point at the target element from the common parent
64
63
  * that was calculated from the anchors.
65
- * If no target is provided, the compound selection will return a locator to the common parents.
64
+ * If no target is provided, the compound selection will return a locator pointing at the common parents.
65
+ * @returns Locator to the common parent(s) or the target element(s) if specified.
66
66
  */
67
- compoundSelection?(
67
+ compoundSelection(
68
68
  anchors: (base: Locator) => Array<Locator | string>,
69
69
  target?: (base: Locator) => Locator | string
70
- ): Locator;
70
+ ): ChecksumLocator;
71
71
 
72
72
  /**
73
73
  * Will create a compound selection that selects elements by grouping multiple locators as anchors
74
- * and finding the target elements from their common root parent.
74
+ * and finding the target elements, if specified, from their common root parent.
75
+ * If no target is provided, the compound selection will return a locator to the common parents that were calculated from the anchors.
75
76
  *
76
77
  * **Usage example**
77
78
  *
@@ -82,10 +83,12 @@ export interface CompoundSelectionInterface {
82
83
  * }).first().click();
83
84
  * ```
84
85
  * @param selection
86
+ * @returns Locator to the common parent(s) or the target element(s) if specified.
85
87
  */
86
- compoundSelection?(selection: {
88
+ compoundSelection(selection: {
87
89
  /**
88
- * Method that returns array of locators to group and calculate the common parent from.
90
+ * Method that returns array of locators and/or text context, to group and calculate the common parent from.
91
+ * The method receives the base locator as an argument, which is the relative locator or page that the compound selection is called on.
89
92
  * The method should return an array of locators or strings that point at the anchor elements.
90
93
  *
91
94
  * @param base Base locator that the compound selection is called on.
@@ -94,12 +97,12 @@ export interface CompoundSelectionInterface {
94
97
  /**
95
98
  * Method that returns the relative locator or string content that will point at the target element from the common parent
96
99
  * that was calculated from the anchors.
97
- * If the target is null, the compound selection will return a locator to the common parents.
100
+ * If the target is null, the compound selection will return a locator pointing at the common parents.
98
101
  *
99
102
  * @param base Base locator that the compound selection is called on.
100
103
  */
101
104
  target?: (base: Locator) => Locator | string;
102
- }): Locator;
105
+ }): ChecksumLocator;
103
106
  }
104
107
 
105
108
  export interface FrameLocatorOwner {
@@ -111,7 +114,7 @@ export interface ChecksumFrameLocator
111
114
  CompoundSelectionInterface {}
112
115
 
113
116
  export interface ChecksumLocator
114
- extends Omit<Locator, "frameLocator">,
117
+ extends Omit<ModifyLocatorMethodToChecksumLocator<Locator>, "frameLocator">,
115
118
  CompoundSelectionInterface,
116
119
  FrameLocatorOwner {
117
120
  canvasClick: (canvasText: string, rectSizeIndex?: number) => Promise<void>;
@@ -286,6 +289,10 @@ type ChecksumTestType<TestArgs> = TestType<
286
289
  PlaywrightWorkerArgs & PlaywrightWorkerOptions
287
290
  >;
288
291
 
292
+ export type ChecksumAI = {
293
+ (description: string, testFunction: Function): Promise<any>;
294
+ withDialog: ChecksumAI;
295
+ };
289
296
  /**
290
297
  * Initialize Checksum runtime
291
298
  *
@@ -296,7 +303,7 @@ export function init(base?: ChecksumTestType<PlaywrightTestArgs>): {
296
303
  login: ReturnType<typeof getLogin>;
297
304
  defineChecksumTest: (title: string, testId: string) => string;
298
305
  expect: IChecksumExpect;
299
- checksumAI: (description: string, testFunction: Function) => Promise<any>;
306
+ checksumAI: ChecksumAI;
300
307
  getEnvironment: ({
301
308
  name,
302
309
  userRole,
@@ -322,4 +329,4 @@ export enum Locators {
322
329
  FrameLocator = "frameLocator",
323
330
  }
324
331
 
325
- export type PWLocators = Pick<Locator, EnumValues<typeof Locators>>;
332
+ // export type PWLocators = Pick<Locator, EnumValues<typeof Locators>>;