@specter-automation/test 1.0.121 → 1.0.123
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.
|
@@ -466,14 +466,12 @@ class ActorLocator extends specter_locator_1.SpecterLocator {
|
|
|
466
466
|
}
|
|
467
467
|
return await new Promise((resolve, reject) => {
|
|
468
468
|
let timeoutId;
|
|
469
|
-
let pollIntervalId;
|
|
470
469
|
let isResolved = false;
|
|
471
470
|
const cleanup = () => {
|
|
472
471
|
if (isResolved)
|
|
473
472
|
return;
|
|
474
473
|
isResolved = true;
|
|
475
474
|
clearTimeout(timeoutId);
|
|
476
|
-
clearInterval(pollIntervalId);
|
|
477
475
|
this.transport.removeEventListener('GLOBAL_timeline-event', listener);
|
|
478
476
|
};
|
|
479
477
|
const listener = (event) => {
|
|
@@ -493,30 +491,20 @@ class ActorLocator extends specter_locator_1.SpecterLocator {
|
|
|
493
491
|
}
|
|
494
492
|
};
|
|
495
493
|
this.transport.registerEventListener('GLOBAL_timeline-event', listener);
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
494
|
+
timeoutId = setTimeout(async () => {
|
|
495
|
+
cleanup();
|
|
496
|
+
// One final check before giving up in case an event was missed
|
|
499
497
|
try {
|
|
500
|
-
const
|
|
501
|
-
if (
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
lastValue = val;
|
|
508
|
-
if (isMatch(val)) {
|
|
509
|
-
cleanup();
|
|
510
|
-
resolve({ finalValue: val, history });
|
|
498
|
+
const finalVal = await this.getAttributeValue(attributeSet, attributeName);
|
|
499
|
+
if (finalVal !== undefined && !isNaN(finalVal)) {
|
|
500
|
+
history.push(finalVal);
|
|
501
|
+
if (isMatch(finalVal)) {
|
|
502
|
+
resolve({ finalValue: finalVal, history });
|
|
503
|
+
return;
|
|
511
504
|
}
|
|
512
505
|
}
|
|
513
506
|
}
|
|
514
|
-
catch {
|
|
515
|
-
// Transient poll errors suppressed
|
|
516
|
-
}
|
|
517
|
-
}, 100);
|
|
518
|
-
timeoutId = setTimeout(() => {
|
|
519
|
-
cleanup();
|
|
507
|
+
catch { }
|
|
520
508
|
reject(new Error(`Timed out after ${timeout}ms waiting for GAS Attribute '${attributeName}' to reach value '${expectedValue}'.\nHistory: [${history.join(', ')}]`));
|
|
521
509
|
}, timeout);
|
|
522
510
|
});
|
|
@@ -226,14 +226,12 @@ exports.gasExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
|
|
|
226
226
|
// 2. If it does not match immediately, listen for the live attribute change event
|
|
227
227
|
const finalValue = await new Promise((resolve, reject) => {
|
|
228
228
|
let timeoutId;
|
|
229
|
-
let pollIntervalId;
|
|
230
229
|
let isResolved = false;
|
|
231
230
|
const cleanup = () => {
|
|
232
231
|
if (isResolved)
|
|
233
232
|
return;
|
|
234
233
|
isResolved = true;
|
|
235
234
|
clearTimeout(timeoutId);
|
|
236
|
-
clearInterval(pollIntervalId);
|
|
237
235
|
if (transport && typeof transport.removeEventListener === 'function') {
|
|
238
236
|
transport.removeEventListener('GLOBAL_timeline-event', listener);
|
|
239
237
|
}
|
|
@@ -259,31 +257,17 @@ exports.gasExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
|
|
|
259
257
|
if (transport && typeof transport.registerEventListener === 'function') {
|
|
260
258
|
transport.registerEventListener('GLOBAL_timeline-event', listener);
|
|
261
259
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return;
|
|
260
|
+
timeoutId = setTimeout(async () => {
|
|
261
|
+
cleanup();
|
|
262
|
+
// One final check before giving up in case an event was missed
|
|
266
263
|
try {
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
264
|
+
const finalVal = await locator.getAttributeValue(attributeSet, attributeName);
|
|
265
|
+
if (finalVal !== undefined && isMatch(finalVal)) {
|
|
266
|
+
resolve(finalVal);
|
|
269
267
|
return;
|
|
270
|
-
if (val !== undefined && !isNaN(val)) {
|
|
271
|
-
if (lastValue !== val) {
|
|
272
|
-
valueHistory.push(val);
|
|
273
|
-
}
|
|
274
|
-
lastValue = val;
|
|
275
|
-
if (isMatch(val)) {
|
|
276
|
-
cleanup();
|
|
277
|
-
resolve(val);
|
|
278
|
-
}
|
|
279
268
|
}
|
|
280
269
|
}
|
|
281
|
-
catch {
|
|
282
|
-
// Transient poll errors are suppressed during wait
|
|
283
|
-
}
|
|
284
|
-
}, 100);
|
|
285
|
-
timeoutId = setTimeout(() => {
|
|
286
|
-
cleanup();
|
|
270
|
+
catch { }
|
|
287
271
|
reject(new Error(`Timed out after ${timeout}ms waiting for GAS Attribute '${attributeName}' to reach value '${expectedValue}'`));
|
|
288
272
|
}, timeout);
|
|
289
273
|
});
|
|
@@ -515,17 +499,15 @@ exports.gasExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
|
|
|
515
499
|
}
|
|
516
500
|
}
|
|
517
501
|
}
|
|
518
|
-
// --- 4. LISTEN FOR ATTRIBUTE CHANGE EVENT
|
|
502
|
+
// --- 4. LISTEN FOR ATTRIBUTE CHANGE EVENT ---
|
|
519
503
|
const matchEvent = await new Promise((resolve, reject) => {
|
|
520
504
|
let timeoutId;
|
|
521
|
-
let pollIntervalId;
|
|
522
505
|
let isResolved = false;
|
|
523
506
|
const cleanup = () => {
|
|
524
507
|
if (isResolved)
|
|
525
508
|
return;
|
|
526
509
|
isResolved = true;
|
|
527
510
|
clearTimeout(timeoutId);
|
|
528
|
-
clearInterval(pollIntervalId);
|
|
529
511
|
};
|
|
530
512
|
onLiveEvent = (event) => {
|
|
531
513
|
if (isResolved)
|
|
@@ -543,41 +525,30 @@ exports.gasExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
|
|
|
543
525
|
return;
|
|
544
526
|
}
|
|
545
527
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
if (isResolved)
|
|
553
|
-
return;
|
|
554
|
-
if (currentVal !== undefined && initialValue !== undefined && expectedChange.delta !== undefined) {
|
|
528
|
+
timeoutId = setTimeout(async () => {
|
|
529
|
+
cleanup();
|
|
530
|
+
// If no specific instigator/causer was demanded, do one final read before timing out:
|
|
531
|
+
if (!expectedInstigatorName && !expectedEffectCauserName && !expectedChange.gameplayEffect && !expectedChange.ability && expectedChange.delta !== undefined && initialValue !== undefined) {
|
|
532
|
+
try {
|
|
533
|
+
const currentVal = await locator.getAttributeValue(attributeSet, attributeName);
|
|
555
534
|
const actualDelta = currentVal - initialValue;
|
|
556
535
|
const expDelta = expectedChange.delta;
|
|
557
536
|
const deltaMatch = Math.abs(actualDelta - expDelta) <= tolerance ||
|
|
558
537
|
Math.abs(Math.abs(actualDelta) - Math.abs(expDelta)) <= tolerance;
|
|
559
538
|
if (deltaMatch) {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
description: `Attribute ${attributeName} changed by ${actualDelta}`,
|
|
570
|
-
});
|
|
571
|
-
}
|
|
539
|
+
resolve(lastEvent || {
|
|
540
|
+
timestamp: Date.now(),
|
|
541
|
+
eventName: attributeName,
|
|
542
|
+
eventType: specter_client_1.SpecterEventType.GameplayAttribute,
|
|
543
|
+
oldValue: String(initialValue),
|
|
544
|
+
newValue: String(currentVal),
|
|
545
|
+
description: `Attribute ${attributeName} changed by ${actualDelta}`,
|
|
546
|
+
});
|
|
547
|
+
return;
|
|
572
548
|
}
|
|
573
549
|
}
|
|
550
|
+
catch { }
|
|
574
551
|
}
|
|
575
|
-
catch {
|
|
576
|
-
// Transient poll errors are suppressed during wait
|
|
577
|
-
}
|
|
578
|
-
}, 100);
|
|
579
|
-
timeoutId = setTimeout(() => {
|
|
580
|
-
cleanup();
|
|
581
552
|
reject(new Error(`Timed out after ${timeout}ms waiting for attribute change event on '${attributeName}'`));
|
|
582
553
|
}, timeout);
|
|
583
554
|
});
|