@checksum-ai/runtime 1.1.13 → 1.1.14

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
@@ -6,6 +6,7 @@ import {
6
6
  PlaywrightTestOptions,
7
7
  PlaywrightWorkerArgs,
8
8
  PlaywrightWorkerOptions,
9
+ Locator,
9
10
  } from "@playwright/test";
10
11
 
11
12
  interface ChecksumAIMethod {
@@ -13,6 +14,9 @@ interface ChecksumAIMethod {
13
14
  <T>(title: string, body: () => T | Promise<T>): Promise<T>;
14
15
  }
15
16
 
17
+ type EnumValues<T> = T[keyof T];
18
+
19
+ export interface CompoundSelectorLocatorInterface extends PWLocators {}
16
20
  export interface IVariablesStore {
17
21
  [key: string]: any;
18
22
  }
@@ -20,22 +24,33 @@ export interface IVariablesStore {
20
24
  export interface IChecksumPage extends Page {
21
25
  checksumSelector: (id: string) => IChecksumPage;
22
26
  checksumAI: ChecksumAIMethod;
27
+ /**
28
+ * Will create a compound selection that selects an element by grouping multiple locators
29
+ * and find the target element from their common root parent
30
+ *
31
+ * * **Usage**
32
+ *
33
+ * ```js
34
+ * await page.compoundSelection([
35
+ * page.getByText('My first anchor'),
36
+ * page.locator('selector to second anchor')
37
+ * ]).locator("<relative selector to target element>").click();
38
+ * ```
39
+ *
40
+ * @param locators Array of locators to group and calculate the common parent
41
+ * @returns CompoundSelectorLocatorInterface - a locator that will expect a locator method to point the target element
42
+ */
43
+ compoundSelection: (locators: Locator[]) => CompoundSelectorLocatorInterface;
23
44
  resolveAssetsFolder: (assets: string[]) => string[];
24
45
  getPage(index: number): Promise<IChecksumPage>;
25
46
  reauthenticate: (role: string) => Promise<void>;
26
47
  }
27
48
 
28
- class Wrapper<ExtendedMatchers, T> {
49
+ declare class Wrapper<ExtendedMatchers, T> {
29
50
  expecter: Expect<ExtendedMatchers>;
30
- apply(e: T) {
31
- return this.expecter<T>(e);
32
- }
33
- soft(e: T) {
34
- return this.expecter.soft<T>(e);
35
- }
36
- poll(e: T) {
37
- return this.expecter.poll<T>(() => e);
38
- }
51
+ apply(e: T);
52
+ soft(e: T);
53
+ poll(e: T);
39
54
  }
40
55
 
41
56
  type Apply_MakeMatchers<ExtendedMatchers, T> = ReturnType<
@@ -223,3 +238,17 @@ export function init(base: ChecksumTestType<PlaywrightTestArgs>): {
223
238
  login: ReturnType<typeof getLogin>;
224
239
  };
225
240
  };
241
+
242
+ export enum Locators {
243
+ Locator = "locator",
244
+ GetByRole = "getByRole",
245
+ GetByText = "getByText",
246
+ GetByLabel = "getByLabel",
247
+ GetByPlaceholder = "getByPlaceholder",
248
+ GetByAltText = "getByAltText",
249
+ GetByTitle = "getByTitle",
250
+ GetByTestId = "getByTestId",
251
+ FrameLocator = "frameLocator",
252
+ }
253
+
254
+ export type PWLocators = Pick<Locator, EnumValues<typeof Locators>>;