@specter-automation/test 1.0.118 → 1.0.119

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.
@@ -37,6 +37,7 @@ exports.gasExpect = void 0;
37
37
  exports.formatAiDiagnostics = formatAiDiagnostics;
38
38
  exports.formatCausalityTimeline = formatCausalityTimeline;
39
39
  const test_1 = __importStar(require("@playwright/test"));
40
+ const instrument_1 = require("./instrument");
40
41
  const specter_client_1 = require("../core/specter-client");
41
42
  function formatAiDiagnostics(diagnostics) {
42
43
  if (!diagnostics)
@@ -177,20 +178,18 @@ function formatCausalityTimeline(events) {
177
178
  lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
178
179
  return '\n\n' + lines.join('\n');
179
180
  }
180
- exports.gasExpect = test_1.expect.extend({
181
+ exports.gasExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
181
182
  async toHaveAttributeValue(locator, attributeSet, attributeName, expectedValue, options) {
182
183
  const assertionName = 'toHaveAttributeValue';
183
184
  const isNot = this.isNot;
184
- const prefix = isNot ? 'not.toHaveAttributeValue' : 'toHaveAttributeValue';
185
185
  const timeout = options?.timeout ?? 5000;
186
186
  const tolerance = options?.tolerance ?? 0.01;
187
- const stepName = `${prefix}('${attributeSet}', '${attributeName}', ${expectedValue}) @ ${locator.toString()}`;
188
187
  const isMatch = (val) => {
189
188
  if (val === expectedValue)
190
189
  return true;
191
190
  return Math.abs(val - expectedValue) <= tolerance;
192
191
  };
193
- return await test_1.default.step(stepName, async () => {
192
+ return await (async () => {
194
193
  let lastValue;
195
194
  let valueHistory = [];
196
195
  const startTime = Date.now();
@@ -334,12 +333,11 @@ exports.gasExpect = test_1.expect.extend({
334
333
  expected: expectedValue
335
334
  };
336
335
  }
337
- });
336
+ })();
338
337
  },
339
338
  async toHaveAttributeChange(locator, attributeSet, attributeName, expectedChange, triggerAction) {
340
339
  const assertionName = 'toHaveAttributeChange';
341
340
  const isNot = this.isNot;
342
- const prefix = isNot ? 'not.toHaveAttributeChange' : 'toHaveAttributeChange';
343
341
  const timeout = expectedChange.timeout ?? 10000;
344
342
  const tolerance = expectedChange.tolerance ?? 0.01;
345
343
  const startTime = Date.now();
@@ -359,8 +357,7 @@ exports.gasExpect = test_1.expect.extend({
359
357
  expectedParts.push(`gameplayEffect: ${expectedChange.gameplayEffect}`);
360
358
  if (expectedChange.ability !== undefined)
361
359
  expectedParts.push(`ability: ${expectedChange.ability}`);
362
- const stepName = `${prefix}('${attributeSet}', '${attributeName}', { ${expectedParts.join(', ')} }) @ ${locator.toString()}`;
363
- return await test_1.default.step(stepName, async () => {
360
+ return await (async () => {
364
361
  const transport = locator.transport;
365
362
  let lastEvent;
366
363
  let lastFailedReasons = [];
@@ -642,14 +639,12 @@ exports.gasExpect = test_1.expect.extend({
642
639
  transport.removeEventListener('GLOBAL_timeline-event', liveListener);
643
640
  }
644
641
  }
645
- });
642
+ })();
646
643
  },
647
644
  async toHaveGameplayTag(locator, tag) {
648
645
  const assertionName = 'toHaveGameplayTag';
649
646
  const isNot = this.isNot;
650
- const prefix = isNot ? 'not.toHaveGameplayTag' : 'toHaveGameplayTag';
651
- const stepName = `${prefix}('${tag}') @ ${locator.toString()}`;
652
- return await test_1.default.step(stepName, async () => {
647
+ return await (async () => {
653
648
  const timeout = 5000;
654
649
  let hasTag = false;
655
650
  try {
@@ -676,14 +671,12 @@ exports.gasExpect = test_1.expect.extend({
676
671
  expected: !isNot
677
672
  };
678
673
  }
679
- });
674
+ })();
680
675
  },
681
676
  async toHaveGameplayEffect(locator, effectClassPath) {
682
677
  const assertionName = 'toHaveGameplayEffect';
683
678
  const isNot = this.isNot;
684
- const prefix = isNot ? 'not.toHaveGameplayEffect' : 'toHaveGameplayEffect';
685
- const stepName = `${prefix}('${effectClassPath}') @ ${locator.toString()}`;
686
- return await test_1.default.step(stepName, async () => {
679
+ return await (async () => {
687
680
  const timeout = 5000;
688
681
  const startTime = Date.now();
689
682
  let hasEffect = false;
@@ -708,12 +701,11 @@ exports.gasExpect = test_1.expect.extend({
708
701
  actual: hasEffect,
709
702
  expected: !isNot
710
703
  };
711
- });
704
+ })();
712
705
  },
713
706
  async toHaveAppliedGameplayEffect(locator, effectNameOrClass, options) {
714
707
  const assertionName = 'toHaveAppliedGameplayEffect';
715
708
  const isNot = this.isNot;
716
- const prefix = isNot ? 'not.toHaveAppliedGameplayEffect' : 'toHaveAppliedGameplayEffect';
717
709
  const timeout = options?.timeout ?? 5000;
718
710
  const expectedCount = options?.count;
719
711
  const startTime = Date.now();
@@ -724,8 +716,7 @@ exports.gasExpect = test_1.expect.extend({
724
716
  const instName = typeof options.instigator === 'string' ? options.instigator : options.instigator.toString();
725
717
  expectedParts.push(`instigator: ${instName}`);
726
718
  }
727
- const stepName = `${prefix}('${effectNameOrClass}'${expectedCount !== undefined ? `, { count: ${expectedCount} }` : ''}) @ ${locator.toString()}`;
728
- return await test_1.default.step(stepName, async () => {
719
+ return await (async () => {
729
720
  const transport = locator.transport;
730
721
  const capturedEvents = [];
731
722
  const matchingApplications = [];
@@ -964,14 +955,12 @@ exports.gasExpect = test_1.expect.extend({
964
955
  actual: matchingApplications.length,
965
956
  expected: expectedCount ?? 1
966
957
  };
967
- });
958
+ })();
968
959
  },
969
960
  async toHaveGameplayAbility(locator, abilityClassPath, options) {
970
961
  const assertionName = 'toHaveGameplayAbility';
971
962
  const isNot = this.isNot;
972
- const prefix = isNot ? 'not.toHaveGameplayAbility' : 'toHaveGameplayAbility';
973
- const stepName = `${prefix}('${abilityClassPath}') @ ${locator.toString()}`;
974
- return await test_1.default.step(stepName, async () => {
963
+ return await (async () => {
975
964
  const timeout = options?.timeout ?? 5000;
976
965
  const startTime = Date.now();
977
966
  let hasAbility = false;
@@ -996,16 +985,14 @@ exports.gasExpect = test_1.expect.extend({
996
985
  actual: hasAbility,
997
986
  expected: !isNot
998
987
  };
999
- });
988
+ })();
1000
989
  },
1001
990
  async toHaveAbilityCooldown(locator, abilityClassPath, options) {
1002
991
  const assertionName = 'toHaveAbilityCooldown';
1003
992
  const isNot = this.isNot;
1004
- const prefix = isNot ? 'not.toHaveAbilityCooldown' : 'toHaveAbilityCooldown';
1005
993
  const operator = options?.operator ?? '>';
1006
994
  const expectedValue = options?.expectedValue ?? 0;
1007
- const stepName = `${prefix}('${abilityClassPath}', '${operator}', ${expectedValue}) @ ${locator.toString()}`;
1008
- return await test_1.default.step(stepName, async () => {
995
+ return await (async () => {
1009
996
  const timeout = options?.timeout ?? 5000;
1010
997
  const startTime = Date.now();
1011
998
  let cooldown = 0;
@@ -1056,11 +1043,11 @@ exports.gasExpect = test_1.expect.extend({
1056
1043
  actual: cooldown,
1057
1044
  expected: `${operator} ${expectedValue}`
1058
1045
  };
1059
- });
1046
+ })();
1060
1047
  },
1061
1048
  async toHaveGameplayEffectStackCount(locator, effectClassPath, expectedCount) {
1062
1049
  const isNot = this.isNot;
1063
- return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveGameplayEffectStackCount('${effectClassPath}', ${expectedCount})`, async () => {
1050
+ return await (async () => {
1064
1051
  const timeout = 5000;
1065
1052
  const startTime = Date.now();
1066
1053
  let count = 0;
@@ -1074,11 +1061,11 @@ exports.gasExpect = test_1.expect.extend({
1074
1061
  await new Promise(r => setTimeout(r, 100));
1075
1062
  }
1076
1063
  return { pass: isNot, message: () => `Expected stack count: ${expectedCount}. Got: ${count}`, actual: count, expected: expectedCount };
1077
- });
1064
+ })();
1078
1065
  },
1079
1066
  async toHaveGameplayEffectLevel(locator, effectClassPath, expectedLevel) {
1080
1067
  const isNot = this.isNot;
1081
- return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveGameplayEffectLevel('${effectClassPath}', ${expectedLevel})`, async () => {
1068
+ return await (async () => {
1082
1069
  const timeout = 5000;
1083
1070
  const startTime = Date.now();
1084
1071
  let level = 0;
@@ -1092,11 +1079,11 @@ exports.gasExpect = test_1.expect.extend({
1092
1079
  await new Promise(r => setTimeout(r, 100));
1093
1080
  }
1094
1081
  return { pass: isNot, message: () => `Expected level: ${expectedLevel}. Got: ${level}`, actual: level, expected: expectedLevel };
1095
- });
1082
+ })();
1096
1083
  },
1097
1084
  async toHaveAttributeBaseValue(locator, attributeSet, attributeName, expectedValue) {
1098
1085
  const isNot = this.isNot;
1099
- return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveAttributeBaseValue('${attributeSet}', '${attributeName}', ${expectedValue})`, async () => {
1086
+ return await (async () => {
1100
1087
  const timeout = 5000;
1101
1088
  const startTime = Date.now();
1102
1089
  let val = 0;
@@ -1110,11 +1097,11 @@ exports.gasExpect = test_1.expect.extend({
1110
1097
  await new Promise(r => setTimeout(r, 100));
1111
1098
  }
1112
1099
  return { pass: isNot, message: () => `Expected base value: ${expectedValue}. Got: ${val}`, actual: val, expected: expectedValue };
1113
- });
1100
+ })();
1114
1101
  },
1115
1102
  async toBeExecutingAbility(locator, abilityClassPath) {
1116
1103
  const isNot = this.isNot;
1117
- return await test_1.default.step(`${isNot ? 'not.' : ''}toBeExecutingAbility('${abilityClassPath}')`, async () => {
1104
+ return await (async () => {
1118
1105
  const timeout = 5000;
1119
1106
  const startTime = Date.now();
1120
1107
  let exec = false;
@@ -1128,12 +1115,11 @@ exports.gasExpect = test_1.expect.extend({
1128
1115
  await new Promise(r => setTimeout(r, 100));
1129
1116
  }
1130
1117
  return { pass: isNot, message: () => `Expected executing: ${!isNot}. Got: ${exec}`, actual: exec, expected: !isNot };
1131
- });
1118
+ })();
1132
1119
  },
1133
1120
  async toHaveActivatedAbility(locator, ability, optionsOrTrigger, triggerAction) {
1134
1121
  const assertionName = 'toHaveActivatedAbility';
1135
1122
  const isNot = this.isNot;
1136
- const prefix = isNot ? 'not.toHaveActivatedAbility' : 'toHaveActivatedAbility';
1137
1123
  let timeout = 5000;
1138
1124
  let action;
1139
1125
  let expectedTimes;
@@ -1147,8 +1133,7 @@ exports.gasExpect = test_1.expect.extend({
1147
1133
  if (triggerAction && typeof triggerAction === 'function') {
1148
1134
  action = triggerAction;
1149
1135
  }
1150
- const stepName = `${prefix}('${ability}'${expectedTimes !== undefined ? `, { times: ${expectedTimes} }` : ''}) @ ${locator.toString()}`;
1151
- return await test_1.default.step(stepName, async () => {
1136
+ return await (async () => {
1152
1137
  const transport = locator.transport;
1153
1138
  const capturedEvents = [];
1154
1139
  const activations = [];
@@ -1399,11 +1384,11 @@ exports.gasExpect = test_1.expect.extend({
1399
1384
  actual: activations.length,
1400
1385
  expected: expectedTimes ?? !isNot
1401
1386
  };
1402
- });
1387
+ })();
1403
1388
  },
1404
1389
  async toHaveGameplayTagCount(locator, tag, expectedCount) {
1405
1390
  const isNot = this.isNot;
1406
- return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveGameplayTagCount('${tag}', ${expectedCount})`, async () => {
1391
+ return await (async () => {
1407
1392
  const timeout = 5000;
1408
1393
  const startTime = Date.now();
1409
1394
  let count = 0;
@@ -1417,11 +1402,11 @@ exports.gasExpect = test_1.expect.extend({
1417
1402
  await new Promise(r => setTimeout(r, 100));
1418
1403
  }
1419
1404
  return { pass: isNot, message: () => `Expected count: ${expectedCount}. Got: ${count}`, actual: count, expected: expectedCount };
1420
- });
1405
+ })();
1421
1406
  },
1422
1407
  async toHaveAnyGameplayTags(locator, tags) {
1423
1408
  const isNot = this.isNot;
1424
- return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveAnyGameplayTags([${tags.join(',')}])`, async () => {
1409
+ return await (async () => {
1425
1410
  const timeout = 5000;
1426
1411
  const startTime = Date.now();
1427
1412
  let has = false;
@@ -1435,11 +1420,11 @@ exports.gasExpect = test_1.expect.extend({
1435
1420
  await new Promise(r => setTimeout(r, 100));
1436
1421
  }
1437
1422
  return { pass: isNot, message: () => `Expected any tags: ${!isNot}. Got: ${has}`, actual: has, expected: !isNot };
1438
- });
1423
+ })();
1439
1424
  },
1440
1425
  async toHaveAllGameplayTags(locator, tags) {
1441
1426
  const isNot = this.isNot;
1442
- return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveAllGameplayTags([${tags.join(',')}])`, async () => {
1427
+ return await (async () => {
1443
1428
  const timeout = 5000;
1444
1429
  const startTime = Date.now();
1445
1430
  let has = false;
@@ -1453,6 +1438,6 @@ exports.gasExpect = test_1.expect.extend({
1453
1438
  await new Promise(r => setTimeout(r, 100));
1454
1439
  }
1455
1440
  return { pass: isNot, message: () => `Expected all tags: ${!isNot}. Got: ${has}`, actual: has, expected: !isNot };
1456
- });
1441
+ })();
1457
1442
  },
1458
- });
1443
+ }));
@@ -0,0 +1,13 @@
1
+ import type { ExpectMatcherState, MatcherReturnType } from '@playwright/test';
2
+ type SpecterMatcherFn = (this: ExpectMatcherState, receiver: any, ...args: any[]) => MatcherReturnType | Promise<MatcherReturnType>;
3
+ /**
4
+ * Wraps every matcher passed to expect.extend so that each call:
5
+ * 1. runs inside one step titled `<matcher>(<args>) @ <locator>`, which the
6
+ * SpecterReporter shows under the outer `Expect "<matcher>"` step, and
7
+ * 2. records a structured result (matcher, locator, expected, actual) as a
8
+ * hidden attachment on the expect step, for the in-engine results grid.
9
+ *
10
+ * Matchers should not open their own step for the whole body; this does it for them.
11
+ */
12
+ export declare function instrumentMatchers<T extends Record<string, SpecterMatcherFn>>(matchers: T): T;
13
+ export {};
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.instrumentMatchers = instrumentMatchers;
7
+ const test_1 = __importDefault(require("@playwright/test"));
8
+ const specter_matcher_report_1 = require("../core/specter-matcher-report");
9
+ const MAX_ARG_LENGTH = 60;
10
+ const MAX_ARGS_LENGTH = 140;
11
+ const MAX_REPORT_VALUE_LENGTH = 4000;
12
+ /**
13
+ * Wraps every matcher passed to expect.extend so that each call:
14
+ * 1. runs inside one step titled `<matcher>(<args>) @ <locator>`, which the
15
+ * SpecterReporter shows under the outer `Expect "<matcher>"` step, and
16
+ * 2. records a structured result (matcher, locator, expected, actual) as a
17
+ * hidden attachment on the expect step, for the in-engine results grid.
18
+ *
19
+ * Matchers should not open their own step for the whole body; this does it for them.
20
+ */
21
+ function instrumentMatchers(matchers) {
22
+ const instrumented = {};
23
+ for (const [name, matcher] of Object.entries(matchers)) {
24
+ instrumented[name] = async function (receiver, ...args) {
25
+ const isNot = this.isNot;
26
+ // Keep the client tag ("[Server] ", "[Client 1] ") in front, as the old per-matcher titles did.
27
+ const title = `${clientTagOf(receiver)}${isNot ? 'not.' : ''}${name}(${formatArgs(args)}) @ ${describe(receiver)}`;
28
+ const result = await test_1.default.step(title, async () => matcher.call(this, receiver, ...args));
29
+ // Back in the expect step's context here, so the attachment lands on it.
30
+ recordResult({
31
+ matcher: name,
32
+ isNot,
33
+ pass: isNot ? !result.pass : result.pass,
34
+ locator: selectorOf(receiver),
35
+ locatorLabel: labelOf(receiver),
36
+ client: clientTagOf(receiver).replace(/^\[|\]\s*$/g, '') || undefined,
37
+ expected: result.expected,
38
+ actual: result.actual,
39
+ });
40
+ return result;
41
+ };
42
+ }
43
+ return instrumented;
44
+ }
45
+ function recordResult(report) {
46
+ let info;
47
+ try {
48
+ info = test_1.default.info();
49
+ }
50
+ catch {
51
+ return; // Called outside a running test (e.g. a plain script); nothing to report to.
52
+ }
53
+ const body = JSON.stringify({
54
+ ...report,
55
+ expected: limitSize(toReportValue(report.expected)),
56
+ actual: limitSize(toReportValue(report.actual)),
57
+ });
58
+ // attachments.push attaches to the current step without adding an "Attach" step.
59
+ info.attachments.push({
60
+ name: specter_matcher_report_1.SPECTER_MATCHER_ATTACHMENT,
61
+ contentType: 'application/json',
62
+ body: Buffer.from(body, 'utf-8'),
63
+ });
64
+ }
65
+ function isLocatorLike(value) {
66
+ return !!value && typeof value === 'object' && Array.isArray(value.pipeline);
67
+ }
68
+ function describe(receiver) {
69
+ if (isLocatorLike(receiver))
70
+ return receiver.toString();
71
+ return formatArg(receiver);
72
+ }
73
+ function selectorOf(receiver) {
74
+ if (isLocatorLike(receiver)) {
75
+ return typeof receiver.toSelectorString === 'function' ? receiver.toSelectorString() : receiver.toString();
76
+ }
77
+ return formatArg(receiver);
78
+ }
79
+ function clientTagOf(receiver) {
80
+ try {
81
+ return isLocatorLike(receiver) && typeof receiver.portTag === 'string' ? receiver.portTag : '';
82
+ }
83
+ catch {
84
+ return '';
85
+ }
86
+ }
87
+ function labelOf(receiver) {
88
+ return isLocatorLike(receiver) && receiver.label ? receiver.label : undefined;
89
+ }
90
+ function formatArgs(args) {
91
+ // Drop trailing undefined (optional args that were not passed).
92
+ const trimmed = [...args];
93
+ while (trimmed.length && trimmed[trimmed.length - 1] === undefined)
94
+ trimmed.pop();
95
+ return truncate(trimmed.map(formatArg).join(', '), MAX_ARGS_LENGTH);
96
+ }
97
+ function formatArg(value) {
98
+ if (value === undefined)
99
+ return 'undefined';
100
+ if (value === null)
101
+ return 'null';
102
+ if (typeof value === 'string')
103
+ return `'${truncate(value, MAX_ARG_LENGTH)}'`;
104
+ if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint')
105
+ return String(value);
106
+ if (typeof value === 'function')
107
+ return '() => …';
108
+ if (isLocatorLike(value))
109
+ return value.toString();
110
+ return truncate(safeStringify(toReportValue(value)), MAX_ARG_LENGTH);
111
+ }
112
+ /** Converts values into something JSON-safe and readable: locators become their description, functions a placeholder. */
113
+ function toReportValue(value, seen = new WeakSet()) {
114
+ if (value === undefined || value === null)
115
+ return value;
116
+ if (typeof value === 'bigint')
117
+ return value.toString();
118
+ if (typeof value === 'function')
119
+ return '[Function]';
120
+ if (typeof value !== 'object')
121
+ return value;
122
+ if (isLocatorLike(value))
123
+ return value.toString();
124
+ if (seen.has(value))
125
+ return '[Circular]';
126
+ seen.add(value);
127
+ if (Array.isArray(value))
128
+ return value.map(v => toReportValue(v, seen));
129
+ const out = {};
130
+ for (const [key, v] of Object.entries(value)) {
131
+ out[key] = toReportValue(v, seen);
132
+ }
133
+ return out;
134
+ }
135
+ function safeStringify(value) {
136
+ try {
137
+ return JSON.stringify(value) ?? 'undefined';
138
+ }
139
+ catch {
140
+ return String(value);
141
+ }
142
+ }
143
+ /** Keeps the attachment small: oversized values are replaced by a truncated JSON string. */
144
+ function limitSize(value) {
145
+ const text = safeStringify(value);
146
+ return text.length > MAX_REPORT_VALUE_LENGTH ? `${text.slice(0, MAX_REPORT_VALUE_LENGTH)}…` : value;
147
+ }
148
+ function truncate(text, max) {
149
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
150
+ }
@@ -1,50 +1,15 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.locatorExpect = void 0;
37
- const test_1 = __importStar(require("@playwright/test"));
4
+ const test_1 = require("@playwright/test");
5
+ const instrument_1 = require("./instrument");
38
6
  const locators_1 = require("../core/locators");
39
- exports.locatorExpect = test_1.expect.extend({
7
+ exports.locatorExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
40
8
  async toHavePropertyValue(locator, propertyName, expectedValue, options) {
41
9
  const operator = options?.operator ?? '===';
42
10
  const pollTimeout = options?.timeout ?? 5000;
43
11
  const isNot = this.isNot;
44
- const prefix = isNot ? 'not.toHavePropertyValue' : 'toHavePropertyValue';
45
- const portStr = locator.portTag || '';
46
- const stepName = `${portStr}expect(${locator.toString()}).${prefix}('${propertyName}', '${operator}', ${JSON.stringify(expectedValue)})`;
47
- return await test_1.default.step(stepName, async () => {
12
+ return await (async () => {
48
13
  let lastValue;
49
14
  try {
50
15
  await test_1.expect.poll(async () => {
@@ -66,15 +31,13 @@ exports.locatorExpect = test_1.expect.extend({
66
31
  expected: expectedValue
67
32
  };
68
33
  }
69
- });
34
+ })();
70
35
  },
71
36
  async toHaveCount(locator, expectedCount, options) {
72
37
  const pollTimeout = options?.timeout ?? 5000;
73
38
  const isNot = this.isNot;
74
39
  const prefix = isNot ? 'not.toHaveCount' : 'toHaveCount';
75
- const portStr = locator.portTag || '';
76
- const stepName = `${portStr}expect(${locator.toString()}).${prefix}(${expectedCount})`;
77
- return await test_1.default.step(stepName, async () => {
40
+ return await (async () => {
78
41
  let lastCount = -1;
79
42
  try {
80
43
  const poll = test_1.expect.poll(async () => {
@@ -98,7 +61,7 @@ exports.locatorExpect = test_1.expect.extend({
98
61
  `Received: ${this.utils.printReceived(lastCount)}\n`
99
62
  };
100
63
  }
101
- });
64
+ })();
102
65
  },
103
66
  async toBeVisible(locator, // Accept any to bypass generic strictness
104
67
  options) {
@@ -117,10 +80,7 @@ exports.locatorExpect = test_1.expect.extend({
117
80
  const pollTimeout = options?.timeout ?? 5000;
118
81
  const checkOnScreen = isActor ? (options?.onScreen ?? false) : false; // UMG ignores spatial onScreen bounds
119
82
  const isNot = this.isNot;
120
- const prefix = isNot ? 'not.toBeVisible' : 'toBeVisible';
121
- const portStr = locator.portTag || '';
122
- const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
123
- return await test_1.default.step(stepName, async () => {
83
+ return await (async () => {
124
84
  let isVis = false;
125
85
  try {
126
86
  await test_1.expect.poll(async () => {
@@ -163,7 +123,7 @@ exports.locatorExpect = test_1.expect.extend({
163
123
  (errorMessage.includes('0 objects') ? '' : `\nUnderlying Engine Error: ${errorMessage}`)
164
124
  };
165
125
  }
166
- });
126
+ })();
167
127
  },
168
128
  async toBeInViewport(locator, options) {
169
129
  return this.toBeVisible(locator, { onScreen: true, timeout: options?.timeout });
@@ -183,9 +143,7 @@ exports.locatorExpect = test_1.expect.extend({
183
143
  const pollTimeout = options?.timeout ?? 5000;
184
144
  const isNot = this.isNot;
185
145
  const prefix = isNot ? 'not.toBeDestroyed' : 'toBeDestroyed';
186
- const portStr = locator.portTag || '';
187
- const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
188
- return await test_1.default.step(stepName, async () => {
146
+ return await (async () => {
189
147
  let lastCount = -1;
190
148
  try {
191
149
  await test_1.expect.poll(async () => {
@@ -209,6 +167,6 @@ exports.locatorExpect = test_1.expect.extend({
209
167
  `Received count: ${this.utils.printReceived(lastCount)}`
210
168
  };
211
169
  }
212
- });
170
+ })();
213
171
  }
214
- });
172
+ }));