@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.
- package/README.md +26 -62
- package/dist/bind-queries.js +4 -4
- package/dist/bind-queries.js.map +1 -1
- package/dist/error-builder.d.ts +3 -3
- package/dist/error-builder.d.ts.map +1 -1
- package/dist/error-builder.js +2 -2
- package/dist/error-builder.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pretty-widget.d.ts +1 -1
- package/dist/pretty-widget.js +2 -2
- package/dist/pretty-widget.js.map +1 -1
- package/dist/queries.d.ts +14 -14
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +25 -25
- package/dist/queries.js.map +1 -1
- package/dist/render.js +1 -1
- package/dist/render.js.map +1 -1
- package/dist/screen.d.ts +4 -4
- package/dist/screen.d.ts.map +1 -1
- package/dist/screenshot.js +4 -4
- package/dist/screenshot.js.map +1 -1
- package/dist/types.d.ts +8 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/user-event.d.ts +1 -1
- package/dist/user-event.js +1 -1
- package/dist/wait-for.d.ts +1 -0
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +1 -1
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-text.d.ts +4 -4
- package/dist/widget-text.d.ts.map +1 -1
- package/dist/widget-text.js +4 -4
- package/dist/widget-text.js.map +1 -1
- package/package.json +6 -5
- package/src/bind-queries.ts +8 -8
- package/src/error-builder.ts +6 -6
- package/src/index.ts +4 -4
- package/src/pretty-widget.ts +2 -2
- package/src/queries.ts +29 -33
- package/src/render.tsx +1 -1
- package/src/screenshot.ts +4 -4
- package/src/types.ts +8 -8
- package/src/user-event.ts +1 -1
- package/src/wait-for.ts +2 -1
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
122
|
-
|
|
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
|
|
130
|
-
|
|
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
|
|
138
|
-
|
|
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
|
|
146
|
-
|
|
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
|
|
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
|
}
|
package/src/widget-text.ts
CHANGED
|
@@ -120,12 +120,12 @@ export const getWidgetAccessibleName = (widget: Gtk.Widget): string | null => {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* Gets the
|
|
123
|
+
* Gets the widget name (gtk_widget_get_name).
|
|
124
124
|
*
|
|
125
|
-
* @param widget - The widget to get the
|
|
126
|
-
* @returns The
|
|
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
|
|
128
|
+
export const getWidgetName = (widget: Gtk.Widget): string | null => {
|
|
129
129
|
return widget.getName();
|
|
130
130
|
};
|
|
131
131
|
|