@specter-automation/test 1.0.149 → 1.0.150
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/core/locators/actor-locator.d.ts +67 -4
- package/dist/core/locators/actor-locator.js +128 -9
- package/dist/core/locators/ai-controller-locator.d.ts +7 -1
- package/dist/core/locators/ai-controller-locator.js +10 -1
- package/dist/core/locators/specter-locator.js +18 -1
- package/dist/core/specter-client.d.ts +26 -49
- package/dist/core/specter-client.js +59 -44
- package/dist/core/specter-debug.d.ts +145 -0
- package/dist/core/specter-debug.js +35 -0
- package/dist/core/specter-matcher-report.d.ts +1 -1
- package/dist/core/specter-matcher-report.js +1 -1
- package/dist/core/specter-math.d.ts +417 -0
- package/dist/core/specter-math.js +522 -0
- package/dist/core/specter-preview.js +2 -1
- package/dist/core/specter-reporter.js +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -1
- package/dist/matchers/actor-matchers.d.ts +51 -30
- package/dist/matchers/actor-matchers.js +93 -10
- package/dist/matchers/gas-matchers.d.ts +2 -0
- package/dist/matchers/gas-matchers.js +3 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ActorLocator, MovementLocator } from '../core/locators';
|
|
2
|
+
import { type Rotator, type Vector3 } from '../core/specter-math';
|
|
2
3
|
declare global {
|
|
3
4
|
namespace PlaywrightTest {
|
|
4
5
|
interface Matchers<R, T> {
|
|
@@ -20,23 +21,22 @@ declare global {
|
|
|
20
21
|
toHaveMovementMode(expectedMode: 'Walking' | 'Falling' | 'Swimming' | 'Flying' | 'NavWalking' | 'Custom' | 'None' | string, options?: {
|
|
21
22
|
timeout?: number;
|
|
22
23
|
}): T extends (ActorLocator | MovementLocator) ? Promise<R> : never;
|
|
23
|
-
toHaveMovedFurtherThan(startLocation: {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
z: number;
|
|
27
|
-
}, expectedDistance: number, axisOrOptions?: MovementAxis | {
|
|
24
|
+
toHaveMovedFurtherThan(startLocation: Vector3, expectedDistance: number, axisOrOptions?: MovementAxis | {
|
|
28
25
|
axis?: MovementAxis;
|
|
29
26
|
timeout?: number;
|
|
30
27
|
}, options?: {
|
|
31
28
|
timeout?: number;
|
|
32
29
|
}): T extends ActorLocator ? Promise<R> : never;
|
|
33
|
-
toHaveLocation(expectedLocation: {
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
z: number;
|
|
37
|
-
}, tolerance?: number, options?: {
|
|
30
|
+
toHaveLocation(expectedLocation: Vector3, tolerance?: number, options?: {
|
|
38
31
|
timeout?: number;
|
|
39
32
|
}): T extends ActorLocator ? Promise<R> : never;
|
|
33
|
+
toHaveRotation(expectedRotation: Rotator, toleranceDegrees?: number, options?: {
|
|
34
|
+
timeout?: number;
|
|
35
|
+
}): T extends ActorLocator ? Promise<R> : never;
|
|
36
|
+
toBeFacing(target: ActorLocator | Vector3, toleranceDegrees?: number, options?: {
|
|
37
|
+
timeout?: number;
|
|
38
|
+
planarOnly?: boolean;
|
|
39
|
+
}): T extends ActorLocator ? Promise<R> : never;
|
|
40
40
|
toHaveInputMappingContext(contextNameOrPath: string, options?: {
|
|
41
41
|
timeout?: number;
|
|
42
42
|
}): T extends ActorLocator ? Promise<R> : never;
|
|
@@ -117,23 +117,22 @@ export interface ActorMatchers {
|
|
|
117
117
|
* `expect(hero).toHaveMovedFurtherThan(start, 100, 'z')` for thrown 100 up. It polls the location every 50ms, so
|
|
118
118
|
* a short hop counts even when the actor is back down by the time the check ends.
|
|
119
119
|
*/
|
|
120
|
-
toHaveMovedFurtherThan(startLocation: {
|
|
121
|
-
x: number;
|
|
122
|
-
y: number;
|
|
123
|
-
z: number;
|
|
124
|
-
}, expectedDistance: number, axisOrOptions?: MovementAxis | {
|
|
120
|
+
toHaveMovedFurtherThan(startLocation: Vector3, expectedDistance: number, axisOrOptions?: MovementAxis | {
|
|
125
121
|
axis?: MovementAxis;
|
|
126
122
|
timeout?: number;
|
|
127
123
|
}, options?: {
|
|
128
124
|
timeout?: number;
|
|
129
125
|
}): Promise<void>;
|
|
130
|
-
toHaveLocation(expectedLocation: {
|
|
131
|
-
x: number;
|
|
132
|
-
y: number;
|
|
133
|
-
z: number;
|
|
134
|
-
}, tolerance?: number, options?: {
|
|
126
|
+
toHaveLocation(expectedLocation: Vector3, tolerance?: number, options?: {
|
|
135
127
|
timeout?: number;
|
|
136
128
|
}): Promise<void>;
|
|
129
|
+
toHaveRotation(expectedRotation: Rotator, toleranceDegrees?: number, options?: {
|
|
130
|
+
timeout?: number;
|
|
131
|
+
}): Promise<void>;
|
|
132
|
+
toBeFacing(target: ActorLocator | Vector3, toleranceDegrees?: number, options?: {
|
|
133
|
+
timeout?: number;
|
|
134
|
+
planarOnly?: boolean;
|
|
135
|
+
}): Promise<void>;
|
|
137
136
|
toHaveInputMappingContext(contextNameOrPath: string, options?: {
|
|
138
137
|
timeout?: number;
|
|
139
138
|
}): Promise<void>;
|
|
@@ -220,11 +219,7 @@ export interface ActorMatchers {
|
|
|
220
219
|
}): Promise<void>;
|
|
221
220
|
}
|
|
222
221
|
export declare const actorExpect: import("playwright/test").Expect<{
|
|
223
|
-
toHaveMovedFurtherThan(this: import("playwright/test").ExpectMatcherState, locator: any, startLocation: {
|
|
224
|
-
x: number;
|
|
225
|
-
y: number;
|
|
226
|
-
z: number;
|
|
227
|
-
}, expectedDistance: number, axisOrOptions?: MovementAxis | {
|
|
222
|
+
toHaveMovedFurtherThan(this: import("playwright/test").ExpectMatcherState, locator: any, startLocation: Vector3, expectedDistance: number, axisOrOptions?: MovementAxis | {
|
|
228
223
|
axis?: MovementAxis;
|
|
229
224
|
timeout?: number;
|
|
230
225
|
}, options?: {
|
|
@@ -240,11 +235,7 @@ export declare const actorExpect: import("playwright/test").Expect<{
|
|
|
240
235
|
actual: number;
|
|
241
236
|
expected: string;
|
|
242
237
|
}>;
|
|
243
|
-
toHaveLocation(this: import("playwright/test").ExpectMatcherState, locator: any, expectedLocation: {
|
|
244
|
-
x: number;
|
|
245
|
-
y: number;
|
|
246
|
-
z: number;
|
|
247
|
-
}, tolerance?: number, options?: {
|
|
238
|
+
toHaveLocation(this: import("playwright/test").ExpectMatcherState, locator: any, expectedLocation: Vector3, tolerance?: number, options?: {
|
|
248
239
|
timeout?: number;
|
|
249
240
|
}): Promise<{
|
|
250
241
|
pass: true;
|
|
@@ -273,6 +264,36 @@ export declare const actorExpect: import("playwright/test").Expect<{
|
|
|
273
264
|
z: number;
|
|
274
265
|
};
|
|
275
266
|
}>;
|
|
267
|
+
toHaveRotation(this: import("playwright/test").ExpectMatcherState, locator: any, expectedRotation: {
|
|
268
|
+
pitch: number;
|
|
269
|
+
yaw: number;
|
|
270
|
+
roll?: number;
|
|
271
|
+
}, toleranceDegrees?: number, options?: {
|
|
272
|
+
timeout?: number;
|
|
273
|
+
}): Promise<{
|
|
274
|
+
pass: boolean;
|
|
275
|
+
message: () => string;
|
|
276
|
+
actual: Rotator | null;
|
|
277
|
+
expected: {
|
|
278
|
+
pitch: number;
|
|
279
|
+
yaw: number;
|
|
280
|
+
roll: number;
|
|
281
|
+
};
|
|
282
|
+
}>;
|
|
283
|
+
toBeFacing(this: import("playwright/test").ExpectMatcherState, locator: any, target: any, toleranceDegrees?: number, options?: {
|
|
284
|
+
timeout?: number;
|
|
285
|
+
planarOnly?: boolean;
|
|
286
|
+
}): Promise<{
|
|
287
|
+
pass: boolean;
|
|
288
|
+
message: () => string;
|
|
289
|
+
actual?: undefined;
|
|
290
|
+
expected?: undefined;
|
|
291
|
+
} | {
|
|
292
|
+
pass: boolean;
|
|
293
|
+
message: () => string;
|
|
294
|
+
actual: Rotator | null;
|
|
295
|
+
expected: Rotator | null;
|
|
296
|
+
}>;
|
|
276
297
|
toHaveInputMappingContext(this: import("playwright/test").ExpectMatcherState, locator: any, contextNameOrPath: string, options?: {
|
|
277
298
|
timeout?: number;
|
|
278
299
|
}): Promise<{
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.actorExpect = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
5
|
const instrument_1 = require("./instrument");
|
|
6
|
+
const specter_math_1 = require("../core/specter-math");
|
|
6
7
|
exports.actorExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
|
|
7
8
|
async toHaveMovedFurtherThan(locator, startLocation, expectedDistance, axisOrOptions, options) {
|
|
8
9
|
const assertionName = 'toHaveMovedFurtherThan';
|
|
@@ -14,10 +15,13 @@ exports.actorExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)(
|
|
|
14
15
|
const timeout = opts?.timeout ?? 5000;
|
|
15
16
|
const startTime = Date.now();
|
|
16
17
|
const along = axis === 'xyz' ? '' : ` along ${axis}`;
|
|
18
|
+
const startX = startLocation.x ?? 0;
|
|
19
|
+
const startY = startLocation.y ?? 0;
|
|
20
|
+
const startZ = startLocation.z ?? 0;
|
|
17
21
|
const measure = (loc) => {
|
|
18
|
-
const dx = axis.includes('x') ? loc.x -
|
|
19
|
-
const dy = axis.includes('y') ? loc.y -
|
|
20
|
-
const dz = axis.includes('z') ? loc.z -
|
|
22
|
+
const dx = axis.includes('x') ? (loc.x ?? 0) - startX : 0;
|
|
23
|
+
const dy = axis.includes('y') ? (loc.y ?? 0) - startY : 0;
|
|
24
|
+
const dz = axis.includes('z') ? (loc.z ?? 0) - startZ : 0;
|
|
21
25
|
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
22
26
|
};
|
|
23
27
|
let maxDistance = 0;
|
|
@@ -55,21 +59,26 @@ exports.actorExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)(
|
|
|
55
59
|
const assertionName = 'toHaveLocation';
|
|
56
60
|
const timeout = options?.timeout ?? 5000;
|
|
57
61
|
const startTime = Date.now();
|
|
62
|
+
const targetLoc = {
|
|
63
|
+
x: expectedLocation.x ?? 0,
|
|
64
|
+
y: expectedLocation.y ?? 0,
|
|
65
|
+
z: expectedLocation.z ?? 0
|
|
66
|
+
};
|
|
58
67
|
let currentLoc = null;
|
|
59
68
|
let diff = 0;
|
|
60
69
|
while (Date.now() - startTime < timeout) {
|
|
61
70
|
currentLoc = await locator.getLocation();
|
|
62
71
|
if (currentLoc) {
|
|
63
|
-
const dx = currentLoc.x -
|
|
64
|
-
const dy = currentLoc.y -
|
|
65
|
-
const dz = currentLoc.z -
|
|
72
|
+
const dx = (currentLoc.x ?? 0) - targetLoc.x;
|
|
73
|
+
const dy = (currentLoc.y ?? 0) - targetLoc.y;
|
|
74
|
+
const dz = (currentLoc.z ?? 0) - targetLoc.z;
|
|
66
75
|
diff = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
67
76
|
if (diff <= tolerance) {
|
|
68
77
|
return {
|
|
69
78
|
pass: true,
|
|
70
79
|
message: () => 'passed',
|
|
71
80
|
actual: currentLoc,
|
|
72
|
-
expected:
|
|
81
|
+
expected: targetLoc
|
|
73
82
|
};
|
|
74
83
|
}
|
|
75
84
|
}
|
|
@@ -78,13 +87,87 @@ exports.actorExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)(
|
|
|
78
87
|
}
|
|
79
88
|
return {
|
|
80
89
|
pass: false,
|
|
81
|
-
message: () => `${this.utils.matcherHint(assertionName, locator.toString(), JSON.stringify(
|
|
90
|
+
message: () => `${this.utils.matcherHint(assertionName, locator.toString(), JSON.stringify(targetLoc))}\n\n` +
|
|
82
91
|
`Timed out after ${timeout}ms waiting for actor to reach location.\n` +
|
|
83
|
-
`Expected location: ${JSON.stringify(
|
|
92
|
+
`Expected location: ${JSON.stringify(targetLoc)} (tolerance: ${tolerance})\n` +
|
|
84
93
|
`Received location: ${JSON.stringify(currentLoc)}\n` +
|
|
85
94
|
`Distance: ${diff}`,
|
|
86
95
|
actual: currentLoc,
|
|
87
|
-
expected:
|
|
96
|
+
expected: targetLoc
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
async toHaveRotation(locator, expectedRotation, toleranceDegrees = 2.0, options) {
|
|
100
|
+
const isNot = this.isNot;
|
|
101
|
+
const assertionName = isNot ? 'not.toHaveRotation' : 'toHaveRotation';
|
|
102
|
+
const timeout = options?.timeout ?? 5000;
|
|
103
|
+
const startTime = Date.now();
|
|
104
|
+
let currentRot = null;
|
|
105
|
+
const targetRot = {
|
|
106
|
+
pitch: expectedRotation.pitch ?? 0,
|
|
107
|
+
yaw: expectedRotation.yaw ?? 0,
|
|
108
|
+
roll: expectedRotation.roll ?? 0
|
|
109
|
+
};
|
|
110
|
+
while (Date.now() - startTime < timeout) {
|
|
111
|
+
try {
|
|
112
|
+
currentRot = await locator.getRotation();
|
|
113
|
+
if (currentRot) {
|
|
114
|
+
const matches = specter_math_1.RotatorUtils.isNearlyEqual(currentRot, targetRot, toleranceDegrees);
|
|
115
|
+
if (isNot ? !matches : matches) {
|
|
116
|
+
return { pass: !isNot, message: () => 'passed', actual: currentRot, expected: targetRot };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e) { }
|
|
121
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
pass: isNot,
|
|
125
|
+
message: () => `${this.utils.matcherHint(assertionName, locator.toString(), JSON.stringify(targetRot))}\n\n` +
|
|
126
|
+
`Timed out after ${timeout}ms waiting for actor to reach rotation.\n` +
|
|
127
|
+
`Expected rotation: ${JSON.stringify(targetRot)} (tolerance: ±${toleranceDegrees}°)\n` +
|
|
128
|
+
`Received rotation: ${JSON.stringify(currentRot)}`,
|
|
129
|
+
actual: currentRot,
|
|
130
|
+
expected: targetRot
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
async toBeFacing(locator, target, toleranceDegrees = 10.0, options) {
|
|
134
|
+
const isNot = this.isNot;
|
|
135
|
+
const assertionName = isNot ? 'not.toBeFacing' : 'toBeFacing';
|
|
136
|
+
const timeout = options?.timeout ?? 5000;
|
|
137
|
+
const planarOnly = options?.planarOnly ?? true;
|
|
138
|
+
const startTime = Date.now();
|
|
139
|
+
let currentRot = null;
|
|
140
|
+
let lookAtRot = null;
|
|
141
|
+
let angleDiff = 0;
|
|
142
|
+
while (Date.now() - startTime < timeout) {
|
|
143
|
+
try {
|
|
144
|
+
currentRot = await locator.getRotation();
|
|
145
|
+
lookAtRot = await locator.getRotationTo(target);
|
|
146
|
+
if (currentRot && lookAtRot) {
|
|
147
|
+
angleDiff = planarOnly
|
|
148
|
+
? specter_math_1.RotatorUtils.yawDifference(currentRot, lookAtRot)
|
|
149
|
+
: specter_math_1.RotatorUtils.angularDistance(currentRot, lookAtRot);
|
|
150
|
+
const matches = angleDiff <= toleranceDegrees;
|
|
151
|
+
if (isNot ? !matches : matches) {
|
|
152
|
+
return { pass: !isNot, message: () => 'passed' };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (e) { }
|
|
157
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
158
|
+
}
|
|
159
|
+
const targetLabel = typeof target === 'object' && target !== null && 'pipeline' in target
|
|
160
|
+
? target.toString()
|
|
161
|
+
: JSON.stringify(target);
|
|
162
|
+
return {
|
|
163
|
+
pass: isNot,
|
|
164
|
+
message: () => `${this.utils.matcherHint(assertionName, locator.toString(), targetLabel)}\n\n` +
|
|
165
|
+
`Timed out after ${timeout}ms waiting for actor to face target.\n` +
|
|
166
|
+
`Current rotation: ${JSON.stringify(currentRot)}\n` +
|
|
167
|
+
`Required look-at rotation: ${JSON.stringify(lookAtRot)}\n` +
|
|
168
|
+
`Angular difference: ${angleDiff.toFixed(2)}° (tolerance: ±${toleranceDegrees}°)`,
|
|
169
|
+
actual: currentRot,
|
|
170
|
+
expected: lookAtRot
|
|
88
171
|
};
|
|
89
172
|
},
|
|
90
173
|
async toHaveInputMappingContext(locator, contextNameOrPath, options) {
|
|
@@ -13,6 +13,8 @@ declare global {
|
|
|
13
13
|
effectCauser?: string | ActorLocator;
|
|
14
14
|
gameplayEffect?: string;
|
|
15
15
|
ability?: string;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
tolerance?: number;
|
|
16
18
|
}, triggerAction?: () => Promise<void>): T extends SpecterLocator ? Promise<R> : never;
|
|
17
19
|
toHaveGameplayTag(tag: RegisteredGameplayTags, options?: {
|
|
18
20
|
timeout?: number;
|
|
@@ -39,6 +39,7 @@ exports.formatCausalityTimeline = formatCausalityTimeline;
|
|
|
39
39
|
const test_1 = __importStar(require("@playwright/test"));
|
|
40
40
|
const instrument_1 = require("./instrument");
|
|
41
41
|
const specter_client_1 = require("../core/specter-client");
|
|
42
|
+
const specter_debug_1 = require("../core/specter-debug");
|
|
42
43
|
/**
|
|
43
44
|
* An asset or class reference reduced to its class name, for comparing effect and ability names however they're
|
|
44
45
|
* written: '/Game/FX/GE_Burn.GE_Burn_C', 'GE_Burn_C', 'Default__GE_Burn_C' and 'GE_Burn' are all 'GE_Burn'.
|
|
@@ -125,6 +126,8 @@ function formatAiDiagnostics(diagnostics) {
|
|
|
125
126
|
}
|
|
126
127
|
lines.push('');
|
|
127
128
|
}
|
|
129
|
+
// 6. Stuck AIs and the engine's warnings during the test
|
|
130
|
+
lines.push(...(0, specter_debug_1.formatDebugDiagnostics)(diagnostics));
|
|
128
131
|
lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
129
132
|
try {
|
|
130
133
|
const testInfo = test_1.default.info();
|