@specter-automation/test 1.0.120 → 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
- pollIntervalId = setInterval(async () => {
497
- if (isResolved)
498
- return;
494
+ timeoutId = setTimeout(async () => {
495
+ cleanup();
496
+ // One final check before giving up in case an event was missed
499
497
  try {
500
- const val = await this.getAttributeValue(attributeSet, attributeName);
501
- if (isResolved)
502
- return;
503
- if (val !== undefined && !isNaN(val)) {
504
- if (lastValue !== val) {
505
- history.push(val);
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
  });
@@ -18,6 +18,8 @@ export default class SpecterReporter implements Reporter {
18
18
  private readMatcherReport;
19
19
  private getParentStepName;
20
20
  onStepBegin(test: TestCase, result: TestResult, step: TestStep): void;
21
+ /** Where a step is written in the spec, for "open at line" in the runner. */
22
+ private locationOf;
21
23
  private customStepDurations;
22
24
  onStepEnd(test: TestCase, result: TestResult, step: TestStep): void;
23
25
  private formatError;
@@ -231,10 +231,17 @@ class SpecterReporter {
231
231
  // The wrapper stands in for its outer expect step, so report the expect step's parent
232
232
  // (the same parent its step_ended event will carry), not the expect step itself.
233
233
  parentStepName: this.getParentStepName(isCustomWrapper ? step.parent : step),
234
- category: category
234
+ category: category,
235
+ // The wrapper's own location is inside Specter; the expect step points at the user's line
236
+ location: this.locationOf(isCustomWrapper ? step.parent : step)
235
237
  }
236
238
  });
237
239
  }
240
+ /** Where a step is written in the spec, for "open at line" in the runner. */
241
+ locationOf(step) {
242
+ const location = step.location;
243
+ return location ? { file: location.file, line: location.line } : undefined;
244
+ }
238
245
  customStepDurations = new WeakMap();
239
246
  onStepEnd(test, result, step) {
240
247
  const uniqueTestKey = `${test.parent.title} > ${test.title}`;
@@ -261,7 +268,8 @@ class SpecterReporter {
261
268
  testName: uniqueTestKey,
262
269
  stepName: uniqueStepName,
263
270
  parentStepName: this.getParentStepName(step),
264
- category: 'expect'
271
+ category: 'expect',
272
+ location: this.locationOf(step)
265
273
  }
266
274
  });
267
275
  }
@@ -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
- // Parallel polling fallback in case the event was already broadcast or missed
263
- pollIntervalId = setInterval(async () => {
264
- if (isResolved)
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 val = await locator.getAttributeValue(attributeSet, attributeName);
268
- if (isResolved)
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 WITH POLLING FALLBACK ---
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
- // Parallel polling fallback
547
- pollIntervalId = setInterval(async () => {
548
- if (isResolved)
549
- return;
550
- try {
551
- const currentVal = await locator.getAttributeValue(attributeSet, attributeName);
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
- // If no specific instigator/causer was demanded, or if we saw an event matching them:
561
- if (!expectedInstigatorName && !expectedEffectCauserName && !expectedChange.gameplayEffect && !expectedChange.ability) {
562
- cleanup();
563
- resolve(lastEvent || {
564
- timestamp: Date.now(),
565
- eventName: attributeName,
566
- eventType: specter_client_1.SpecterEventType.GameplayAttribute,
567
- oldValue: String(initialValue),
568
- newValue: String(currentVal),
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specter-automation/test",
3
- "version": "1.0.120",
3
+ "version": "1.0.123",
4
4
  "description": "Playwright integration for Unreal Engine automation via Specter",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",