@specter-automation/test 1.0.127 → 1.0.128
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SpecterLocator } from "../locators/specter-locator";
|
|
1
|
+
import { SpecterLocator, FilterOptions } from "../locators/specter-locator";
|
|
2
2
|
import { ClickOptions } from "../specter-client";
|
|
3
3
|
import { WidgetEventMap, EventPredicate, WaitForEventOptions } from "../events";
|
|
4
4
|
export type WidgetRole = 'button' | 'textbox' | 'checkbox' | 'slider' | 'text' | 'heading' | 'label' | 'image' | 'combobox' | 'dropdown' | 'progressbar';
|
|
@@ -6,6 +6,45 @@ export interface WidgetRoleOptions {
|
|
|
6
6
|
name?: string | RegExp;
|
|
7
7
|
exact?: boolean;
|
|
8
8
|
}
|
|
9
|
+
export interface WidgetFilterOptions extends Partial<FilterOptions> {
|
|
10
|
+
/**
|
|
11
|
+
* Matches widgets containing the specified text string or regular expression anywhere inside them.
|
|
12
|
+
*/
|
|
13
|
+
hasText?: string | RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* Matches widgets that do NOT contain the specified text string or regular expression anywhere inside them.
|
|
16
|
+
*/
|
|
17
|
+
hasNotText?: string | RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* Matches widgets that contain a child or descendant matching the given sub-locator.
|
|
20
|
+
*/
|
|
21
|
+
has?: WidgetLocator | SpecterLocator;
|
|
22
|
+
/**
|
|
23
|
+
* Matches widgets that do NOT contain any child or descendant matching the given sub-locator.
|
|
24
|
+
*/
|
|
25
|
+
hasNot?: WidgetLocator | SpecterLocator;
|
|
26
|
+
/**
|
|
27
|
+
* Matches widgets that have a child with the specified designer name.
|
|
28
|
+
*/
|
|
29
|
+
hasChild?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Matches widgets that do not have a child with the specified designer name.
|
|
32
|
+
*/
|
|
33
|
+
hasNotChild?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Filter by whether the widget is visually visible / rendered.
|
|
36
|
+
*/
|
|
37
|
+
visible?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Filter by whether the widget is enabled (`bIsEnabled`).
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* When using string `hasText` or `hasNotText`, whether the match must be exact.
|
|
44
|
+
* Default is false (substring match) for string, or exact if specified.
|
|
45
|
+
*/
|
|
46
|
+
exact?: boolean;
|
|
47
|
+
}
|
|
9
48
|
export interface WidgetGeometry {
|
|
10
49
|
isRendered: boolean;
|
|
11
50
|
isVisible: boolean;
|
|
@@ -23,6 +62,10 @@ export interface WidgetGeometry {
|
|
|
23
62
|
};
|
|
24
63
|
}
|
|
25
64
|
export declare class WidgetLocator<T = any> extends SpecterLocator<T> {
|
|
65
|
+
/**
|
|
66
|
+
* Filters the currently located widgets by text, child widgets, visibility, enabled state, or properties.
|
|
67
|
+
*/
|
|
68
|
+
filter(options: WidgetFilterOptions): this;
|
|
26
69
|
waitForEvent<K extends keyof WidgetEventMap>(eventName: K | (string & {}), optionsOrPredicate?: number | EventPredicate<K extends keyof WidgetEventMap ? WidgetEventMap[K] : any> | WaitForEventOptions<K extends keyof WidgetEventMap ? WidgetEventMap[K] : any>): Promise<K extends keyof WidgetEventMap ? WidgetEventMap[K] : any>;
|
|
27
70
|
/**
|
|
28
71
|
* Finds a child widget by its semantic role (button, textbox, checkbox, slider, text, image, combobox)
|
|
@@ -37,6 +37,119 @@ exports.WidgetLocator = void 0;
|
|
|
37
37
|
const specter_locator_1 = require("../locators/specter-locator");
|
|
38
38
|
const test_1 = __importStar(require("@playwright/test"));
|
|
39
39
|
class WidgetLocator extends specter_locator_1.SpecterLocator {
|
|
40
|
+
/**
|
|
41
|
+
* Filters the currently located widgets by text, child widgets, visibility, enabled state, or properties.
|
|
42
|
+
*/
|
|
43
|
+
filter(options) {
|
|
44
|
+
const newLocator = this.clone();
|
|
45
|
+
if (options.hasText !== undefined) {
|
|
46
|
+
const isRegex = options.hasText instanceof RegExp;
|
|
47
|
+
const textStr = isRegex ? options.hasText.source : options.hasText;
|
|
48
|
+
newLocator.pipeline.push({
|
|
49
|
+
action: 'filterWidgetByText',
|
|
50
|
+
value: textStr,
|
|
51
|
+
exact: options.exact ?? false,
|
|
52
|
+
regex: isRegex,
|
|
53
|
+
invert: false,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (options.hasNotText !== undefined) {
|
|
57
|
+
const isRegex = options.hasNotText instanceof RegExp;
|
|
58
|
+
const textStr = isRegex ? options.hasNotText.source : options.hasNotText;
|
|
59
|
+
newLocator.pipeline.push({
|
|
60
|
+
action: 'filterWidgetByText',
|
|
61
|
+
value: textStr,
|
|
62
|
+
exact: options.exact ?? false,
|
|
63
|
+
regex: isRegex,
|
|
64
|
+
invert: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (options.hasChild !== undefined) {
|
|
68
|
+
newLocator.pipeline.push({
|
|
69
|
+
action: 'filterWidgetByChild',
|
|
70
|
+
value: options.hasChild,
|
|
71
|
+
exact: options.exact ?? false,
|
|
72
|
+
invert: false,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (options.hasNotChild !== undefined) {
|
|
76
|
+
newLocator.pipeline.push({
|
|
77
|
+
action: 'filterWidgetByChild',
|
|
78
|
+
value: options.hasNotChild,
|
|
79
|
+
exact: options.exact ?? false,
|
|
80
|
+
invert: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (options.has !== undefined) {
|
|
84
|
+
newLocator.pipeline.push({
|
|
85
|
+
action: 'filterWidgetHas',
|
|
86
|
+
value: JSON.stringify(options.has.pipeline),
|
|
87
|
+
invert: false,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (options.hasNot !== undefined) {
|
|
91
|
+
newLocator.pipeline.push({
|
|
92
|
+
action: 'filterWidgetHas',
|
|
93
|
+
value: JSON.stringify(options.hasNot.pipeline),
|
|
94
|
+
invert: true,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (options.visible !== undefined) {
|
|
98
|
+
newLocator.pipeline.push({
|
|
99
|
+
action: 'filterWidgetVisibility',
|
|
100
|
+
value: options.visible ? 'true' : 'false',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (options.enabled !== undefined) {
|
|
104
|
+
newLocator.pipeline.push({
|
|
105
|
+
action: 'filterWidgetEnabled',
|
|
106
|
+
value: options.enabled ? 'true' : 'false',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (options.property) {
|
|
110
|
+
newLocator.pipeline.push({
|
|
111
|
+
action: 'filterByProperty',
|
|
112
|
+
value: JSON.stringify(options.property),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (options.hasComponent) {
|
|
116
|
+
newLocator.pipeline.push({
|
|
117
|
+
action: 'filterByComponent',
|
|
118
|
+
value: options.hasComponent,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (options.withinRadius !== undefined) {
|
|
122
|
+
const spatialPayload = JSON.stringify({
|
|
123
|
+
x: options.x ?? 0,
|
|
124
|
+
y: options.y ?? 0,
|
|
125
|
+
z: options.z ?? 0,
|
|
126
|
+
radius: options.withinRadius,
|
|
127
|
+
});
|
|
128
|
+
newLocator.pipeline.push({
|
|
129
|
+
action: 'withinRadius',
|
|
130
|
+
value: spatialPayload,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (options.locallyControlled !== undefined) {
|
|
134
|
+
newLocator.pipeline.push({
|
|
135
|
+
action: 'filterLocallyControlled',
|
|
136
|
+
value: options.locallyControlled ? '' : 'false',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (options.possessed !== undefined) {
|
|
140
|
+
newLocator.pipeline.push({
|
|
141
|
+
action: 'filterPossessed',
|
|
142
|
+
value: options.possessed ? '' : 'false',
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (options.playerControlled !== undefined) {
|
|
146
|
+
newLocator.pipeline.push({
|
|
147
|
+
action: 'filterPossessed',
|
|
148
|
+
value: options.playerControlled ? '' : 'false',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return newLocator;
|
|
152
|
+
}
|
|
40
153
|
async waitForEvent(eventName, optionsOrPredicate) {
|
|
41
154
|
return super.waitForEvent(eventName, optionsOrPredicate);
|
|
42
155
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { test, expect, type SpecterTestOptions } from './core/test-wrapper';
|
|
2
2
|
export { SpecterTransport, SpecterWorld, VectorUtils } from './core/specter-client';
|
|
3
3
|
export type { SpecterPayload, SpawnOptions, Vector3, Rotator, Transform, HitResult, LinearColor, Color, Vector2D, SpecterRegistry, SpecterFunctionRegistry, LoadMapOptions, SpecterGrantedAbility, SpecterActiveEffect, SpecterActorSnapshot, RegisteredGameplayTags } from './core/specter-client';
|
|
4
|
-
export { SpecterLocator, WidgetLocator, ActorLocator, AiControllerLocator, type WidgetGeometry } from './core/locators';
|
|
4
|
+
export { SpecterLocator, WidgetLocator, ActorLocator, AiControllerLocator, type WidgetGeometry, type WidgetFilterOptions } from './core/locators';
|
|
5
5
|
export { default as SpecterReporter } from './core/specter-reporter';
|
|
6
6
|
export { expectAll } from './core/expect-all';
|
|
7
7
|
export { SPECTER_MATCHER_ATTACHMENT } from './core/specter-matcher-report';
|