@specter-automation/test 1.0.107

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 (47) hide show
  1. package/dist/core/component-registry.d.ts +12 -0
  2. package/dist/core/component-registry.js +25 -0
  3. package/dist/core/conditions/input-conditions.d.ts +81 -0
  4. package/dist/core/conditions/input-conditions.js +197 -0
  5. package/dist/core/events.d.ts +133 -0
  6. package/dist/core/events.js +6 -0
  7. package/dist/core/locators/actor-locator.d.ts +425 -0
  8. package/dist/core/locators/actor-locator.js +1006 -0
  9. package/dist/core/locators/ai-controller-locator.d.ts +6 -0
  10. package/dist/core/locators/ai-controller-locator.js +19 -0
  11. package/dist/core/locators/index.d.ts +6 -0
  12. package/dist/core/locators/index.js +22 -0
  13. package/dist/core/locators/movement-locator.d.ts +27 -0
  14. package/dist/core/locators/movement-locator.js +78 -0
  15. package/dist/core/locators/skeleton-locator.d.ts +13 -0
  16. package/dist/core/locators/skeleton-locator.js +35 -0
  17. package/dist/core/locators/specter-locator.d.ts +110 -0
  18. package/dist/core/locators/specter-locator.js +323 -0
  19. package/dist/core/locators/widget-locator.d.ts +104 -0
  20. package/dist/core/locators/widget-locator.js +297 -0
  21. package/dist/core/specter-client.d.ts +352 -0
  22. package/dist/core/specter-client.js +883 -0
  23. package/dist/core/specter-input-sequence.d.ts +96 -0
  24. package/dist/core/specter-input-sequence.js +180 -0
  25. package/dist/core/specter-keyboard.d.ts +21 -0
  26. package/dist/core/specter-keyboard.js +63 -0
  27. package/dist/core/specter-keys.d.ts +1 -0
  28. package/dist/core/specter-keys.js +2 -0
  29. package/dist/core/specter-network.d.ts +34 -0
  30. package/dist/core/specter-network.js +59 -0
  31. package/dist/core/specter-reporter.d.ts +23 -0
  32. package/dist/core/specter-reporter.js +403 -0
  33. package/dist/core/test-wrapper.d.ts +25 -0
  34. package/dist/core/test-wrapper.js +200 -0
  35. package/dist/index.d.ts +13 -0
  36. package/dist/index.js +29 -0
  37. package/dist/matchers/actor-matchers.d.ts +492 -0
  38. package/dist/matchers/actor-matchers.js +841 -0
  39. package/dist/matchers/gas-matchers.d.ts +198 -0
  40. package/dist/matchers/gas-matchers.js +539 -0
  41. package/dist/matchers/locator-matchers.d.ts +80 -0
  42. package/dist/matchers/locator-matchers.js +214 -0
  43. package/dist/matchers/material-matchers.d.ts +74 -0
  44. package/dist/matchers/material-matchers.js +295 -0
  45. package/dist/matchers/widget-matchers.d.ts +81 -0
  46. package/dist/matchers/widget-matchers.js +110 -0
  47. package/package.json +33 -0
@@ -0,0 +1,841 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.actorExpect = void 0;
37
+ const test_1 = __importStar(require("@playwright/test"));
38
+ exports.actorExpect = test_1.expect.extend({
39
+ async toHaveMovedFurtherThan(locator, startLocation, expectedDistance, options) {
40
+ const assertionName = 'toHaveMovedFurtherThan';
41
+ const timeout = options?.timeout ?? 5000;
42
+ const startTime = Date.now();
43
+ let currentDistance = 0;
44
+ while (Date.now() - startTime < timeout) {
45
+ const loc = await locator.getLocation();
46
+ const dx = loc.x - startLocation.x;
47
+ const dy = loc.y - startLocation.y;
48
+ const dz = loc.z - startLocation.z;
49
+ currentDistance = Math.sqrt(dx * dx + dy * dy + dz * dz);
50
+ if (currentDistance > expectedDistance) {
51
+ return {
52
+ pass: true,
53
+ message: () => 'passed',
54
+ actual: currentDistance,
55
+ expected: `> ${expectedDistance}`
56
+ };
57
+ }
58
+ // Sleep for 100ms before polling again
59
+ await new Promise(resolve => setTimeout(resolve, 100));
60
+ }
61
+ return {
62
+ pass: false,
63
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), expectedDistance.toString())}\n\n` +
64
+ `Timed out after ${timeout}ms waiting for actor "${locator.toString()}" to move.\n` +
65
+ `Expected distance: > ${expectedDistance}\n` +
66
+ `Received max distance: ${currentDistance}`,
67
+ actual: currentDistance,
68
+ expected: `> ${expectedDistance}`
69
+ };
70
+ },
71
+ async toHaveLocation(locator, expectedLocation, tolerance = 5.0, options) {
72
+ const assertionName = 'toHaveLocation';
73
+ const timeout = options?.timeout ?? 5000;
74
+ const startTime = Date.now();
75
+ let currentLoc = null;
76
+ let diff = 0;
77
+ while (Date.now() - startTime < timeout) {
78
+ currentLoc = await locator.getLocation();
79
+ if (currentLoc) {
80
+ const dx = currentLoc.x - expectedLocation.x;
81
+ const dy = currentLoc.y - expectedLocation.y;
82
+ const dz = currentLoc.z - expectedLocation.z;
83
+ diff = Math.sqrt(dx * dx + dy * dy + dz * dz);
84
+ if (diff <= tolerance) {
85
+ return {
86
+ pass: true,
87
+ message: () => 'passed',
88
+ actual: currentLoc,
89
+ expected: expectedLocation
90
+ };
91
+ }
92
+ }
93
+ // Sleep for 100ms before polling again
94
+ await new Promise(resolve => setTimeout(resolve, 100));
95
+ }
96
+ return {
97
+ pass: false,
98
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), JSON.stringify(expectedLocation))}\n\n` +
99
+ `Timed out after ${timeout}ms waiting for actor to reach location.\n` +
100
+ `Expected location: ${JSON.stringify(expectedLocation)} (tolerance: ${tolerance})\n` +
101
+ `Received location: ${JSON.stringify(currentLoc)}\n` +
102
+ `Distance: ${diff}`,
103
+ actual: currentLoc,
104
+ expected: expectedLocation
105
+ };
106
+ },
107
+ async toHaveInputMappingContext(locator, contextNameOrPath, options) {
108
+ const isNot = this.isNot;
109
+ const timeout = options?.timeout ?? 5000;
110
+ const prefix = isNot ? 'not.toHaveInputMappingContext' : 'toHaveInputMappingContext';
111
+ const startTime = Date.now();
112
+ let lastResult = false;
113
+ while (Date.now() - startTime < timeout) {
114
+ try {
115
+ lastResult = await locator.hasInputMappingContext(contextNameOrPath);
116
+ if (lastResult === !isNot) {
117
+ return { pass: !isNot, message: () => 'passed' };
118
+ }
119
+ }
120
+ catch (e) { }
121
+ await new Promise(r => setTimeout(r, 100));
122
+ }
123
+ return {
124
+ pass: isNot,
125
+ message: () => `Expected player to${isNot ? ' not' : ''} have Input Mapping Context "${contextNameOrPath}", but it did${lastResult ? '' : ' not'}.`
126
+ };
127
+ },
128
+ async toHaveInputActionValue(locator, actionNameOrPath, expectedValue, options) {
129
+ const isNot = this.isNot;
130
+ const timeout = options?.timeout ?? 5000;
131
+ const prefix = isNot ? 'not.toHaveInputActionValue' : 'toHaveInputActionValue';
132
+ const startTime = Date.now();
133
+ let lastData = null;
134
+ while (Date.now() - startTime < timeout) {
135
+ try {
136
+ lastData = await locator.getInputActionValue(actionNameOrPath);
137
+ let actualVal = lastData?.value;
138
+ if (typeof expectedValue === 'boolean')
139
+ actualVal = lastData?.boolValue;
140
+ if (typeof expectedValue === 'object')
141
+ actualVal = lastData?.vector;
142
+ const isMatch = JSON.stringify(actualVal) === JSON.stringify(expectedValue);
143
+ if (isMatch === !isNot) {
144
+ return { pass: !isNot, message: () => 'passed' };
145
+ }
146
+ }
147
+ catch (e) { }
148
+ await new Promise(r => setTimeout(r, 100));
149
+ }
150
+ return {
151
+ pass: isNot,
152
+ message: () => `Expected Input Action "${actionNameOrPath}" value to${isNot ? ' not' : ''} be ${JSON.stringify(expectedValue)}, but got ${JSON.stringify(lastData?.value)}`,
153
+ actual: lastData,
154
+ expected: expectedValue
155
+ };
156
+ },
157
+ async toHavePlayerScore(locator, expectedScore, options) {
158
+ const isNot = this.isNot;
159
+ const timeout = options?.timeout ?? 5000;
160
+ const operator = options?.operator ?? '===';
161
+ const startTime = Date.now();
162
+ let lastScore = 0;
163
+ while (Date.now() - startTime < timeout) {
164
+ try {
165
+ const info = await locator.getPlayerStateInfo();
166
+ lastScore = info?.score ?? 0;
167
+ let pass = false;
168
+ if (operator === '===')
169
+ pass = lastScore === expectedScore;
170
+ else if (operator === '>')
171
+ pass = lastScore > expectedScore;
172
+ else if (operator === '>=')
173
+ pass = lastScore >= expectedScore;
174
+ else if (operator === '<')
175
+ pass = lastScore < expectedScore;
176
+ else if (operator === '<=')
177
+ pass = lastScore <= expectedScore;
178
+ if (pass === !isNot) {
179
+ return { pass: !isNot, message: () => 'passed' };
180
+ }
181
+ }
182
+ catch (e) { }
183
+ await new Promise(r => setTimeout(r, 100));
184
+ }
185
+ return {
186
+ pass: isNot,
187
+ message: () => `Expected PlayerState score to${isNot ? ' not' : ''} be ${operator} ${expectedScore}, but got ${lastScore}`,
188
+ actual: lastScore,
189
+ expected: expectedScore
190
+ };
191
+ },
192
+ async toBeNiagaraActive(locator, options) {
193
+ const isNot = this.isNot;
194
+ const timeout = options?.timeout ?? 5000;
195
+ const startTime = Date.now();
196
+ let lastState = false;
197
+ while (Date.now() - startTime < timeout) {
198
+ try {
199
+ lastState = await locator.isNiagaraActive();
200
+ if (lastState === !isNot) {
201
+ return { pass: !isNot, message: () => 'passed' };
202
+ }
203
+ }
204
+ catch (e) { }
205
+ await new Promise(r => setTimeout(r, 100));
206
+ }
207
+ return {
208
+ pass: isNot,
209
+ message: () => `Expected NiagaraComponent to${isNot ? ' not' : ''} be active, but it was${lastState ? '' : ' not'}.`
210
+ };
211
+ },
212
+ async toHaveNiagaraAsset(locator, expectedAsset, options) {
213
+ const isNot = this.isNot;
214
+ const timeout = options?.timeout ?? 5000;
215
+ const startTime = Date.now();
216
+ let lastAsset = "";
217
+ while (Date.now() - startTime < timeout) {
218
+ try {
219
+ lastAsset = await locator.getNiagaraAsset();
220
+ const isMatch = lastAsset.toLowerCase().includes(expectedAsset.toLowerCase());
221
+ if (isMatch === !isNot) {
222
+ return { pass: !isNot, message: () => 'passed' };
223
+ }
224
+ }
225
+ catch (e) { }
226
+ await new Promise(r => setTimeout(r, 100));
227
+ }
228
+ return {
229
+ pass: isNot,
230
+ message: () => `Expected Niagara asset to${isNot ? ' not' : ''} contain "${expectedAsset}", but got "${lastAsset}"`,
231
+ actual: lastAsset,
232
+ expected: expectedAsset
233
+ };
234
+ },
235
+ async toBeAudioPlaying(locator, options) {
236
+ const isNot = this.isNot;
237
+ const timeout = options?.timeout ?? 5000;
238
+ const startTime = Date.now();
239
+ let lastState = false;
240
+ while (Date.now() - startTime < timeout) {
241
+ try {
242
+ lastState = await locator.isAudioPlaying();
243
+ if (lastState === !isNot) {
244
+ return { pass: !isNot, message: () => 'passed' };
245
+ }
246
+ }
247
+ catch (e) { }
248
+ await new Promise(r => setTimeout(r, 100));
249
+ }
250
+ return {
251
+ pass: isNot,
252
+ message: () => `Expected AudioComponent to${isNot ? ' not' : ''} be playing audio, but it was${lastState ? '' : ' not'}.`
253
+ };
254
+ },
255
+ async toHaveSoundAsset(locator, expectedSound, options) {
256
+ const isNot = this.isNot;
257
+ const timeout = options?.timeout ?? 5000;
258
+ const startTime = Date.now();
259
+ let lastSound = "";
260
+ while (Date.now() - startTime < timeout) {
261
+ try {
262
+ lastSound = await locator.getSoundAsset();
263
+ const isMatch = lastSound.toLowerCase().includes(expectedSound.toLowerCase());
264
+ if (isMatch === !isNot) {
265
+ return { pass: !isNot, message: () => 'passed' };
266
+ }
267
+ }
268
+ catch (e) { }
269
+ await new Promise(r => setTimeout(r, 100));
270
+ }
271
+ return {
272
+ pass: isNot,
273
+ message: () => `Expected Audio sound asset to${isNot ? ' not' : ''} contain "${expectedSound}", but got "${lastSound}"`,
274
+ actual: lastSound,
275
+ expected: expectedSound
276
+ };
277
+ },
278
+ async toBePhysicsSimulating(locator, options) {
279
+ const isNot = this.isNot;
280
+ const timeout = options?.timeout ?? 5000;
281
+ const startTime = Date.now();
282
+ let lastState = false;
283
+ while (Date.now() - startTime < timeout) {
284
+ try {
285
+ lastState = await locator.isPhysicsSimulating(options?.boneName);
286
+ if (lastState === !isNot) {
287
+ return { pass: !isNot, message: () => 'passed' };
288
+ }
289
+ }
290
+ catch (e) { }
291
+ await new Promise(r => setTimeout(r, 100));
292
+ }
293
+ return {
294
+ pass: isNot,
295
+ message: () => `Expected Actor physics simulation to${isNot ? ' not' : ''} be active, but it was${lastState ? '' : ' not'}.`
296
+ };
297
+ },
298
+ async toBePhysicsAsleep(locator, options) {
299
+ const isNot = this.isNot;
300
+ const timeout = options?.timeout ?? 5000;
301
+ const startTime = Date.now();
302
+ let lastState = false;
303
+ while (Date.now() - startTime < timeout) {
304
+ try {
305
+ lastState = await locator.isPhysicsAsleep(options?.boneName);
306
+ if (lastState === !isNot) {
307
+ return { pass: !isNot, message: () => 'passed' };
308
+ }
309
+ }
310
+ catch (e) { }
311
+ await new Promise(r => setTimeout(r, 100));
312
+ }
313
+ return {
314
+ pass: isNot,
315
+ message: () => `Expected Actor rigid body to${isNot ? ' not' : ''} be asleep, but it was${lastState ? '' : ' not'}.`
316
+ };
317
+ },
318
+ async toHaveVelocity(locator, expectedSpeed, options) {
319
+ const isNot = this.isNot;
320
+ const timeout = options?.timeout ?? 5000;
321
+ const operator = options?.operator ?? '>=';
322
+ const startTime = Date.now();
323
+ let lastSpeed = 0;
324
+ while (Date.now() - startTime < timeout) {
325
+ try {
326
+ const velInfo = await locator.getPhysicsVelocity(options?.boneName);
327
+ lastSpeed = velInfo?.speed ?? 0;
328
+ let pass = false;
329
+ if (operator === '===')
330
+ pass = Math.abs(lastSpeed - expectedSpeed) < 0.1;
331
+ else if (operator === '>')
332
+ pass = lastSpeed > expectedSpeed;
333
+ else if (operator === '>=')
334
+ pass = lastSpeed >= expectedSpeed;
335
+ else if (operator === '<')
336
+ pass = lastSpeed < expectedSpeed;
337
+ else if (operator === '<=')
338
+ pass = lastSpeed <= expectedSpeed;
339
+ if (pass === !isNot) {
340
+ return { pass: !isNot, message: () => 'passed' };
341
+ }
342
+ }
343
+ catch (e) { }
344
+ await new Promise(r => setTimeout(r, 100));
345
+ }
346
+ return {
347
+ pass: isNot,
348
+ message: () => `Expected physics speed to${isNot ? ' not' : ''} be ${operator} ${expectedSpeed}, but got ${lastSpeed.toFixed(2)} cm/s`,
349
+ actual: lastSpeed,
350
+ expected: expectedSpeed
351
+ };
352
+ },
353
+ async toHaveCameraFOV(locator, expectedFOV, options) {
354
+ const isNot = this.isNot;
355
+ const timeout = options?.timeout ?? 5000;
356
+ const tolerance = options?.tolerance ?? 0.5;
357
+ const startTime = Date.now();
358
+ let lastFOV = 0;
359
+ while (Date.now() - startTime < timeout) {
360
+ try {
361
+ lastFOV = await locator.getCameraFOV();
362
+ const isMatch = Math.abs(lastFOV - expectedFOV) <= tolerance;
363
+ if (isMatch === !isNot) {
364
+ return { pass: !isNot, message: () => 'passed' };
365
+ }
366
+ }
367
+ catch (e) { }
368
+ await new Promise(r => setTimeout(r, 100));
369
+ }
370
+ return {
371
+ pass: isNot,
372
+ message: () => `Expected camera FOV to${isNot ? ' not' : ''} be ${expectedFOV}° (±${tolerance}°), but got ${lastFOV.toFixed(1)}°`,
373
+ actual: lastFOV,
374
+ expected: expectedFOV
375
+ };
376
+ },
377
+ async toBeCameraShaking(locator, options) {
378
+ const isNot = this.isNot;
379
+ const timeout = options?.timeout ?? 5000;
380
+ const startTime = Date.now();
381
+ let lastState = false;
382
+ while (Date.now() - startTime < timeout) {
383
+ try {
384
+ lastState = await locator.isCameraShaking();
385
+ if (lastState === !isNot) {
386
+ return { pass: !isNot, message: () => 'passed' };
387
+ }
388
+ }
389
+ catch (e) { }
390
+ await new Promise(r => setTimeout(r, 100));
391
+ }
392
+ return {
393
+ pass: isNot,
394
+ message: () => `Expected camera to${isNot ? ' not' : ''} be shaking, but it was${lastState ? '' : ' not'}.`
395
+ };
396
+ },
397
+ async toHaveCameraViewTarget(locator, expectedTarget, options) {
398
+ const isNot = this.isNot;
399
+ const timeout = options?.timeout ?? 5000;
400
+ const startTime = Date.now();
401
+ let lastTarget = "";
402
+ while (Date.now() - startTime < timeout) {
403
+ try {
404
+ lastTarget = await locator.getCameraViewTarget();
405
+ const isMatch = lastTarget.toLowerCase().includes(expectedTarget.toLowerCase());
406
+ if (isMatch === !isNot) {
407
+ return { pass: !isNot, message: () => 'passed' };
408
+ }
409
+ }
410
+ catch (e) { }
411
+ await new Promise(r => setTimeout(r, 100));
412
+ }
413
+ return {
414
+ pass: isNot,
415
+ message: () => `Expected camera ViewTarget to${isNot ? ' not' : ''} contain "${expectedTarget}", but got "${lastTarget}"`,
416
+ actual: lastTarget,
417
+ expected: expectedTarget
418
+ };
419
+ },
420
+ async toBeAINavigating(locator, options) {
421
+ const isNot = this.isNot;
422
+ const timeout = options?.timeout ?? 5000;
423
+ const startTime = Date.now();
424
+ let lastState = false;
425
+ while (Date.now() - startTime < timeout) {
426
+ try {
427
+ lastState = await locator.isAINavigating();
428
+ if (lastState === !isNot) {
429
+ return { pass: !isNot, message: () => 'passed' };
430
+ }
431
+ }
432
+ catch (e) { }
433
+ await new Promise(r => setTimeout(r, 100));
434
+ }
435
+ return {
436
+ pass: isNot,
437
+ message: () => `Expected AI to${isNot ? ' not' : ''} be actively navigating on NavMesh, but it was${lastState ? '' : ' not'}.`
438
+ };
439
+ },
440
+ async toHaveGameplayTag(locator, expectedTag, options) {
441
+ const isNot = this.isNot;
442
+ const timeout = options?.timeout ?? 5000;
443
+ const startTime = Date.now();
444
+ let lastHas = false;
445
+ while (Date.now() - startTime < timeout) {
446
+ try {
447
+ lastHas = await locator.hasGameplayTag(expectedTag);
448
+ if (lastHas === !isNot) {
449
+ return { pass: !isNot, message: () => 'passed' };
450
+ }
451
+ }
452
+ catch (e) { }
453
+ await new Promise(r => setTimeout(r, 100));
454
+ }
455
+ return {
456
+ pass: isNot,
457
+ message: () => `Expected Actor to${isNot ? ' not' : ''} have Gameplay Tag "${expectedTag}", but it did${lastHas ? '' : ' not'}.`
458
+ };
459
+ },
460
+ async toHaveTeamId(locator, expectedTeamId, options) {
461
+ const isNot = this.isNot;
462
+ const timeout = options?.timeout ?? 5000;
463
+ const startTime = Date.now();
464
+ let lastId = 255;
465
+ while (Date.now() - startTime < timeout) {
466
+ try {
467
+ lastId = await locator.getTeamId();
468
+ if ((lastId === expectedTeamId) === !isNot) {
469
+ return { pass: !isNot, message: () => 'passed' };
470
+ }
471
+ }
472
+ catch (e) { }
473
+ await new Promise(r => setTimeout(r, 100));
474
+ }
475
+ return {
476
+ pass: isNot,
477
+ message: () => `Expected Actor to${isNot ? ' not' : ''} have Team ID ${expectedTeamId}, but got ${lastId}.`,
478
+ actual: lastId,
479
+ expected: expectedTeamId
480
+ };
481
+ },
482
+ async toBeHostileTowards(locator, otherActor, options) {
483
+ const isNot = this.isNot;
484
+ const timeout = options?.timeout ?? 5000;
485
+ const startTime = Date.now();
486
+ let lastAttitude = 'Neutral';
487
+ while (Date.now() - startTime < timeout) {
488
+ try {
489
+ lastAttitude = await locator.getTeamAttitudeTowards(otherActor);
490
+ if ((lastAttitude === 'Hostile') === !isNot) {
491
+ return { pass: !isNot, message: () => 'passed' };
492
+ }
493
+ }
494
+ catch (e) { }
495
+ await new Promise(r => setTimeout(r, 100));
496
+ }
497
+ return {
498
+ pass: isNot,
499
+ message: () => `Expected Actor to${isNot ? ' not' : ''} be Hostile towards target, but attitude was ${lastAttitude}.`,
500
+ actual: lastAttitude,
501
+ expected: 'Hostile'
502
+ };
503
+ },
504
+ async toBePossessed(locator, options) {
505
+ const isNot = this.isNot;
506
+ const timeout = options?.timeout ?? 5000;
507
+ const prefix = isNot ? 'not.toBePossessed' : 'toBePossessed';
508
+ const portStr = locator.portTag || '';
509
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
510
+ return await test_1.default.step(stepName, async () => {
511
+ let lastInfo = null;
512
+ try {
513
+ await test_1.expect.poll(async () => {
514
+ lastInfo = await locator.getControllerInfo();
515
+ return lastInfo.isPossessed;
516
+ }, { timeout }).toBe(!isNot);
517
+ return { pass: !isNot, message: () => 'passed' };
518
+ }
519
+ catch (e) {
520
+ return {
521
+ pass: isNot,
522
+ message: () => `Timed out waiting for actor to be ${isNot ? 'unpossessed' : 'possessed'}.\n` +
523
+ `Received: ${lastInfo ? (lastInfo.isPossessed ? `Possessed by ${lastInfo.controllerClass}` : 'Unpossessed') : 'null'}`
524
+ };
525
+ }
526
+ });
527
+ },
528
+ async toBePlayerControlled(locator, options) {
529
+ const isNot = this.isNot;
530
+ const timeout = options?.timeout ?? 5000;
531
+ const prefix = isNot ? 'not.toBePlayerControlled' : 'toBePlayerControlled';
532
+ const portStr = locator.portTag || '';
533
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
534
+ return await test_1.default.step(stepName, async () => {
535
+ let lastInfo = null;
536
+ try {
537
+ await test_1.expect.poll(async () => {
538
+ lastInfo = await locator.getControllerInfo();
539
+ return lastInfo.isPlayerControlled;
540
+ }, { timeout }).toBe(!isNot);
541
+ return { pass: !isNot, message: () => 'passed' };
542
+ }
543
+ catch (e) {
544
+ return {
545
+ pass: isNot,
546
+ message: () => `Timed out waiting for actor to be ${isNot ? 'not player controlled' : 'player controlled'}.\n` +
547
+ `Received controller: ${lastInfo?.controllerClass || 'None (Unpossessed)'}`
548
+ };
549
+ }
550
+ });
551
+ },
552
+ async toBeLocallyControlled(locator, options) {
553
+ const isNot = this.isNot;
554
+ const timeout = options?.timeout ?? 5000;
555
+ const prefix = isNot ? 'not.toBeLocallyControlled' : 'toBeLocallyControlled';
556
+ const portStr = locator.portTag || '';
557
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
558
+ return await test_1.default.step(stepName, async () => {
559
+ let lastInfo = null;
560
+ try {
561
+ await test_1.expect.poll(async () => {
562
+ lastInfo = await locator.getControllerInfo();
563
+ return lastInfo.isLocallyControlled;
564
+ }, { timeout }).toBe(!isNot);
565
+ return { pass: !isNot, message: () => 'passed' };
566
+ }
567
+ catch (e) {
568
+ return {
569
+ pass: isNot,
570
+ message: () => `Timed out waiting for actor to be ${isNot ? 'not locally controlled' : 'locally controlled'}.\n` +
571
+ `Received: isLocallyControlled=${lastInfo?.isLocallyControlled}`
572
+ };
573
+ }
574
+ });
575
+ },
576
+ async toHaveController(locator, expectedControllerClass, options) {
577
+ const isNot = this.isNot;
578
+ const timeout = options?.timeout ?? 5000;
579
+ const prefix = isNot ? 'not.toHaveController' : 'toHaveController';
580
+ const portStr = locator.portTag || '';
581
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}(${expectedControllerClass ? JSON.stringify(expectedControllerClass) : ''})`;
582
+ return await test_1.default.step(stepName, async () => {
583
+ let lastInfo = null;
584
+ try {
585
+ await test_1.expect.poll(async () => {
586
+ lastInfo = await locator.getControllerInfo();
587
+ if (!lastInfo.isPossessed)
588
+ return false;
589
+ if (!expectedControllerClass)
590
+ return true;
591
+ return (lastInfo.controllerClass && lastInfo.controllerClass.includes(expectedControllerClass)) ||
592
+ (lastInfo.controllerName && lastInfo.controllerName.includes(expectedControllerClass));
593
+ }, { timeout }).toBe(!isNot);
594
+ return { pass: !isNot, message: () => 'passed' };
595
+ }
596
+ catch (e) {
597
+ return {
598
+ pass: isNot,
599
+ message: () => `Timed out waiting for actor to have controller ${expectedControllerClass ? `'${expectedControllerClass}'` : 'attached'}.\n` +
600
+ `Received: ${lastInfo?.controllerClass || 'None (Unpossessed)'}`
601
+ };
602
+ }
603
+ });
604
+ },
605
+ async toBeFalling(locator, options) {
606
+ const isNot = this.isNot;
607
+ const timeout = options?.timeout ?? 5000;
608
+ const prefix = isNot ? 'not.toBeFalling' : 'toBeFalling';
609
+ const portStr = locator.portTag || '';
610
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
611
+ return await test_1.default.step(stepName, async () => {
612
+ // 1. Initial State Check: 0ms return if already in desired state
613
+ let current = await locator.isFalling();
614
+ if (isNot ? !current : current) {
615
+ return { pass: !isNot, message: () => 'passed' };
616
+ }
617
+ // 2. Native Event Wait: React immediately on exact tick
618
+ try {
619
+ if (isNot) {
620
+ // Waiting to STOP falling -> either OnLanded or OnMovementModeChanged
621
+ await Promise.race([
622
+ locator.waitForEvent('OnLanded', { timeout }),
623
+ locator.waitForEvent('OnMovementModeChanged', {
624
+ timeout,
625
+ predicate: (data) => data?.movementMode !== 'Falling' && data?.isFalling === false
626
+ })
627
+ ]);
628
+ }
629
+ else {
630
+ // Waiting to START falling -> OnMovementModeChanged
631
+ await locator.waitForEvent('OnMovementModeChanged', {
632
+ timeout,
633
+ predicate: (data) => data?.movementMode === 'Falling' || data?.isFalling === true
634
+ });
635
+ }
636
+ return { pass: !isNot, message: () => 'passed' };
637
+ }
638
+ catch (e) {
639
+ current = await locator.isFalling();
640
+ if (isNot ? !current : current) {
641
+ return { pass: !isNot, message: () => 'passed' };
642
+ }
643
+ return {
644
+ pass: isNot,
645
+ message: () => `Timed out waiting for actor to ${isNot ? 'stop falling' : 'be falling'}.\n` +
646
+ `Received: isFalling=${current}`
647
+ };
648
+ }
649
+ });
650
+ },
651
+ async toBeSwimming(locator, options) {
652
+ const isNot = this.isNot;
653
+ const timeout = options?.timeout ?? 5000;
654
+ const prefix = isNot ? 'not.toBeSwimming' : 'toBeSwimming';
655
+ const portStr = locator.portTag || '';
656
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
657
+ return await test_1.default.step(stepName, async () => {
658
+ // 1. Initial State Check
659
+ let current = await locator.isSwimming();
660
+ if (isNot ? !current : current) {
661
+ return { pass: !isNot, message: () => 'passed' };
662
+ }
663
+ // 2. Native Event Wait
664
+ try {
665
+ await locator.waitForEvent('OnMovementModeChanged', {
666
+ timeout,
667
+ predicate: (data) => isNot
668
+ ? (data?.movementMode !== 'Swimming' && data?.isSwimming === false)
669
+ : (data?.movementMode === 'Swimming' || data?.isSwimming === true)
670
+ });
671
+ return { pass: !isNot, message: () => 'passed' };
672
+ }
673
+ catch (e) {
674
+ current = await locator.isSwimming();
675
+ if (isNot ? !current : current) {
676
+ return { pass: !isNot, message: () => 'passed' };
677
+ }
678
+ return {
679
+ pass: isNot,
680
+ message: () => `Timed out waiting for actor to ${isNot ? 'stop swimming' : 'be swimming'}.\n` +
681
+ `Received: isSwimming=${current}`
682
+ };
683
+ }
684
+ });
685
+ },
686
+ async toBeFlying(locator, options) {
687
+ const isNot = this.isNot;
688
+ const timeout = options?.timeout ?? 5000;
689
+ const prefix = isNot ? 'not.toBeFlying' : 'toBeFlying';
690
+ const portStr = locator.portTag || '';
691
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
692
+ return await test_1.default.step(stepName, async () => {
693
+ // 1. Initial State Check
694
+ let current = await locator.isFlying();
695
+ if (isNot ? !current : current) {
696
+ return { pass: !isNot, message: () => 'passed' };
697
+ }
698
+ // 2. Native Event Wait
699
+ try {
700
+ await locator.waitForEvent('OnMovementModeChanged', {
701
+ timeout,
702
+ predicate: (data) => isNot
703
+ ? (data?.movementMode !== 'Flying' && data?.isFlying === false)
704
+ : (data?.movementMode === 'Flying' || data?.isFlying === true)
705
+ });
706
+ return { pass: !isNot, message: () => 'passed' };
707
+ }
708
+ catch (e) {
709
+ current = await locator.isFlying();
710
+ if (isNot ? !current : current) {
711
+ return { pass: !isNot, message: () => 'passed' };
712
+ }
713
+ return {
714
+ pass: isNot,
715
+ message: () => `Timed out waiting for actor to ${isNot ? 'stop flying' : 'be flying'}.\n` +
716
+ `Received: isFlying=${current}`
717
+ };
718
+ }
719
+ });
720
+ },
721
+ async toBeCrouching(locator, options) {
722
+ const isNot = this.isNot;
723
+ const timeout = options?.timeout ?? 5000;
724
+ const prefix = isNot ? 'not.toBeCrouching' : 'toBeCrouching';
725
+ const portStr = locator.portTag || '';
726
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
727
+ return await test_1.default.step(stepName, async () => {
728
+ // 1. Initial State Check
729
+ let current = await locator.isCrouching();
730
+ if (isNot ? !current : current) {
731
+ return { pass: !isNot, message: () => 'passed' };
732
+ }
733
+ // 2. Native Event Wait
734
+ try {
735
+ await locator.waitForEvent('OnMovementModeChanged', {
736
+ timeout,
737
+ predicate: (data) => isNot ? !data?.isCrouching : !!data?.isCrouching
738
+ });
739
+ return { pass: !isNot, message: () => 'passed' };
740
+ }
741
+ catch (e) {
742
+ current = await locator.isCrouching();
743
+ if (isNot ? !current : current) {
744
+ return { pass: !isNot, message: () => 'passed' };
745
+ }
746
+ return {
747
+ pass: isNot,
748
+ message: () => `Timed out waiting for actor to ${isNot ? 'stop crouching' : 'be crouching'}.\n` +
749
+ `Received: isCrouching=${current}`
750
+ };
751
+ }
752
+ });
753
+ },
754
+ async toBeMovingOnGround(locator, options) {
755
+ const isNot = this.isNot;
756
+ const timeout = options?.timeout ?? 5000;
757
+ const prefix = isNot ? 'not.toBeMovingOnGround' : 'toBeMovingOnGround';
758
+ const portStr = locator.portTag || '';
759
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
760
+ return await test_1.default.step(stepName, async () => {
761
+ // 1. Initial State Check
762
+ let current = await locator.isMovingOnGround();
763
+ if (isNot ? !current : current) {
764
+ return { pass: !isNot, message: () => 'passed' };
765
+ }
766
+ // 2. Native Event Wait
767
+ try {
768
+ if (!isNot) {
769
+ // Waiting to touch ground
770
+ await Promise.race([
771
+ locator.waitForEvent('OnLanded', { timeout }),
772
+ locator.waitForEvent('OnMovementModeChanged', {
773
+ timeout,
774
+ predicate: (data) => data?.isMovingOnGround === true || data?.movementMode === 'Walking' || data?.movementMode === 'NavWalking'
775
+ })
776
+ ]);
777
+ }
778
+ else {
779
+ // Waiting to leave ground
780
+ await locator.waitForEvent('OnMovementModeChanged', {
781
+ timeout,
782
+ predicate: (data) => data?.isMovingOnGround === false
783
+ });
784
+ }
785
+ return { pass: !isNot, message: () => 'passed' };
786
+ }
787
+ catch (e) {
788
+ current = await locator.isMovingOnGround();
789
+ if (isNot ? !current : current) {
790
+ return { pass: !isNot, message: () => 'passed' };
791
+ }
792
+ return {
793
+ pass: isNot,
794
+ message: () => `Timed out waiting for actor to ${isNot ? 'leave the ground' : 'be moving on ground'}.\n` +
795
+ `Received: isMovingOnGround=${current}`
796
+ };
797
+ }
798
+ });
799
+ },
800
+ async toHaveMovementMode(locator, expectedMode, options) {
801
+ const isNot = this.isNot;
802
+ const timeout = options?.timeout ?? 5000;
803
+ const prefix = isNot ? 'not.toHaveMovementMode' : 'toHaveMovementMode';
804
+ const portStr = locator.portTag || '';
805
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}('${expectedMode}')`;
806
+ return await test_1.default.step(stepName, async () => {
807
+ // 1. Initial State Check
808
+ const info = await locator.getMovementMode();
809
+ let lastMode = typeof info === 'string' ? info : (info?.movementMode ?? info?.mode ?? 'None');
810
+ const matches = (lastMode ?? '').toLowerCase() === expectedMode.toLowerCase();
811
+ if (isNot ? !matches : matches) {
812
+ return { pass: !isNot, message: () => 'passed' };
813
+ }
814
+ // 2. Native Event Wait
815
+ try {
816
+ await locator.waitForEvent('OnMovementModeChanged', {
817
+ timeout,
818
+ predicate: (data) => {
819
+ const mode = (data?.movementMode ?? '').toLowerCase();
820
+ const isMatch = mode === expectedMode.toLowerCase();
821
+ return isNot ? !isMatch : isMatch;
822
+ }
823
+ });
824
+ return { pass: !isNot, message: () => 'passed' };
825
+ }
826
+ catch (e) {
827
+ const finalInfo = await locator.getMovementMode();
828
+ lastMode = typeof finalInfo === 'string' ? finalInfo : (finalInfo?.movementMode ?? finalInfo?.mode ?? 'None');
829
+ const finalMatches = (lastMode ?? '').toLowerCase() === expectedMode.toLowerCase();
830
+ if (isNot ? !finalMatches : finalMatches) {
831
+ return { pass: !isNot, message: () => 'passed' };
832
+ }
833
+ return {
834
+ pass: isNot,
835
+ message: () => `Timed out waiting for actor to ${isNot ? 'not have' : 'have'} movement mode '${expectedMode}'.\n` +
836
+ `Received: '${lastMode}'`
837
+ };
838
+ }
839
+ });
840
+ }
841
+ });