@gtkx/testing 0.20.0 → 1.0.0-rc.1
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 +122 -55
- package/dist/act.d.ts +19 -0
- package/dist/act.d.ts.map +1 -0
- package/dist/act.js +48 -0
- package/dist/act.js.map +1 -0
- package/dist/bound-queries.d.ts +32 -0
- package/dist/bound-queries.d.ts.map +1 -0
- package/dist/bound-queries.js +2 -0
- package/dist/bound-queries.js.map +1 -0
- package/dist/build-queries.d.ts +16 -0
- package/dist/build-queries.d.ts.map +1 -0
- package/dist/build-queries.js +103 -0
- package/dist/build-queries.js.map +1 -0
- package/dist/cleanup-registry.d.ts +4 -0
- package/dist/cleanup-registry.d.ts.map +1 -0
- package/dist/cleanup-registry.js +11 -0
- package/dist/cleanup-registry.js.map +1 -0
- package/dist/config.d.ts +18 -51
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -40
- package/dist/config.js.map +1 -1
- package/dist/editable.d.ts +7 -0
- package/dist/editable.d.ts.map +1 -0
- package/dist/editable.js +24 -0
- package/dist/editable.js.map +1 -0
- package/dist/errors.d.ts +29 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +119 -0
- package/dist/errors.js.map +1 -0
- package/dist/fire-event.d.ts +7 -25
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +9 -29
- package/dist/fire-event.js.map +1 -1
- package/dist/frame-sync.d.ts +3 -0
- package/dist/frame-sync.d.ts.map +1 -0
- package/dist/frame-sync.js +30 -0
- package/dist/frame-sync.js.map +1 -0
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/matchers.d.ts +55 -0
- package/dist/matchers.d.ts.map +1 -0
- package/dist/matchers.js +103 -0
- package/dist/matchers.js.map +1 -0
- package/dist/pretty-widget.d.ts +21 -25
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +69 -115
- package/dist/pretty-widget.js.map +1 -1
- package/dist/queries.d.ts +130 -177
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +212 -325
- package/dist/queries.js.map +1 -1
- package/dist/register-test-hooks.d.ts +2 -0
- package/dist/register-test-hooks.d.ts.map +1 -0
- package/dist/register-test-hooks.js +15 -0
- package/dist/register-test-hooks.js.map +1 -0
- package/dist/render-hook.d.ts +14 -35
- package/dist/render-hook.d.ts.map +1 -1
- package/dist/render-hook.js +8 -45
- package/dist/render-hook.js.map +1 -1
- package/dist/render.d.ts +11 -41
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +129 -118
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +16 -51
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +39 -58
- package/dist/role-helpers.js.map +1 -1
- package/dist/screen.d.ts +6 -63
- package/dist/screen.d.ts.map +1 -1
- package/dist/screen.js +21 -109
- package/dist/screen.js.map +1 -1
- package/dist/screenshot.d.ts +20 -23
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +89 -48
- package/dist/screenshot.js.map +1 -1
- package/dist/suggestions.d.ts +22 -0
- package/dist/suggestions.d.ts.map +1 -0
- package/dist/suggestions.js +56 -0
- package/dist/suggestions.js.map +1 -0
- package/dist/traversal.d.ts +10 -8
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +28 -13
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +103 -172
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +8 -0
- package/dist/user-event/adjustment.d.ts.map +1 -0
- package/dist/user-event/adjustment.js +33 -0
- package/dist/user-event/adjustment.js.map +1 -0
- package/dist/user-event/click.d.ts +7 -0
- package/dist/user-event/click.d.ts.map +1 -0
- package/dist/user-event/click.js +65 -0
- package/dist/user-event/click.js.map +1 -0
- package/dist/user-event/controller.d.ts +7 -0
- package/dist/user-event/controller.d.ts.map +1 -0
- package/dist/user-event/controller.js +28 -0
- package/dist/user-event/controller.js.map +1 -0
- package/dist/user-event/dispatch.d.ts +7 -0
- package/dist/user-event/dispatch.d.ts.map +1 -0
- package/dist/user-event/dispatch.js +10 -0
- package/dist/user-event/dispatch.js.map +1 -0
- package/dist/user-event/event-wrapper.d.ts +3 -0
- package/dist/user-event/event-wrapper.d.ts.map +1 -0
- package/dist/user-event/event-wrapper.js +48 -0
- package/dist/user-event/event-wrapper.js.map +1 -0
- package/dist/user-event/gesture.d.ts +31 -0
- package/dist/user-event/gesture.d.ts.map +1 -0
- package/dist/user-event/gesture.js +105 -0
- package/dist/user-event/gesture.js.map +1 -0
- package/dist/user-event/index.d.ts +44 -0
- package/dist/user-event/index.d.ts.map +1 -0
- package/dist/user-event/index.js +38 -0
- package/dist/user-event/index.js.map +1 -0
- package/dist/user-event/keyboard.d.ts +9 -0
- package/dist/user-event/keyboard.d.ts.map +1 -0
- package/dist/user-event/keyboard.js +173 -0
- package/dist/user-event/keyboard.js.map +1 -0
- package/dist/user-event/pointer.d.ts +6 -0
- package/dist/user-event/pointer.d.ts.map +1 -0
- package/dist/user-event/pointer.js +27 -0
- package/dist/user-event/pointer.js.map +1 -0
- package/dist/user-event/selection.d.ts +4 -0
- package/dist/user-event/selection.d.ts.map +1 -0
- package/dist/user-event/selection.js +106 -0
- package/dist/user-event/selection.js.map +1 -0
- package/dist/user-event/state.d.ts +6 -0
- package/dist/user-event/state.d.ts.map +1 -0
- package/dist/user-event/state.js +2 -0
- package/dist/user-event/state.js.map +1 -0
- package/dist/user-event/text.d.ts +17 -0
- package/dist/user-event/text.d.ts.map +1 -0
- package/dist/user-event/text.js +107 -0
- package/dist/user-event/text.js.map +1 -0
- package/dist/wait-for.d.ts +13 -32
- package/dist/wait-for.d.ts.map +1 -1
- package/dist/wait-for.js +62 -73
- package/dist/wait-for.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +33 -0
- package/dist/widget-accessible-properties.d.ts.map +1 -0
- package/dist/widget-accessible-properties.js +215 -0
- package/dist/widget-accessible-properties.js.map +1 -0
- package/dist/within.d.ts +9 -26
- package/dist/within.d.ts.map +1 -1
- package/dist/within.js +15 -25
- package/dist/within.js.map +1 -1
- package/package.json +21 -12
- package/src/act.ts +68 -0
- package/src/bound-queries.ts +36 -0
- package/src/build-queries.ts +185 -0
- package/src/cleanup-registry.ts +14 -0
- package/src/config.ts +28 -59
- package/src/editable.ts +30 -0
- package/src/errors.ts +130 -0
- package/src/fire-event.ts +11 -38
- package/src/frame-sync.ts +34 -0
- package/src/index.ts +60 -18
- package/src/matchers.ts +200 -0
- package/src/pretty-widget.ts +99 -138
- package/src/queries.ts +321 -425
- package/src/register-test-hooks.ts +16 -0
- package/src/render-hook.tsx +31 -44
- package/src/render.tsx +161 -149
- package/src/role-helpers.ts +47 -67
- package/src/screen.ts +21 -114
- package/src/screenshot.ts +104 -55
- package/src/suggestions.ts +87 -0
- package/src/traversal.ts +32 -18
- package/src/types.ts +115 -176
- package/src/user-event/adjustment.ts +49 -0
- package/src/user-event/click.ts +70 -0
- package/src/user-event/controller.ts +44 -0
- package/src/user-event/dispatch.ts +23 -0
- package/src/user-event/event-wrapper.ts +54 -0
- package/src/user-event/gesture.ts +154 -0
- package/src/user-event/index.ts +74 -0
- package/src/user-event/keyboard.ts +204 -0
- package/src/user-event/pointer.ts +34 -0
- package/src/user-event/selection.ts +122 -0
- package/src/user-event/state.ts +6 -0
- package/src/user-event/text.ts +137 -0
- package/src/wait-for.ts +79 -80
- package/src/widget-accessible-properties.ts +244 -0
- package/src/within.ts +26 -27
- package/dist/bind-queries.d.ts +0 -14
- package/dist/bind-queries.d.ts.map +0 -1
- package/dist/bind-queries.js +0 -29
- package/dist/bind-queries.js.map +0 -1
- package/dist/error-builder.d.ts +0 -28
- package/dist/error-builder.d.ts.map +0 -1
- package/dist/error-builder.js +0 -81
- package/dist/error-builder.js.map +0 -1
- package/dist/timing.d.ts +0 -18
- package/dist/timing.d.ts.map +0 -1
- package/dist/timing.js +0 -18
- package/dist/timing.js.map +0 -1
- package/dist/user-event.d.ts +0 -138
- package/dist/user-event.d.ts.map +0 -1
- package/dist/user-event.js +0 -411
- package/dist/user-event.js.map +0 -1
- package/dist/widget-text.d.ts +0 -69
- package/dist/widget-text.d.ts.map +0 -1
- package/dist/widget-text.js +0 -177
- package/dist/widget-text.js.map +0 -1
- package/dist/widget.d.ts +0 -3
- package/dist/widget.d.ts.map +0 -1
- package/dist/widget.js +0 -13
- package/dist/widget.js.map +0 -1
- package/src/bind-queries.ts +0 -52
- package/src/error-builder.ts +0 -102
- package/src/timing.ts +0 -17
- package/src/user-event.ts +0 -492
- package/src/widget-text.ts +0 -202
- package/src/widget.ts +0 -15
package/src/queries.ts
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import * as Gtk from "@gtkx/
|
|
2
|
-
import {
|
|
1
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import { type BuiltQueries, buildQueries, type QueryAllBy } from "./build-queries.js";
|
|
3
|
+
import { multipleFoundError, notFoundError } from "./errors.js";
|
|
3
4
|
import { type Container, findAll, traverse } from "./traversal.js";
|
|
4
|
-
import type { ByRoleOptions,
|
|
5
|
-
import { waitFor } from "./wait-for.js";
|
|
5
|
+
import type { ByRoleOptions, ByRoleValue, Matcher, MatcherOptions, NormalizerFn, NormalizerOptions } from "./types.js";
|
|
6
6
|
import {
|
|
7
7
|
getWidgetAccessibleName,
|
|
8
|
+
getWidgetBusyState,
|
|
8
9
|
getWidgetCheckedState,
|
|
10
|
+
getWidgetDescription,
|
|
11
|
+
getWidgetDisplayValue,
|
|
9
12
|
getWidgetExpandedState,
|
|
13
|
+
getWidgetLabelledByText,
|
|
14
|
+
getWidgetLabelText,
|
|
15
|
+
getWidgetLevel,
|
|
16
|
+
getWidgetName,
|
|
17
|
+
getWidgetOwnLabel,
|
|
18
|
+
getWidgetPlaceholderText,
|
|
10
19
|
getWidgetPressedState,
|
|
11
20
|
getWidgetSelectedState,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./widget-
|
|
15
|
-
|
|
16
|
-
const buildNormalizer = (options?: TextMatchOptions): ((text: string) => string) => {
|
|
17
|
-
if (options?.normalizer) {
|
|
18
|
-
return options.normalizer;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const trim = options?.trim ?? true;
|
|
22
|
-
const collapseWhitespace = options?.collapseWhitespace ?? true;
|
|
21
|
+
getWidgetValue,
|
|
22
|
+
isInaccessible,
|
|
23
|
+
} from "./widget-accessible-properties.js";
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Builds the default text normalizer, which optionally trims surrounding whitespace and collapses runs of whitespace into single spaces.
|
|
27
|
+
* @param options Toggles for trimming and whitespace collapsing.
|
|
28
|
+
* @returns A function that normalizes a string for comparison against a matcher.
|
|
29
|
+
*/
|
|
30
|
+
export const getDefaultNormalizer = ({
|
|
31
|
+
trim = true,
|
|
32
|
+
collapseWhitespace = true,
|
|
33
|
+
}: NormalizerOptions = {}): NormalizerFn => {
|
|
24
34
|
return (text: string): string => {
|
|
25
35
|
let result = text;
|
|
26
36
|
if (trim) {
|
|
@@ -28,24 +38,37 @@ const buildNormalizer = (options?: TextMatchOptions): ((text: string) => string)
|
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
if (collapseWhitespace) {
|
|
31
|
-
result = result.
|
|
41
|
+
result = result.replaceAll(/\s+/g, " ");
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
return result;
|
|
35
45
|
};
|
|
36
46
|
};
|
|
37
47
|
|
|
38
|
-
const
|
|
48
|
+
const buildNormalizer = (options?: MatcherOptions): NormalizerFn => {
|
|
49
|
+
const { normalizer, trim, collapseWhitespace } = options ?? {};
|
|
50
|
+
|
|
51
|
+
if (!normalizer) {
|
|
52
|
+
return getDefaultNormalizer({ trim, collapseWhitespace });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (trim !== undefined || collapseWhitespace !== undefined) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"trim and collapseWhitespace are not supported with a normalizer. " +
|
|
58
|
+
"If you want to use the default trim and collapseWhitespace logic in your normalizer, " +
|
|
59
|
+
'use "getDefaultNormalizer({ trim, collapseWhitespace })" and compose that into your normalizer',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return normalizer;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const normalizeText = (text: string, options?: MatcherOptions): string => {
|
|
39
67
|
const normalizer = buildNormalizer(options);
|
|
40
68
|
return normalizer(text);
|
|
41
69
|
};
|
|
42
70
|
|
|
43
|
-
const matchText = (
|
|
44
|
-
actual: string | null,
|
|
45
|
-
expected: TextMatch,
|
|
46
|
-
widget: Gtk.Widget,
|
|
47
|
-
options?: TextMatchOptions,
|
|
48
|
-
): boolean => {
|
|
71
|
+
const matchText = (actual: string | null, expected: Matcher, widget: Gtk.Widget, options?: MatcherOptions): boolean => {
|
|
49
72
|
if (actual === null) return false;
|
|
50
73
|
|
|
51
74
|
const normalizedActual = normalizeText(actual, options);
|
|
@@ -59,453 +82,326 @@ const matchText = (
|
|
|
59
82
|
return expected.test(normalizedActual);
|
|
60
83
|
}
|
|
61
84
|
|
|
62
|
-
const normalizedExpected = normalizeText(expected, options);
|
|
85
|
+
const normalizedExpected = normalizeText(String(expected), options);
|
|
63
86
|
const exact = options?.exact ?? true;
|
|
64
87
|
return exact
|
|
65
88
|
? normalizedActual === normalizedExpected
|
|
66
89
|
: normalizedActual.toLowerCase().includes(normalizedExpected.toLowerCase());
|
|
67
90
|
};
|
|
68
91
|
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const text = getWidgetAccessibleName(widget);
|
|
74
|
-
if (!matchText(text, options.name, widget, options)) return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (options.checked !== undefined) {
|
|
78
|
-
const checked = getWidgetCheckedState(widget);
|
|
79
|
-
if (checked !== options.checked) return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (options.pressed !== undefined) {
|
|
83
|
-
const pressed = getWidgetPressedState(widget);
|
|
84
|
-
if (pressed !== options.pressed) return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (options.expanded !== undefined) {
|
|
88
|
-
const expanded = getWidgetExpandedState(widget);
|
|
89
|
-
if (expanded !== options.expanded) return false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (options.selected !== undefined) {
|
|
93
|
-
const selected = getWidgetSelectedState(widget);
|
|
94
|
-
if (selected !== options.selected) return false;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return true;
|
|
92
|
+
const matchAccessibleName = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {
|
|
93
|
+
if (options.name === undefined) return true;
|
|
94
|
+
const text = getWidgetAccessibleName(widget);
|
|
95
|
+
return matchText(text, options.name, widget, options);
|
|
98
96
|
};
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
*/
|
|
108
|
-
export const queryAllByRole = (
|
|
109
|
-
container: Container,
|
|
110
|
-
role: Gtk.AccessibleRole,
|
|
111
|
-
options?: ByRoleOptions,
|
|
112
|
-
): Gtk.Widget[] => {
|
|
113
|
-
return findAll(container, (node) => {
|
|
114
|
-
if (node.getAccessibleRole() !== role) return false;
|
|
115
|
-
return matchByRoleOptions(node, options);
|
|
116
|
-
});
|
|
98
|
+
const matchAccessibleValue = (widget: Gtk.Widget, value: ByRoleValue, options: ByRoleOptions): boolean => {
|
|
99
|
+
const actual = getWidgetValue(widget);
|
|
100
|
+
if (value.now !== undefined && actual.now !== value.now) return false;
|
|
101
|
+
if (value.min !== undefined && actual.min !== value.min) return false;
|
|
102
|
+
if (value.max !== undefined && actual.max !== value.max) return false;
|
|
103
|
+
if (value.text !== undefined && !matchText(actual.text, value.text, widget, options)) return false;
|
|
104
|
+
return true;
|
|
117
105
|
};
|
|
118
106
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* @throws Error if multiple elements match
|
|
127
|
-
*/
|
|
128
|
-
export const queryByRole = (
|
|
129
|
-
container: Container,
|
|
130
|
-
role: Gtk.AccessibleRole,
|
|
131
|
-
options?: ByRoleOptions,
|
|
132
|
-
): Gtk.Widget | null => {
|
|
133
|
-
const matches = queryAllByRole(container, role, options);
|
|
134
|
-
|
|
135
|
-
if (matches.length > 1) {
|
|
136
|
-
throw buildMultipleFoundError(container, "role", { role, options }, matches.length);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return matches[0] ?? null;
|
|
107
|
+
const matchBooleanStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {
|
|
108
|
+
if (options.checked !== undefined && getWidgetCheckedState(widget) !== options.checked) return false;
|
|
109
|
+
if (options.pressed !== undefined && getWidgetPressedState(widget) !== options.pressed) return false;
|
|
110
|
+
if (options.expanded !== undefined && getWidgetExpandedState(widget) !== options.expanded) return false;
|
|
111
|
+
if (options.selected !== undefined && getWidgetSelectedState(widget) !== options.selected) return false;
|
|
112
|
+
if (options.busy !== undefined && (getWidgetBusyState(widget) ?? false) !== options.busy) return false;
|
|
113
|
+
return true;
|
|
140
114
|
};
|
|
141
115
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
* @returns Array of labelled widgets (empty if none found)
|
|
153
|
-
*/
|
|
154
|
-
export const queryAllByLabelText = (
|
|
155
|
-
container: Container,
|
|
156
|
-
text: TextMatch,
|
|
157
|
-
options?: TextMatchOptions,
|
|
158
|
-
): Gtk.Widget[] => {
|
|
159
|
-
const results: Gtk.Widget[] = [];
|
|
160
|
-
|
|
161
|
-
for (const node of traverse(container)) {
|
|
162
|
-
if (!(node instanceof Gtk.Label)) continue;
|
|
163
|
-
|
|
164
|
-
const labelText = node.getLabel();
|
|
165
|
-
if (!labelText) continue;
|
|
166
|
-
if (!matchText(labelText, text, node, options)) continue;
|
|
167
|
-
|
|
168
|
-
const target = node.getMnemonicWidget();
|
|
169
|
-
if (target) {
|
|
170
|
-
results.push(target);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return results;
|
|
116
|
+
const matchAccessibleStates = (widget: Gtk.Widget, options: ByRoleOptions): boolean => {
|
|
117
|
+
if (!matchBooleanStates(widget, options)) return false;
|
|
118
|
+
if (options.level !== undefined && getWidgetLevel(widget) !== options.level) return false;
|
|
119
|
+
if (
|
|
120
|
+
options.description !== undefined &&
|
|
121
|
+
!matchText(getWidgetDescription(widget), options.description, widget, options)
|
|
122
|
+
)
|
|
123
|
+
return false;
|
|
124
|
+
if (options.value !== undefined && !matchAccessibleValue(widget, options.value, options)) return false;
|
|
125
|
+
return true;
|
|
175
126
|
};
|
|
176
127
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
* @param container - The container to search within
|
|
181
|
-
* @param text - Text to match (string, RegExp, or custom matcher)
|
|
182
|
-
* @param options - Query options including normalization
|
|
183
|
-
* @returns The matching widget or null if not found
|
|
184
|
-
* @throws Error if multiple elements match
|
|
185
|
-
*/
|
|
186
|
-
export const queryByLabelText = (
|
|
187
|
-
container: Container,
|
|
188
|
-
text: TextMatch,
|
|
189
|
-
options?: TextMatchOptions,
|
|
190
|
-
): Gtk.Widget | null => {
|
|
191
|
-
const matches = queryAllByLabelText(container, text, options);
|
|
192
|
-
|
|
193
|
-
if (matches.length > 1) {
|
|
194
|
-
throw buildMultipleFoundError(container, "labelText", { text, options }, matches.length);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return matches[0] ?? null;
|
|
128
|
+
const matchByRoleOptions = (widget: Gtk.Widget, options?: ByRoleOptions): boolean => {
|
|
129
|
+
if (!options) return true;
|
|
130
|
+
return matchAccessibleName(widget, options) && matchAccessibleStates(widget, options);
|
|
198
131
|
};
|
|
199
132
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
})
|
|
133
|
+
type NamedFamily<Suffix extends string, Args extends unknown[]> = {
|
|
134
|
+
[P in `queryBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget | null;
|
|
135
|
+
} & {
|
|
136
|
+
[P in `queryAllBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget[];
|
|
137
|
+
} & {
|
|
138
|
+
[P in `getBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget;
|
|
139
|
+
} & {
|
|
140
|
+
[P in `getAllBy${Suffix}`]: (container: Container, ...args: Args) => Gtk.Widget[];
|
|
141
|
+
} & {
|
|
142
|
+
[P in `findBy${Suffix}`]: (container: Container, ...args: Args) => Promise<Gtk.Widget>;
|
|
143
|
+
} & {
|
|
144
|
+
[P in `findAllBy${Suffix}`]: (container: Container, ...args: Args) => Promise<Gtk.Widget[]>;
|
|
212
145
|
};
|
|
213
146
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return matches[0] ?? null;
|
|
147
|
+
const nameQueryFamily = <Suffix extends string, Args extends unknown[]>(
|
|
148
|
+
suffix: Suffix,
|
|
149
|
+
queryAllBy: QueryAllBy<Args>,
|
|
150
|
+
built: BuiltQueries<Args>,
|
|
151
|
+
): NamedFamily<Suffix, Args> => {
|
|
152
|
+
const family = {
|
|
153
|
+
[`queryBy${suffix}`]: built.queryBy,
|
|
154
|
+
[`queryAllBy${suffix}`]: queryAllBy,
|
|
155
|
+
[`getBy${suffix}`]: built.getBy,
|
|
156
|
+
[`getAllBy${suffix}`]: built.getAllBy,
|
|
157
|
+
[`findBy${suffix}`]: built.findBy,
|
|
158
|
+
[`findAllBy${suffix}`]: built.findAllBy,
|
|
159
|
+
};
|
|
160
|
+
return family as NamedFamily<Suffix, Args>;
|
|
231
161
|
};
|
|
232
162
|
|
|
233
163
|
/**
|
|
234
|
-
* Finds
|
|
235
|
-
*
|
|
236
|
-
* @param container
|
|
237
|
-
* @param
|
|
238
|
-
* @param options
|
|
239
|
-
* @returns
|
|
164
|
+
* Finds every widget under the container whose accessible role matches `role` and that satisfies the given options.
|
|
165
|
+
* Widgets excluded from the accessibility tree are skipped unless `options.hidden` is set.
|
|
166
|
+
* @param container Widget subtree to search.
|
|
167
|
+
* @param role Accessible role to match.
|
|
168
|
+
* @param options Additional accessible name, state, and value constraints.
|
|
169
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
240
170
|
*/
|
|
241
|
-
export const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
171
|
+
export const queryAllByRole = (container: Container, role: Gtk.AccessibleRole, options?: ByRoleOptions): Gtk.Widget[] =>
|
|
172
|
+
findAll(container, (widget) => {
|
|
173
|
+
if (widget.getAccessibleRole() !== role) return false;
|
|
174
|
+
if (!options?.hidden && isInaccessible(widget)) return false;
|
|
175
|
+
return matchByRoleOptions(widget, options);
|
|
245
176
|
});
|
|
246
|
-
};
|
|
247
177
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
178
|
+
const roleQueries = nameQueryFamily(
|
|
179
|
+
"Role",
|
|
180
|
+
queryAllByRole,
|
|
181
|
+
buildQueries<[role: Gtk.AccessibleRole, options?: ByRoleOptions]>(
|
|
182
|
+
"Role",
|
|
183
|
+
queryAllByRole,
|
|
184
|
+
(container, matches, role, options) =>
|
|
185
|
+
multipleFoundError(container, { queryType: "role", role, options }, matches),
|
|
186
|
+
(container, role, options) => notFoundError(container, { queryType: "role", role, options }),
|
|
187
|
+
),
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const collectMnemonicMatch = (
|
|
191
|
+
widget: Gtk.Widget,
|
|
192
|
+
text: Matcher,
|
|
193
|
+
options: MatcherOptions | undefined,
|
|
261
194
|
): Gtk.Widget | null => {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return matches[0] ?? null;
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const getAllByRole = (container: Container, role: Gtk.AccessibleRole, options?: ByRoleOptions): Gtk.Widget[] => {
|
|
272
|
-
const matches = queryAllByRole(container, role, options);
|
|
273
|
-
|
|
274
|
-
if (matches.length === 0) {
|
|
275
|
-
throw buildNotFoundError(container, "role", { role, options });
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return matches;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
const getByRole = (container: Container, role: Gtk.AccessibleRole, options?: ByRoleOptions): Gtk.Widget => {
|
|
282
|
-
const matches = getAllByRole(container, role, options);
|
|
283
|
-
|
|
284
|
-
if (matches.length > 1) {
|
|
285
|
-
throw buildMultipleFoundError(container, "role", { role, options }, matches.length);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return matches[0] as Gtk.Widget;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
const getAllByLabelText = (container: Container, text: TextMatch, options?: TextMatchOptions): Gtk.Widget[] => {
|
|
292
|
-
const matches = queryAllByLabelText(container, text, options);
|
|
293
|
-
|
|
294
|
-
if (matches.length === 0) {
|
|
295
|
-
throw buildNotFoundError(container, "labelText", { text, options });
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return matches;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
const getByLabelText = (container: Container, text: TextMatch, options?: TextMatchOptions): Gtk.Widget => {
|
|
302
|
-
const matches = getAllByLabelText(container, text, options);
|
|
303
|
-
|
|
304
|
-
if (matches.length > 1) {
|
|
305
|
-
throw buildMultipleFoundError(container, "labelText", { text, options }, matches.length);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return matches[0] as Gtk.Widget;
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
const getAllByText = (container: Container, text: TextMatch, options?: TextMatchOptions): Gtk.Widget[] => {
|
|
312
|
-
const matches = queryAllByText(container, text, options);
|
|
313
|
-
|
|
314
|
-
if (matches.length === 0) {
|
|
315
|
-
throw buildNotFoundError(container, "text", { text, options });
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return matches;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const getByText = (container: Container, text: TextMatch, options?: TextMatchOptions): Gtk.Widget => {
|
|
322
|
-
const matches = getAllByText(container, text, options);
|
|
323
|
-
|
|
324
|
-
if (matches.length > 1) {
|
|
325
|
-
throw buildMultipleFoundError(container, "text", { text, options }, matches.length);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return matches[0] as Gtk.Widget;
|
|
195
|
+
if (!(widget instanceof Gtk.Label)) return null;
|
|
196
|
+
const labelText = widget.getLabel();
|
|
197
|
+
if (!labelText || !matchText(labelText, text, widget, options)) return null;
|
|
198
|
+
return widget.getMnemonicWidget();
|
|
329
199
|
};
|
|
330
200
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the widget's own accessible label, or its labelled-by relation.
|
|
203
|
+
* @param container Widget subtree to search.
|
|
204
|
+
* @param text Matcher for the label text.
|
|
205
|
+
* @param options Text matching options.
|
|
206
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
207
|
+
*/
|
|
208
|
+
export const queryAllByLabelText = (container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] => {
|
|
209
|
+
const results = new Set<Gtk.Widget>();
|
|
337
210
|
|
|
338
|
-
|
|
339
|
-
|
|
211
|
+
for (const widget of traverse(container)) {
|
|
212
|
+
const mnemonicTarget = collectMnemonicMatch(widget, text, options);
|
|
213
|
+
if (mnemonicTarget) results.add(mnemonicTarget);
|
|
340
214
|
|
|
341
|
-
const
|
|
342
|
-
|
|
215
|
+
const ownLabel = getWidgetOwnLabel(widget);
|
|
216
|
+
if (ownLabel !== null && matchText(ownLabel, text, widget, options)) results.add(widget);
|
|
343
217
|
|
|
344
|
-
|
|
345
|
-
|
|
218
|
+
const labelledByText = getWidgetLabelledByText(widget);
|
|
219
|
+
if (labelledByText !== null && matchText(labelledByText, text, widget, options)) results.add(widget);
|
|
346
220
|
}
|
|
347
221
|
|
|
348
|
-
return
|
|
222
|
+
return [...results];
|
|
349
223
|
};
|
|
350
224
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
* @example
|
|
362
|
-
* ```tsx
|
|
363
|
-
* const button = await findByRole(container, Gtk.AccessibleRole.BUTTON, { name: "Submit" });
|
|
364
|
-
* ```
|
|
365
|
-
*/
|
|
366
|
-
export const findByRole = async (
|
|
367
|
-
container: Container,
|
|
368
|
-
role: Gtk.AccessibleRole,
|
|
369
|
-
options?: ByRoleOptions,
|
|
370
|
-
): Promise<Gtk.Widget> =>
|
|
371
|
-
waitFor(() => getByRole(container, role, options), {
|
|
372
|
-
timeout: options?.timeout,
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Finds all elements matching an accessible role.
|
|
377
|
-
*
|
|
378
|
-
* @param container - The container to search within
|
|
379
|
-
* @param role - The GTK accessible role to match
|
|
380
|
-
* @param options - Query options including name, state filters, and timeout
|
|
381
|
-
* @returns Promise resolving to array of matching widgets
|
|
382
|
-
*/
|
|
383
|
-
export const findAllByRole = async (
|
|
384
|
-
container: Container,
|
|
385
|
-
role: Gtk.AccessibleRole,
|
|
386
|
-
options?: ByRoleOptions,
|
|
387
|
-
): Promise<Gtk.Widget[]> =>
|
|
388
|
-
waitFor(() => getAllByRole(container, role, options), {
|
|
389
|
-
timeout: options?.timeout,
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Finds a single element that is labelled by a GtkLabel whose text matches.
|
|
394
|
-
*
|
|
395
|
-
* Waits for the element to appear, throwing if not found within timeout.
|
|
396
|
-
* Uses GtkLabel's mnemonic widget association to find form elements.
|
|
397
|
-
*
|
|
398
|
-
* @param container - The container to search within
|
|
399
|
-
* @param text - Label text to match (string, RegExp, or custom matcher)
|
|
400
|
-
* @param options - Query options including normalization and timeout
|
|
401
|
-
* @returns Promise resolving to the labelled widget
|
|
402
|
-
*
|
|
403
|
-
* @example
|
|
404
|
-
* ```tsx
|
|
405
|
-
* const input = await findByLabelText(container, "Username");
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
export const findByLabelText = async (
|
|
409
|
-
container: Container,
|
|
410
|
-
text: TextMatch,
|
|
411
|
-
options?: TextMatchOptions,
|
|
412
|
-
): Promise<Gtk.Widget> =>
|
|
413
|
-
waitFor(() => getByLabelText(container, text, options), {
|
|
414
|
-
timeout: options?.timeout,
|
|
415
|
-
});
|
|
225
|
+
const labelTextQueries = nameQueryFamily(
|
|
226
|
+
"LabelText",
|
|
227
|
+
queryAllByLabelText,
|
|
228
|
+
buildQueries<[text: Matcher, options?: MatcherOptions]>(
|
|
229
|
+
"LabelText",
|
|
230
|
+
queryAllByLabelText,
|
|
231
|
+
(container, matches, text) => multipleFoundError(container, { queryType: "labelText", text }, matches),
|
|
232
|
+
(container, text) => notFoundError(container, { queryType: "labelText", text }),
|
|
233
|
+
),
|
|
234
|
+
);
|
|
416
235
|
|
|
417
236
|
/**
|
|
418
|
-
* Finds
|
|
419
|
-
*
|
|
420
|
-
* @param
|
|
421
|
-
* @param
|
|
422
|
-
* @
|
|
423
|
-
* @returns Promise resolving to array of matching widgets
|
|
237
|
+
* Finds every widget whose rendered text content matches.
|
|
238
|
+
* @param container Widget subtree to search.
|
|
239
|
+
* @param text Matcher for the widget text.
|
|
240
|
+
* @param options Text matching options.
|
|
241
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
424
242
|
*/
|
|
425
|
-
export const
|
|
426
|
-
container
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
243
|
+
export const queryAllByText = (container: Container, text: Matcher, options?: MatcherOptions): Gtk.Widget[] =>
|
|
244
|
+
findAll(container, (widget) => matchText(getWidgetLabelText(widget), text, widget, options));
|
|
245
|
+
|
|
246
|
+
const textQueries = nameQueryFamily(
|
|
247
|
+
"Text",
|
|
248
|
+
queryAllByText,
|
|
249
|
+
buildQueries<[text: Matcher, options?: MatcherOptions]>(
|
|
250
|
+
"Text",
|
|
251
|
+
queryAllByText,
|
|
252
|
+
(container, matches, text) => multipleFoundError(container, { queryType: "text", text }, matches),
|
|
253
|
+
(container, text) => notFoundError(container, { queryType: "text", text }),
|
|
254
|
+
),
|
|
255
|
+
);
|
|
433
256
|
|
|
434
257
|
/**
|
|
435
|
-
* Finds
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* @
|
|
440
|
-
* @param text - Text to match (string, RegExp, or custom matcher)
|
|
441
|
-
* @param options - Query options including normalization and timeout
|
|
442
|
-
* @returns Promise resolving to the matching widget
|
|
258
|
+
* Finds every widget whose widget name matches.
|
|
259
|
+
* @param container Widget subtree to search.
|
|
260
|
+
* @param name Matcher for the widget name.
|
|
261
|
+
* @param options Text matching options.
|
|
262
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
443
263
|
*/
|
|
444
|
-
export const
|
|
445
|
-
container
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
264
|
+
export const queryAllByName = (container: Container, name: Matcher, options?: MatcherOptions): Gtk.Widget[] =>
|
|
265
|
+
findAll(container, (widget) => matchText(getWidgetName(widget), name, widget, options));
|
|
266
|
+
|
|
267
|
+
const nameQueries = nameQueryFamily(
|
|
268
|
+
"Name",
|
|
269
|
+
queryAllByName,
|
|
270
|
+
buildQueries<[name: Matcher, options?: MatcherOptions]>(
|
|
271
|
+
"Name",
|
|
272
|
+
queryAllByName,
|
|
273
|
+
(container, matches, name) => multipleFoundError(container, { queryType: "name", name }, matches),
|
|
274
|
+
(container, name) => notFoundError(container, { queryType: "name", name }),
|
|
275
|
+
),
|
|
276
|
+
);
|
|
452
277
|
|
|
453
278
|
/**
|
|
454
|
-
* Finds
|
|
455
|
-
*
|
|
456
|
-
* @param
|
|
457
|
-
* @param
|
|
458
|
-
* @
|
|
459
|
-
* @returns Promise resolving to array of matching widgets
|
|
279
|
+
* Finds every widget whose placeholder text matches.
|
|
280
|
+
* @param container Widget subtree to search.
|
|
281
|
+
* @param text Matcher for the placeholder text.
|
|
282
|
+
* @param options Text matching options.
|
|
283
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
460
284
|
*/
|
|
461
|
-
export const
|
|
285
|
+
export const queryAllByPlaceholderText = (
|
|
462
286
|
container: Container,
|
|
463
|
-
text:
|
|
464
|
-
options?:
|
|
465
|
-
):
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
287
|
+
text: Matcher,
|
|
288
|
+
options?: MatcherOptions,
|
|
289
|
+
): Gtk.Widget[] => findAll(container, (widget) => matchText(getWidgetPlaceholderText(widget), text, widget, options));
|
|
290
|
+
|
|
291
|
+
const placeholderTextQueries = nameQueryFamily(
|
|
292
|
+
"PlaceholderText",
|
|
293
|
+
queryAllByPlaceholderText,
|
|
294
|
+
buildQueries<[text: Matcher, options?: MatcherOptions]>(
|
|
295
|
+
"PlaceholderText",
|
|
296
|
+
queryAllByPlaceholderText,
|
|
297
|
+
(container, matches, text) => multipleFoundError(container, { queryType: "placeholderText", text }, matches),
|
|
298
|
+
(container, text) => notFoundError(container, { queryType: "placeholderText", text }),
|
|
299
|
+
),
|
|
300
|
+
);
|
|
469
301
|
|
|
470
302
|
/**
|
|
471
|
-
* Finds
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* @param container - The container to search within
|
|
477
|
-
* @param testId - Test ID to match (string, RegExp, or custom matcher)
|
|
478
|
-
* @param options - Query options including normalization and timeout
|
|
479
|
-
* @returns Promise resolving to the matching widget
|
|
480
|
-
*
|
|
481
|
-
* @example
|
|
482
|
-
* ```tsx
|
|
483
|
-
* // In component: <GtkButton name="submit-btn" />
|
|
484
|
-
* const button = await findByTestId(container, "submit-btn");
|
|
485
|
-
* ```
|
|
303
|
+
* Finds every widget whose current display value matches.
|
|
304
|
+
* @param container Widget subtree to search.
|
|
305
|
+
* @param value Matcher for the display value.
|
|
306
|
+
* @param options Text matching options.
|
|
307
|
+
* @returns Every matching widget, or an empty array when none match.
|
|
486
308
|
*/
|
|
487
|
-
export const
|
|
488
|
-
container
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
309
|
+
export const queryAllByDisplayValue = (container: Container, value: Matcher, options?: MatcherOptions): Gtk.Widget[] =>
|
|
310
|
+
findAll(container, (widget) => matchText(getWidgetDisplayValue(widget), value, widget, options));
|
|
311
|
+
|
|
312
|
+
const displayValueQueries = nameQueryFamily(
|
|
313
|
+
"DisplayValue",
|
|
314
|
+
queryAllByDisplayValue,
|
|
315
|
+
buildQueries<[value: Matcher, options?: MatcherOptions]>(
|
|
316
|
+
"DisplayValue",
|
|
317
|
+
queryAllByDisplayValue,
|
|
318
|
+
(container, matches, value) => multipleFoundError(container, { queryType: "displayValue", value }, matches),
|
|
319
|
+
(container, value) => notFoundError(container, { queryType: "displayValue", value }),
|
|
320
|
+
),
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
export type BuiltinQueries = NamedFamily<"Role", [role: Gtk.AccessibleRole, options?: ByRoleOptions]> &
|
|
324
|
+
NamedFamily<"LabelText", [text: Matcher, options?: MatcherOptions]> &
|
|
325
|
+
NamedFamily<"Text", [text: Matcher, options?: MatcherOptions]> &
|
|
326
|
+
NamedFamily<"Name", [name: Matcher, options?: MatcherOptions]> &
|
|
327
|
+
NamedFamily<"PlaceholderText", [text: Matcher, options?: MatcherOptions]> &
|
|
328
|
+
NamedFamily<"DisplayValue", [value: Matcher, options?: MatcherOptions]>;
|
|
329
|
+
|
|
330
|
+
export const builtinQueries: BuiltinQueries = {
|
|
331
|
+
...roleQueries,
|
|
332
|
+
...labelTextQueries,
|
|
333
|
+
...textQueries,
|
|
334
|
+
...nameQueries,
|
|
335
|
+
...placeholderTextQueries,
|
|
336
|
+
...displayValueQueries,
|
|
337
|
+
};
|
|
495
338
|
|
|
496
|
-
/**
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
339
|
+
/** Returns the single widget with a matching accessible role and options, or null when none match. Throws when more than one matches. */
|
|
340
|
+
export const queryByRole: BuiltinQueries["queryByRole"] = roleQueries.queryByRole;
|
|
341
|
+
/** Returns every widget with a matching accessible role and options. Throws when none match. */
|
|
342
|
+
export const getAllByRole: BuiltinQueries["getAllByRole"] = roleQueries.getAllByRole;
|
|
343
|
+
/** Returns the single widget with a matching accessible role and options. Throws when none or more than one matches. */
|
|
344
|
+
export const getByRole: BuiltinQueries["getByRole"] = roleQueries.getByRole;
|
|
345
|
+
/** Waits for and returns every widget with a matching accessible role and options, retrying until at least one appears or the timeout elapses. */
|
|
346
|
+
export const findAllByRole: BuiltinQueries["findAllByRole"] = roleQueries.findAllByRole;
|
|
347
|
+
/** Waits for and returns the single widget with a matching accessible role and options, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */
|
|
348
|
+
export const findByRole: BuiltinQueries["findByRole"] = roleQueries.findByRole;
|
|
349
|
+
|
|
350
|
+
/** Returns the single widget with matching associated label text, or null when none match. Throws when more than one matches. */
|
|
351
|
+
export const queryByLabelText: BuiltinQueries["queryByLabelText"] = labelTextQueries.queryByLabelText;
|
|
352
|
+
/** Returns every widget with matching associated label text. Throws when none match. */
|
|
353
|
+
export const getAllByLabelText: BuiltinQueries["getAllByLabelText"] = labelTextQueries.getAllByLabelText;
|
|
354
|
+
/** Returns the single widget with matching associated label text. Throws when none or more than one matches. */
|
|
355
|
+
export const getByLabelText: BuiltinQueries["getByLabelText"] = labelTextQueries.getByLabelText;
|
|
356
|
+
/** Waits for and returns every widget with matching associated label text, retrying until at least one appears or the timeout elapses. */
|
|
357
|
+
export const findAllByLabelText: BuiltinQueries["findAllByLabelText"] = labelTextQueries.findAllByLabelText;
|
|
358
|
+
/** Waits for and returns the single widget with matching associated label text, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */
|
|
359
|
+
export const findByLabelText: BuiltinQueries["findByLabelText"] = labelTextQueries.findByLabelText;
|
|
360
|
+
|
|
361
|
+
/** Returns the single widget with matching rendered text content, or null when none match. Throws when more than one matches. */
|
|
362
|
+
export const queryByText: BuiltinQueries["queryByText"] = textQueries.queryByText;
|
|
363
|
+
/** Returns every widget with matching rendered text content. Throws when none match. */
|
|
364
|
+
export const getAllByText: BuiltinQueries["getAllByText"] = textQueries.getAllByText;
|
|
365
|
+
/** Returns the single widget with matching rendered text content. Throws when none or more than one matches. */
|
|
366
|
+
export const getByText: BuiltinQueries["getByText"] = textQueries.getByText;
|
|
367
|
+
/** Waits for and returns every widget with matching rendered text content, retrying until at least one appears or the timeout elapses. */
|
|
368
|
+
export const findAllByText: BuiltinQueries["findAllByText"] = textQueries.findAllByText;
|
|
369
|
+
/** Waits for and returns the single widget with matching rendered text content, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */
|
|
370
|
+
export const findByText: BuiltinQueries["findByText"] = textQueries.findByText;
|
|
371
|
+
|
|
372
|
+
/** Returns the single widget with a matching widget name, or null when none match. Throws when more than one matches. */
|
|
373
|
+
export const queryByName: BuiltinQueries["queryByName"] = nameQueries.queryByName;
|
|
374
|
+
/** Returns every widget with a matching widget name. Throws when none match. */
|
|
375
|
+
export const getAllByName: BuiltinQueries["getAllByName"] = nameQueries.getAllByName;
|
|
376
|
+
/** Returns the single widget with a matching widget name. Throws when none or more than one matches. */
|
|
377
|
+
export const getByName: BuiltinQueries["getByName"] = nameQueries.getByName;
|
|
378
|
+
/** Waits for and returns every widget with a matching widget name, retrying until at least one appears or the timeout elapses. */
|
|
379
|
+
export const findAllByName: BuiltinQueries["findAllByName"] = nameQueries.findAllByName;
|
|
380
|
+
/** Waits for and returns the single widget with a matching widget name, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */
|
|
381
|
+
export const findByName: BuiltinQueries["findByName"] = nameQueries.findByName;
|
|
382
|
+
|
|
383
|
+
/** Returns the single widget with matching placeholder text, or null when none match. Throws when more than one matches. */
|
|
384
|
+
export const queryByPlaceholderText: BuiltinQueries["queryByPlaceholderText"] =
|
|
385
|
+
placeholderTextQueries.queryByPlaceholderText;
|
|
386
|
+
/** Returns every widget with matching placeholder text. Throws when none match. */
|
|
387
|
+
export const getAllByPlaceholderText: BuiltinQueries["getAllByPlaceholderText"] =
|
|
388
|
+
placeholderTextQueries.getAllByPlaceholderText;
|
|
389
|
+
/** Returns the single widget with matching placeholder text. Throws when none or more than one matches. */
|
|
390
|
+
export const getByPlaceholderText: BuiltinQueries["getByPlaceholderText"] = placeholderTextQueries.getByPlaceholderText;
|
|
391
|
+
/** Waits for and returns every widget with matching placeholder text, retrying until at least one appears or the timeout elapses. */
|
|
392
|
+
export const findAllByPlaceholderText: BuiltinQueries["findAllByPlaceholderText"] =
|
|
393
|
+
placeholderTextQueries.findAllByPlaceholderText;
|
|
394
|
+
/** Waits for and returns the single widget with matching placeholder text, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */
|
|
395
|
+
export const findByPlaceholderText: BuiltinQueries["findByPlaceholderText"] =
|
|
396
|
+
placeholderTextQueries.findByPlaceholderText;
|
|
397
|
+
|
|
398
|
+
/** Returns the single widget with a matching display value, or null when none match. Throws when more than one matches. */
|
|
399
|
+
export const queryByDisplayValue: BuiltinQueries["queryByDisplayValue"] = displayValueQueries.queryByDisplayValue;
|
|
400
|
+
/** Returns every widget with a matching display value. Throws when none match. */
|
|
401
|
+
export const getAllByDisplayValue: BuiltinQueries["getAllByDisplayValue"] = displayValueQueries.getAllByDisplayValue;
|
|
402
|
+
/** Returns the single widget with a matching display value. Throws when none or more than one matches. */
|
|
403
|
+
export const getByDisplayValue: BuiltinQueries["getByDisplayValue"] = displayValueQueries.getByDisplayValue;
|
|
404
|
+
/** Waits for and returns every widget with a matching display value, retrying until at least one appears or the timeout elapses. */
|
|
405
|
+
export const findAllByDisplayValue: BuiltinQueries["findAllByDisplayValue"] = displayValueQueries.findAllByDisplayValue;
|
|
406
|
+
/** Waits for and returns the single widget with a matching display value, retrying until it appears or the timeout elapses. Rejects when none or more than one matches. */
|
|
407
|
+
export const findByDisplayValue: BuiltinQueries["findByDisplayValue"] = displayValueQueries.findByDisplayValue;
|