@specter-automation/test 1.0.158 → 1.0.160
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/specter-locator.d.ts +7 -0
- package/dist/core/locators/specter-locator.js +30 -1
- package/dist/core/specter-client.d.ts +16 -0
- package/dist/core/specter-client.js +26 -0
- package/dist/core/test-wrapper.js +9 -0
- package/dist/matchers/gas-matchers.js +10 -0
- package/package.json +1 -1
|
@@ -100,6 +100,13 @@ export declare class SpecterLocator<T = any> {
|
|
|
100
100
|
* locator files add themselves here, since this file can't import them.
|
|
101
101
|
*/
|
|
102
102
|
static locatorFactories: Record<string, (transport: SpecterTransport, pipeline: LocatorStep[]) => SpecterLocator<any>>;
|
|
103
|
+
private static warnedLowerCaseKeys;
|
|
104
|
+
/**
|
|
105
|
+
* Struct fields used to come back lower-cased ("eventtype" for EventType). They now come back as declared.
|
|
106
|
+
* Tests written against the old names keep working through hidden aliases, which warn once each.
|
|
107
|
+
* The aliases aren't enumerable, so they don't show in toEqual, Object.keys or JSON.
|
|
108
|
+
*/
|
|
109
|
+
private static addLowerCaseAliases;
|
|
103
110
|
/** Turns the engine's object references (in a value, an array or a struct) into locators */
|
|
104
111
|
protected hydrateValue(val: any): any;
|
|
105
112
|
getMaterialScalarParameter(parameterName: string, options?: {
|
|
@@ -247,8 +247,11 @@ class SpecterLocator {
|
|
|
247
247
|
return data;
|
|
248
248
|
}
|
|
249
249
|
const unpackValue = (val) => this.hydrateValue(val);
|
|
250
|
+
// A function with one output gives that value, whatever the output is called: a Blueprint
|
|
251
|
+
// function's output pin named "Open" used to come back as { Open: true }. With several outputs,
|
|
252
|
+
// an object of them by name.
|
|
250
253
|
const keys = Object.keys(data);
|
|
251
|
-
if (keys.length === 1
|
|
254
|
+
if (keys.length === 1) {
|
|
252
255
|
return unpackValue(data[keys[0]]);
|
|
253
256
|
}
|
|
254
257
|
if (keys.length === 0) {
|
|
@@ -291,6 +294,31 @@ class SpecterLocator {
|
|
|
291
294
|
* locator files add themselves here, since this file can't import them.
|
|
292
295
|
*/
|
|
293
296
|
static locatorFactories = {};
|
|
297
|
+
static warnedLowerCaseKeys = new Set();
|
|
298
|
+
/**
|
|
299
|
+
* Struct fields used to come back lower-cased ("eventtype" for EventType). They now come back as declared.
|
|
300
|
+
* Tests written against the old names keep working through hidden aliases, which warn once each.
|
|
301
|
+
* The aliases aren't enumerable, so they don't show in toEqual, Object.keys or JSON.
|
|
302
|
+
*/
|
|
303
|
+
static addLowerCaseAliases(obj) {
|
|
304
|
+
for (const key of Object.keys(obj)) {
|
|
305
|
+
const lower = key.toLowerCase();
|
|
306
|
+
if (lower === key || lower in obj) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
Object.defineProperty(obj, lower, {
|
|
310
|
+
enumerable: false,
|
|
311
|
+
configurable: true,
|
|
312
|
+
get() {
|
|
313
|
+
if (!SpecterLocator.warnedLowerCaseKeys.has(lower)) {
|
|
314
|
+
SpecterLocator.warnedLowerCaseKeys.add(lower);
|
|
315
|
+
console.warn(`[SPECTER] "${lower}" is the old lower-cased name of the struct field "${key}". Use "${key}": the old name will stop working in a later version.`);
|
|
316
|
+
}
|
|
317
|
+
return obj[key];
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
294
322
|
/** Turns the engine's object references (in a value, an array or a struct) into locators */
|
|
295
323
|
hydrateValue(val) {
|
|
296
324
|
if (Array.isArray(val)) {
|
|
@@ -325,6 +353,7 @@ class SpecterLocator {
|
|
|
325
353
|
for (const [key, inner] of Object.entries(val)) {
|
|
326
354
|
out[key] = this.hydrateValue(inner);
|
|
327
355
|
}
|
|
356
|
+
SpecterLocator.addLowerCaseAliases(out);
|
|
328
357
|
return out;
|
|
329
358
|
}
|
|
330
359
|
}
|
|
@@ -129,6 +129,11 @@ export interface SpecterDiagnosticsReport {
|
|
|
129
129
|
worldTime: number;
|
|
130
130
|
deltaSeconds: number;
|
|
131
131
|
};
|
|
132
|
+
/** What the test before this one left changed: a moved pawn or camera, a screen left open, pause */
|
|
133
|
+
previousTestLeftChanged?: {
|
|
134
|
+
test: string;
|
|
135
|
+
changes: string[];
|
|
136
|
+
};
|
|
132
137
|
}
|
|
133
138
|
export type { Vector3, Vector2D, Rotator, Transform } from './specter-math';
|
|
134
139
|
export { VectorUtils, RotatorUtils, resolveVector3, resolveRotator, normalizeAxis, findLookAtRotation, getRotationBetween, calculateDistance, calculateDistance2D, normalizeRotator, deltaRotator } from './specter-math';
|
|
@@ -570,6 +575,17 @@ export declare class SpecterWorld {
|
|
|
570
575
|
map: string;
|
|
571
576
|
serverAddress: string;
|
|
572
577
|
}>;
|
|
578
|
+
/**
|
|
579
|
+
* Notes the state a test can leave behind for the next one (each player's pawn and camera, the screens
|
|
580
|
+
* showing, pause, time dilation). The test fixture calls it when a test starts; `endLeftStateCheck` compares.
|
|
581
|
+
* Does nothing on a plugin that doesn't have it.
|
|
582
|
+
*/
|
|
583
|
+
beginLeftStateCheck(testName: string): Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* What changed since `beginLeftStateCheck`, after the test's afterEach hooks. Specter can't put the game
|
|
586
|
+
* back itself (only the game knows its starting state), but the next test's failure report names these.
|
|
587
|
+
*/
|
|
588
|
+
endLeftStateCheck(): Promise<string[]>;
|
|
573
589
|
cleanup(): Promise<void>;
|
|
574
590
|
/**
|
|
575
591
|
* Restores the primary PlayerController to its pre-possession state
|
|
@@ -1209,6 +1209,32 @@ class SpecterWorld {
|
|
|
1209
1209
|
const response = await this.evaluate("GetNetworkStatus", {});
|
|
1210
1210
|
return response.data;
|
|
1211
1211
|
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Notes the state a test can leave behind for the next one (each player's pawn and camera, the screens
|
|
1214
|
+
* showing, pause, time dilation). The test fixture calls it when a test starts; `endLeftStateCheck` compares.
|
|
1215
|
+
* Does nothing on a plugin that doesn't have it.
|
|
1216
|
+
*/
|
|
1217
|
+
async beginLeftStateCheck(testName) {
|
|
1218
|
+
try {
|
|
1219
|
+
await this.evaluate("BeginLeftStateCheck", { testName }, undefined, undefined, true);
|
|
1220
|
+
}
|
|
1221
|
+
catch (e) {
|
|
1222
|
+
// An older plugin: no check
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* What changed since `beginLeftStateCheck`, after the test's afterEach hooks. Specter can't put the game
|
|
1227
|
+
* back itself (only the game knows its starting state), but the next test's failure report names these.
|
|
1228
|
+
*/
|
|
1229
|
+
async endLeftStateCheck() {
|
|
1230
|
+
try {
|
|
1231
|
+
const response = await this.evaluate("EndLeftStateCheck", {}, undefined, undefined, true);
|
|
1232
|
+
return Array.isArray(response?.data?.changes) ? response.data.changes : [];
|
|
1233
|
+
}
|
|
1234
|
+
catch (e) {
|
|
1235
|
+
return [];
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1212
1238
|
async cleanup() {
|
|
1213
1239
|
if (!this.transport.isConnected)
|
|
1214
1240
|
return;
|
|
@@ -79,11 +79,20 @@ const extendedTest = test_1.test.extend({
|
|
|
79
79
|
if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
|
|
80
80
|
await world.console(`r.FixedDeltaTime ${fixedDeltaSeconds}`);
|
|
81
81
|
}
|
|
82
|
+
// Tests share one game: note what this one might leave changed for the next
|
|
83
|
+
await world.beginLeftStateCheck(testInfo.titlePath.slice(1).join(' > '));
|
|
82
84
|
try {
|
|
83
85
|
await use(world);
|
|
84
86
|
}
|
|
85
87
|
finally {
|
|
86
88
|
(0, failure_capture_1.setActiveWorld)(null);
|
|
89
|
+
// After afterEach: what this test left changed. Said here, on the test that did it, and again in the
|
|
90
|
+
// next test's failure report.
|
|
91
|
+
const leftChanged = await world.endLeftStateCheck();
|
|
92
|
+
if (leftChanged.length > 0) {
|
|
93
|
+
console.warn(`[SPECTER] This test left the game changed for the next test:\n${leftChanged.map(change => ` - ${change}`).join('\n')}\n` +
|
|
94
|
+
` Specter can't reset game state (only the game knows its start). Reset it in your fixture or afterEach if later tests depend on it.`);
|
|
95
|
+
}
|
|
87
96
|
// Teardown: Reset fixed delta time if configured
|
|
88
97
|
if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
|
|
89
98
|
try {
|
|
@@ -69,6 +69,16 @@ function formatAiDiagnostics(diagnostics) {
|
|
|
69
69
|
lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
70
70
|
lines.push('🧠 SPECTER AI DIAGNOSTICS REPORT');
|
|
71
71
|
lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
72
|
+
// 0. What the test before this one left changed. First: in a full run it's often the whole story.
|
|
73
|
+
const left = diagnostics.previousTestLeftChanged;
|
|
74
|
+
if (left?.changes?.length) {
|
|
75
|
+
lines.push(`⚠️ The previous test${left.test ? ` ("${left.test}")` : ''} left the game changed:`);
|
|
76
|
+
for (const change of left.changes) {
|
|
77
|
+
lines.push(` • ${change}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push(' If this test expects the starting state, reset it in the project\'s fixture or a beforeEach/afterEach.');
|
|
80
|
+
lines.push('');
|
|
81
|
+
}
|
|
72
82
|
// 1. Actor Identity Mapping
|
|
73
83
|
if (diagnostics.actorMap && Object.keys(diagnostics.actorMap).length > 0) {
|
|
74
84
|
lines.push('📍 Actor Identity Mapping:');
|