@gtkx/testing 0.19.0 → 0.21.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 (48) hide show
  1. package/README.md +26 -62
  2. package/dist/bind-queries.js +4 -4
  3. package/dist/bind-queries.js.map +1 -1
  4. package/dist/error-builder.d.ts +3 -3
  5. package/dist/error-builder.d.ts.map +1 -1
  6. package/dist/error-builder.js +2 -2
  7. package/dist/error-builder.js.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/pretty-widget.d.ts +1 -1
  13. package/dist/pretty-widget.js +2 -2
  14. package/dist/pretty-widget.js.map +1 -1
  15. package/dist/queries.d.ts +14 -14
  16. package/dist/queries.d.ts.map +1 -1
  17. package/dist/queries.js +25 -25
  18. package/dist/queries.js.map +1 -1
  19. package/dist/render.js +1 -1
  20. package/dist/render.js.map +1 -1
  21. package/dist/screen.d.ts +4 -4
  22. package/dist/screen.d.ts.map +1 -1
  23. package/dist/screenshot.js +4 -4
  24. package/dist/screenshot.js.map +1 -1
  25. package/dist/types.d.ts +8 -8
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/user-event.d.ts +1 -1
  28. package/dist/user-event.js +1 -1
  29. package/dist/wait-for.d.ts +1 -0
  30. package/dist/wait-for.d.ts.map +1 -1
  31. package/dist/wait-for.js +1 -1
  32. package/dist/wait-for.js.map +1 -1
  33. package/dist/widget-text.d.ts +4 -4
  34. package/dist/widget-text.d.ts.map +1 -1
  35. package/dist/widget-text.js +4 -4
  36. package/dist/widget-text.js.map +1 -1
  37. package/package.json +6 -5
  38. package/src/bind-queries.ts +8 -8
  39. package/src/error-builder.ts +6 -6
  40. package/src/index.ts +4 -4
  41. package/src/pretty-widget.ts +2 -2
  42. package/src/queries.ts +29 -33
  43. package/src/render.tsx +1 -1
  44. package/src/screenshot.ts +4 -4
  45. package/src/types.ts +8 -8
  46. package/src/user-event.ts +1 -1
  47. package/src/wait-for.ts +2 -1
  48. package/src/widget-text.ts +4 -4
package/src/screenshot.ts CHANGED
@@ -18,7 +18,7 @@ const captureSnapshot = (widget: Gtk.Widget): ScreenshotResult => {
18
18
  const height = paintable.getIntrinsicHeight();
19
19
 
20
20
  if (width <= 0 || height <= 0) {
21
- throw new Error("Widget has no size - ensure it is realized and visible");
21
+ throw new Error("Widget has no size: ensure it is realized and visible");
22
22
  }
23
23
 
24
24
  const snapshot = new Gtk.Snapshot();
@@ -31,7 +31,7 @@ const captureSnapshot = (widget: Gtk.Widget): ScreenshotResult => {
31
31
 
32
32
  const display = widget.getDisplay();
33
33
  if (!display) {
34
- throw new Error("Widget has no display - ensure it is realized");
34
+ throw new Error("Widget has no display: ensure it is realized");
35
35
  }
36
36
 
37
37
  const renderer = new Gsk.CairoRenderer();
@@ -97,9 +97,9 @@ export const screenshot = async (widget: Gtk.Widget, options?: ScreenshotOptions
97
97
  const height = paintable.getIntrinsicHeight();
98
98
 
99
99
  if (width <= 0 || height <= 0) {
100
- return new Error("Widget has no size - ensure it is realized and visible");
100
+ return new Error("Widget has no size: ensure it is realized and visible");
101
101
  }
102
- return new Error(`Widget produced no render content after waiting for paint cycle. ${error.message}`);
102
+ return new Error(`Widget produced no render content after waiting for paint cycle: ${error.message}`);
103
103
  },
104
104
  });
105
105
  };
package/src/types.ts CHANGED
@@ -118,32 +118,32 @@ export type BoundQueries = {
118
118
  queryByLabelText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
119
119
  /** Query single element by visible text (returns null if not found) */
120
120
  queryByText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
121
- /** Query single element by test ID (returns null if not found) */
122
- queryByTestId: (testId: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
121
+ /** Query single element by widget name (returns null if not found) */
122
+ queryByName: (name: TextMatch, options?: TextMatchOptions) => Gtk.Widget | null;
123
123
  /** Query all elements by accessible role (returns empty array if none found) */
124
124
  queryAllByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Gtk.Widget[];
125
125
  /** Query all elements by label/text content (returns empty array if none found) */
126
126
  queryAllByLabelText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
127
127
  /** Query all elements by visible text (returns empty array if none found) */
128
128
  queryAllByText: (text: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
129
- /** Query all elements by test ID (returns empty array if none found) */
130
- queryAllByTestId: (testId: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
129
+ /** Query all elements by widget name (returns empty array if none found) */
130
+ queryAllByName: (name: TextMatch, options?: TextMatchOptions) => Gtk.Widget[];
131
131
  /** Find single element by accessible role (waits and throws if not found) */
132
132
  findByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Promise<Gtk.Widget>;
133
133
  /** Find single element by label/text content (waits and throws if not found) */
134
134
  findByLabelText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
135
135
  /** Find single element by visible text (waits and throws if not found) */
136
136
  findByText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
137
- /** Find single element by test ID (waits and throws if not found) */
138
- findByTestId: (testId: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
137
+ /** Find single element by widget name (waits and throws if not found) */
138
+ findByName: (name: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget>;
139
139
  /** Find all elements by accessible role (waits and throws if none found) */
140
140
  findAllByRole: (role: Gtk.AccessibleRole, options?: ByRoleOptions) => Promise<Gtk.Widget[]>;
141
141
  /** Find all elements by label/text content (waits and throws if none found) */
142
142
  findAllByLabelText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
143
143
  /** Find all elements by visible text (waits and throws if none found) */
144
144
  findAllByText: (text: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
145
- /** Find all elements by test ID (waits and throws if none found) */
146
- findAllByTestId: (testId: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
145
+ /** Find all elements by widget name (waits and throws if none found) */
146
+ findAllByName: (name: TextMatch, options?: TextMatchOptions) => Promise<Gtk.Widget[]>;
147
147
  };
148
148
 
149
149
  /**
package/src/user-event.ts CHANGED
@@ -394,7 +394,7 @@ export const userEvent = {
394
394
  /**
395
395
  * Activates a widget.
396
396
  *
397
- * Uses GTK's native {@link Gtk.Widget.activate} to trigger the widget's
397
+ * Uses GTK's native `Gtk.Widget.activate()` to trigger the widget's
398
398
  * default action — clicking buttons, toggling checkboxes/switches, etc.
399
399
  */
400
400
  click,
package/src/wait-for.ts CHANGED
@@ -46,6 +46,7 @@ export const waitFor = async <T>(callback: () => T | Promise<T>, options?: WaitF
46
46
  throw timeoutError;
47
47
  };
48
48
 
49
+ /** @internal */
49
50
  type ElementOrCallback = Gtk.Widget | (() => Gtk.Widget | null);
50
51
 
51
52
  const getElement = (elementOrCallback: ElementOrCallback): Gtk.Widget | null => {
@@ -107,7 +108,7 @@ export const waitForElementToBeRemoved = async (
107
108
  await new Promise((resolve) => setTimeout(resolve, interval));
108
109
  }
109
110
 
110
- const timeoutError = new Error(`Timed out after ${timeout}ms waiting for element to be removed.`);
111
+ const timeoutError = new Error(`Timed out after ${timeout}ms waiting for element to be removed`);
111
112
  if (onTimeout) {
112
113
  throw onTimeout(timeoutError);
113
114
  }
@@ -120,12 +120,12 @@ export const getWidgetAccessibleName = (widget: Gtk.Widget): string | null => {
120
120
  };
121
121
 
122
122
  /**
123
- * Gets the test ID from a widget (uses the widget's name property).
123
+ * Gets the widget name (gtk_widget_get_name).
124
124
  *
125
- * @param widget - The widget to get the test ID from
126
- * @returns The test ID or null if not set
125
+ * @param widget - The widget to get the name from
126
+ * @returns The widget name or null if not set
127
127
  */
128
- export const getWidgetTestId = (widget: Gtk.Widget): string | null => {
128
+ export const getWidgetName = (widget: Gtk.Widget): string | null => {
129
129
  return widget.getName();
130
130
  };
131
131