@gtkx/testing 0.1.50 → 0.1.51

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/dist/types.d.ts CHANGED
@@ -1,42 +1,87 @@
1
1
  import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type { AccessibleRole } from "@gtkx/ffi/gtk";
3
3
  import type { ComponentType, ReactNode } from "react";
4
+ /**
5
+ * Options for text matching in queries.
6
+ */
4
7
  export interface TextMatchOptions {
8
+ /** Whether to match the entire string exactly. Defaults to true. */
5
9
  exact?: boolean;
10
+ /** Custom function to normalize text before comparison. */
6
11
  normalizer?: (text: string) => string;
12
+ /** Maximum time in milliseconds to wait for a match. */
7
13
  timeout?: number;
8
14
  }
15
+ /**
16
+ * Options for querying elements by their accessible role.
17
+ */
9
18
  export interface ByRoleOptions extends TextMatchOptions {
19
+ /** Filter by the element's accessible name. */
10
20
  name?: string | RegExp;
21
+ /** Filter checkboxes/switches by checked state. */
11
22
  checked?: boolean;
23
+ /** Filter toggle buttons by pressed state. */
12
24
  pressed?: boolean;
25
+ /** Filter selectable items by selected state. */
13
26
  selected?: boolean;
27
+ /** Filter expandable elements by expanded state. */
14
28
  expanded?: boolean;
29
+ /** Filter headings by their level (1-6). */
15
30
  level?: number;
16
31
  }
32
+ /**
33
+ * Options for waitFor and related async utilities.
34
+ */
17
35
  export interface WaitForOptions {
36
+ /** Maximum time in milliseconds to wait. Defaults to 1000ms. */
18
37
  timeout?: number;
38
+ /** Interval in milliseconds between condition checks. Defaults to 50ms. */
19
39
  interval?: number;
40
+ /** Custom error handler called when timeout is reached. */
20
41
  onTimeout?: (error: Error) => Error;
21
42
  }
43
+ /**
44
+ * Options for the render function.
45
+ */
22
46
  export interface RenderOptions {
47
+ /** A React component to wrap the rendered element. Useful for providing context. */
23
48
  wrapper?: ComponentType<{
24
49
  children: ReactNode;
25
50
  }>;
26
51
  }
52
+ /**
53
+ * Query methods bound to a specific container. All queries return promises
54
+ * that resolve when a matching element is found or reject on timeout.
55
+ */
27
56
  export interface BoundQueries {
57
+ /** Find a single element by its accessible role. */
28
58
  findByRole: (role: AccessibleRole, options?: ByRoleOptions) => Promise<Gtk.Widget>;
59
+ /** Find a single element by its associated label text. */
29
60
  findByLabelText: (text: string | RegExp, options?: TextMatchOptions) => Promise<Gtk.Widget>;
61
+ /** Find a single element by its text content. */
30
62
  findByText: (text: string | RegExp, options?: TextMatchOptions) => Promise<Gtk.Widget>;
63
+ /** Find a single element by its test ID. */
31
64
  findByTestId: (testId: string | RegExp, options?: TextMatchOptions) => Promise<Gtk.Widget>;
65
+ /** Find all elements matching an accessible role. */
32
66
  findAllByRole: (role: AccessibleRole, options?: ByRoleOptions) => Promise<Gtk.Widget[]>;
67
+ /** Find all elements with matching label text. */
33
68
  findAllByLabelText: (text: string | RegExp, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
69
+ /** Find all elements with matching text content. */
34
70
  findAllByText: (text: string | RegExp, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
71
+ /** Find all elements with matching test ID. */
35
72
  findAllByTestId: (testId: string | RegExp, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
36
73
  }
74
+ /**
75
+ * The result returned by the render function. Includes query methods
76
+ * and utilities for interacting with the rendered component.
77
+ */
37
78
  export interface RenderResult extends BoundQueries {
79
+ /** The GTK Application instance containing the rendered component. */
38
80
  container: Gtk.Application;
81
+ /** Unmount the rendered component and clean up resources. */
39
82
  unmount: () => Promise<void>;
83
+ /** Re-render with a new element, preserving state where possible. */
40
84
  rerender: (element: ReactNode) => Promise<void>;
85
+ /** Print the current widget tree to the console for debugging. */
41
86
  debug: () => void;
42
87
  }
@@ -1,6 +1,9 @@
1
1
  import type * as Gtk from "@gtkx/ffi/gtk";
2
+ /**
3
+ * Options for the tab user event.
4
+ */
2
5
  export interface TabOptions {
3
- /** If true, navigates backwards (Shift+Tab behavior) */
6
+ /** If true, navigates backwards (Shift+Tab behavior). */
4
7
  shift?: boolean;
5
8
  }
6
9
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/testing",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "description": "Testing utilities for GTKX applications",
5
5
  "keywords": [
6
6
  "gtk",
@@ -32,9 +32,9 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@gtkx/react": "0.1.50",
36
- "@gtkx/ffi": "0.1.50",
37
- "@gtkx/native": "0.1.50"
35
+ "@gtkx/ffi": "0.1.51",
36
+ "@gtkx/react": "0.1.51",
37
+ "@gtkx/native": "0.1.51"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc -b && cp ../../README.md .",