@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,539 @@
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.gasExpect = void 0;
37
+ const test_1 = __importStar(require("@playwright/test"));
38
+ const specter_client_1 = require("../core/specter-client");
39
+ exports.gasExpect = test_1.expect.extend({
40
+ async toHaveAttributeValue(locator, attributeSet, attributeName, expectedValue) {
41
+ const assertionName = 'toHaveAttributeValue';
42
+ const isNot = this.isNot;
43
+ const prefix = isNot ? 'not.toHaveAttributeValue' : 'toHaveAttributeValue';
44
+ const stepName = `${prefix}('${attributeSet}', '${attributeName}', ${expectedValue}) @ ${locator.toString()}`;
45
+ return await test_1.default.step(stepName, async () => {
46
+ let lastValue;
47
+ let valueHistory = [];
48
+ try {
49
+ // 1. Check the current value immediately (no polling loop)
50
+ lastValue = await locator.getAttributeValue(attributeSet, attributeName);
51
+ if (lastValue !== undefined)
52
+ valueHistory.push(lastValue);
53
+ if (lastValue === expectedValue) {
54
+ return {
55
+ pass: true,
56
+ message: () => 'passed',
57
+ actual: lastValue,
58
+ expected: expectedValue
59
+ };
60
+ }
61
+ // 2. If it doesn't match, wait for the telemetry event
62
+ const transport = locator.transport;
63
+ const timeout = 5000;
64
+ // Wait for the live broadcast
65
+ const finalValue = await new Promise((resolve, reject) => {
66
+ let timeoutId;
67
+ const listener = (event) => {
68
+ // DEBUG LOGGING TO HELP IDENTIFY MISMATCHES
69
+ console.log(`[Specter Debug] Received Event: type=${event.eventType}, name=${event.eventName}, value=${event.newValue}, instigator=${event.instigator}, effectCauser=${event.effectCauser}, gameplayEffect=${event.gameplayEffect}, ability=${event.ability}`);
70
+ if (event.eventType === specter_client_1.SpecterEventType.GameplayAttribute &&
71
+ (event.eventName === attributeName || event.eventName.includes(attributeName))) {
72
+ const val = parseFloat(event.newValue);
73
+ valueHistory.push(val); // Track history!
74
+ if (val === expectedValue) {
75
+ clearTimeout(timeoutId);
76
+ transport.removeEventListener('GLOBAL_timeline-event', listener);
77
+ resolve(val);
78
+ }
79
+ else {
80
+ // Keep track of the latest value we saw during the wait
81
+ lastValue = val;
82
+ }
83
+ }
84
+ };
85
+ timeoutId = setTimeout(() => {
86
+ transport.removeEventListener('GLOBAL_timeline-event', listener);
87
+ reject(new Error(`Timed out after ${timeout}ms waiting for GAS Attribute '${attributeName}' to reach value '${expectedValue}'`));
88
+ }, timeout);
89
+ transport.registerEventListener('GLOBAL_timeline-event', listener);
90
+ });
91
+ return {
92
+ pass: true,
93
+ message: () => 'passed',
94
+ actual: finalValue,
95
+ expected: expectedValue
96
+ };
97
+ }
98
+ catch (e) {
99
+ if (!e.message.includes('Timed out')) {
100
+ throw e;
101
+ }
102
+ return {
103
+ pass: false,
104
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), expectedValue.toString())}\n\n` +
105
+ `Expected: ${this.utils.printExpected(expectedValue)}\n` +
106
+ `Received: ${lastValue !== undefined ? this.utils.printReceived(lastValue) : 'Timeout'}\n` +
107
+ `History: [${valueHistory.join(', ')}]`,
108
+ actual: lastValue,
109
+ expected: expectedValue
110
+ };
111
+ }
112
+ });
113
+ },
114
+ async toHaveAttributeChange(locator, attributeSet, attributeName, expectedChange, triggerAction) {
115
+ const assertionName = 'toHaveAttributeChange';
116
+ const isNot = this.isNot;
117
+ const prefix = isNot ? 'not.toHaveAttributeChange' : 'toHaveAttributeChange';
118
+ // Format expectations for description
119
+ const expectedParts = [];
120
+ if (expectedChange.delta !== undefined)
121
+ expectedParts.push(`delta: ${expectedChange.delta}`);
122
+ if (expectedChange.instigator !== undefined) {
123
+ const name = typeof expectedChange.instigator === 'string' ? expectedChange.instigator : expectedChange.instigator.toString();
124
+ expectedParts.push(`instigator: ${name}`);
125
+ }
126
+ if (expectedChange.effectCauser !== undefined) {
127
+ const name = typeof expectedChange.effectCauser === 'string' ? expectedChange.effectCauser : expectedChange.effectCauser.toString();
128
+ expectedParts.push(`effectCauser: ${name}`);
129
+ }
130
+ if (expectedChange.gameplayEffect !== undefined)
131
+ expectedParts.push(`gameplayEffect: ${expectedChange.gameplayEffect}`);
132
+ if (expectedChange.ability !== undefined)
133
+ expectedParts.push(`ability: ${expectedChange.ability}`);
134
+ const stepName = `${prefix}('${attributeSet}', '${attributeName}', { ${expectedParts.join(', ')} }) @ ${locator.toString()}`;
135
+ return await test_1.default.step(stepName, async () => {
136
+ const transport = locator.transport;
137
+ const timeout = 10000;
138
+ // Trigger C++ tracking of this attribute by reading its value once
139
+ await locator.getAttributeValue(attributeSet, attributeName);
140
+ // Resolve target expected names for locators
141
+ let expectedInstigatorName;
142
+ if (expectedChange.instigator) {
143
+ if (typeof expectedChange.instigator === 'string') {
144
+ expectedInstigatorName = expectedChange.instigator;
145
+ }
146
+ else {
147
+ expectedInstigatorName = await expectedChange.instigator.getObjectName();
148
+ }
149
+ }
150
+ let expectedEffectCauserName;
151
+ if (expectedChange.effectCauser) {
152
+ if (typeof expectedChange.effectCauser === 'string') {
153
+ expectedEffectCauserName = expectedChange.effectCauser;
154
+ }
155
+ else {
156
+ expectedEffectCauserName = await expectedChange.effectCauser.getObjectName();
157
+ }
158
+ }
159
+ let matchEvent;
160
+ let lastEvent;
161
+ let lastFailedReasons = [];
162
+ try {
163
+ // Wait for the timeline event matching the criteria
164
+ const matchPromise = new Promise((resolve, reject) => {
165
+ let timeoutId;
166
+ const listener = (event) => {
167
+ if (event.eventType === specter_client_1.SpecterEventType.GameplayAttribute &&
168
+ (event.eventName === attributeName || event.eventName.includes(attributeName))) {
169
+ lastEvent = event;
170
+ lastFailedReasons = [];
171
+ let isMatch = true;
172
+ // 1. Delta check
173
+ if (expectedChange.delta !== undefined) {
174
+ const oldVal = parseFloat(event.oldValue);
175
+ const newVal = parseFloat(event.newValue);
176
+ const actualDelta = newVal - oldVal;
177
+ // Use close comparison for floats (e.g. within 0.01 tolerance)
178
+ if (Math.abs(actualDelta - expectedChange.delta) > 0.01) {
179
+ isMatch = false;
180
+ lastFailedReasons.push(`delta (expected: ${expectedChange.delta}, actual: ${actualDelta})`);
181
+ }
182
+ }
183
+ // 2. Instigator check
184
+ if (expectedInstigatorName !== undefined) {
185
+ if (event.instigator !== expectedInstigatorName && !event.instigator?.includes(expectedInstigatorName)) {
186
+ isMatch = false;
187
+ lastFailedReasons.push(`instigator (expected to include: '${expectedInstigatorName}', actual: '${event.instigator}')`);
188
+ }
189
+ }
190
+ // 3. Effect Causer check
191
+ if (expectedEffectCauserName !== undefined) {
192
+ if (event.effectCauser !== expectedEffectCauserName && !event.effectCauser?.includes(expectedEffectCauserName)) {
193
+ isMatch = false;
194
+ lastFailedReasons.push(`effectCauser (expected to include: '${expectedEffectCauserName}', actual: '${event.effectCauser}')`);
195
+ }
196
+ }
197
+ // 4. Gameplay Effect check
198
+ if (expectedChange.gameplayEffect !== undefined) {
199
+ if (event.gameplayEffect !== expectedChange.gameplayEffect && !event.gameplayEffect?.includes(expectedChange.gameplayEffect)) {
200
+ isMatch = false;
201
+ lastFailedReasons.push(`gameplayEffect (expected to include: '${expectedChange.gameplayEffect}', actual: '${event.gameplayEffect}')`);
202
+ }
203
+ }
204
+ // 5. Ability check
205
+ if (expectedChange.ability !== undefined) {
206
+ if (event.ability !== expectedChange.ability && !event.ability?.includes(expectedChange.ability)) {
207
+ isMatch = false;
208
+ lastFailedReasons.push(`ability (expected to include: '${expectedChange.ability}', actual: '${event.ability}')`);
209
+ }
210
+ }
211
+ if (isMatch) {
212
+ clearTimeout(timeoutId);
213
+ transport.removeEventListener('GLOBAL_timeline-event', listener);
214
+ resolve(event);
215
+ }
216
+ }
217
+ };
218
+ timeoutId = setTimeout(() => {
219
+ transport.removeEventListener('GLOBAL_timeline-event', listener);
220
+ reject(new Error(`Timed out after ${timeout}ms waiting for attribute change event on '${attributeName}'`));
221
+ }, timeout);
222
+ transport.registerEventListener('GLOBAL_timeline-event', listener);
223
+ });
224
+ if (triggerAction) {
225
+ await triggerAction();
226
+ }
227
+ matchEvent = await matchPromise;
228
+ return {
229
+ pass: !isNot,
230
+ message: () => 'passed',
231
+ actual: matchEvent,
232
+ expected: expectedChange
233
+ };
234
+ }
235
+ catch (e) {
236
+ if (!e.message.includes('Timed out')) {
237
+ throw e;
238
+ }
239
+ let failureDetails = `Last checked event: ${lastEvent ? JSON.stringify(lastEvent, null, 2) : 'None received'}`;
240
+ if (lastFailedReasons.length > 0) {
241
+ failureDetails += `\n\nFailed Criteria on last event:\n- ${lastFailedReasons.join('\n- ')}`;
242
+ }
243
+ return {
244
+ pass: isNot,
245
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), expectedParts.join(', '))}\n\n` +
246
+ `Error: ${e.message}\n` +
247
+ `Expected criteria: { ${expectedParts.join(', ')} }\n\n` +
248
+ failureDetails,
249
+ actual: lastEvent,
250
+ expected: expectedChange
251
+ };
252
+ }
253
+ });
254
+ },
255
+ async toHaveGameplayTag(locator, tag) {
256
+ const assertionName = 'toHaveGameplayTag';
257
+ const isNot = this.isNot;
258
+ const prefix = isNot ? 'not.toHaveGameplayTag' : 'toHaveGameplayTag';
259
+ const stepName = `${prefix}('${tag}') @ ${locator.toString()}`;
260
+ return await test_1.default.step(stepName, async () => {
261
+ const timeout = 5000;
262
+ let hasTag = false;
263
+ try {
264
+ hasTag = await locator.waitForGameplayTag(tag, !isNot, timeout);
265
+ return {
266
+ pass: !isNot,
267
+ message: () => 'passed',
268
+ actual: hasTag,
269
+ expected: !isNot
270
+ };
271
+ }
272
+ catch (e) {
273
+ if (!e.message.includes('Timed out')) {
274
+ throw e;
275
+ }
276
+ hasTag = isNot;
277
+ return {
278
+ pass: isNot,
279
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), tag)}\n\n` +
280
+ `Timed out after ${timeout}ms waiting for tag on "${locator.toString()}".\n` +
281
+ `Expected: ${isNot ? 'not to have tag' : 'to have tag'} ${tag}\n` +
282
+ `Received: ${hasTag ? 'has tag' : 'does not have tag'}`,
283
+ actual: hasTag,
284
+ expected: !isNot
285
+ };
286
+ }
287
+ });
288
+ },
289
+ async toHaveGameplayEffect(locator, effectClassPath) {
290
+ const assertionName = 'toHaveGameplayEffect';
291
+ const isNot = this.isNot;
292
+ const prefix = isNot ? 'not.toHaveGameplayEffect' : 'toHaveGameplayEffect';
293
+ const stepName = `${prefix}('${effectClassPath}') @ ${locator.toString()}`;
294
+ return await test_1.default.step(stepName, async () => {
295
+ const timeout = 5000;
296
+ const startTime = Date.now();
297
+ let hasEffect = false;
298
+ while (Date.now() - startTime < timeout) {
299
+ hasEffect = await locator.hasActiveGameplayEffect(effectClassPath);
300
+ if (hasEffect === !isNot) {
301
+ return {
302
+ pass: !isNot,
303
+ message: () => 'passed',
304
+ actual: hasEffect,
305
+ expected: !isNot
306
+ };
307
+ }
308
+ await new Promise(resolve => setTimeout(resolve, 100));
309
+ }
310
+ return {
311
+ pass: isNot,
312
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), effectClassPath)}\n\n` +
313
+ `Timed out after ${timeout}ms waiting for gameplay effect.\n` +
314
+ `Expected: ${isNot ? 'not to have effect' : 'to have effect'} ${effectClassPath}\n` +
315
+ `Received: ${hasEffect ? 'has effect' : 'does not have effect'}`,
316
+ actual: hasEffect,
317
+ expected: !isNot
318
+ };
319
+ });
320
+ },
321
+ async toHaveGameplayAbility(locator, abilityClassPath, options) {
322
+ const assertionName = 'toHaveGameplayAbility';
323
+ const isNot = this.isNot;
324
+ const prefix = isNot ? 'not.toHaveGameplayAbility' : 'toHaveGameplayAbility';
325
+ const stepName = `${prefix}('${abilityClassPath}') @ ${locator.toString()}`;
326
+ return await test_1.default.step(stepName, async () => {
327
+ const timeout = options?.timeout ?? 5000;
328
+ const startTime = Date.now();
329
+ let hasAbility = false;
330
+ while (Date.now() - startTime < timeout) {
331
+ hasAbility = await locator.hasGameplayAbility(abilityClassPath);
332
+ if (hasAbility === !isNot) {
333
+ return {
334
+ pass: !isNot,
335
+ message: () => 'passed',
336
+ actual: hasAbility,
337
+ expected: !isNot
338
+ };
339
+ }
340
+ await new Promise(resolve => setTimeout(resolve, 100));
341
+ }
342
+ return {
343
+ pass: isNot,
344
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), abilityClassPath)}\n\n` +
345
+ `Timed out after ${timeout}ms waiting for gameplay ability.\n` +
346
+ `Expected: ${isNot ? 'not to have ability' : 'to have ability'} ${abilityClassPath}\n` +
347
+ `Received: ${hasAbility ? 'has ability' : 'does not have ability'}`,
348
+ actual: hasAbility,
349
+ expected: !isNot
350
+ };
351
+ });
352
+ },
353
+ async toHaveAbilityCooldown(locator, abilityClassPath, options) {
354
+ const assertionName = 'toHaveAbilityCooldown';
355
+ const isNot = this.isNot;
356
+ const prefix = isNot ? 'not.toHaveAbilityCooldown' : 'toHaveAbilityCooldown';
357
+ const operator = options?.operator ?? '>';
358
+ const expectedValue = options?.expectedValue ?? 0;
359
+ const stepName = `${prefix}('${abilityClassPath}', '${operator}', ${expectedValue}) @ ${locator.toString()}`;
360
+ return await test_1.default.step(stepName, async () => {
361
+ const timeout = options?.timeout ?? 5000;
362
+ const startTime = Date.now();
363
+ let cooldown = 0;
364
+ let conditionMet = false;
365
+ while (Date.now() - startTime < timeout) {
366
+ try {
367
+ cooldown = await locator.getAbilityCooldown(abilityClassPath);
368
+ switch (operator) {
369
+ case '>':
370
+ conditionMet = cooldown > expectedValue;
371
+ break;
372
+ case '<':
373
+ conditionMet = cooldown < expectedValue;
374
+ break;
375
+ case '>=':
376
+ conditionMet = cooldown >= expectedValue;
377
+ break;
378
+ case '<=':
379
+ conditionMet = cooldown <= expectedValue;
380
+ break;
381
+ case '===':
382
+ conditionMet = cooldown === expectedValue;
383
+ break;
384
+ case '!=':
385
+ conditionMet = cooldown !== expectedValue;
386
+ break;
387
+ }
388
+ if (conditionMet === !isNot) {
389
+ return {
390
+ pass: !isNot,
391
+ message: () => 'passed',
392
+ actual: cooldown,
393
+ expected: `${operator} ${expectedValue}`
394
+ };
395
+ }
396
+ }
397
+ catch (e) {
398
+ // Ignore errors during polling (e.g., ability not found) and just keep polling
399
+ }
400
+ await new Promise(resolve => setTimeout(resolve, 100));
401
+ }
402
+ return {
403
+ pass: isNot,
404
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), abilityClassPath)}\n\n` +
405
+ `Timed out after ${timeout}ms waiting for ability cooldown.\n` +
406
+ `Expected: ${isNot ? 'not ' : ''}${operator} ${expectedValue}\n` +
407
+ `Received: ${cooldown}`,
408
+ actual: cooldown,
409
+ expected: `${operator} ${expectedValue}`
410
+ };
411
+ });
412
+ },
413
+ async toHaveGameplayEffectStackCount(locator, effectClassPath, expectedCount) {
414
+ const isNot = this.isNot;
415
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveGameplayEffectStackCount('${effectClassPath}', ${expectedCount})`, async () => {
416
+ const timeout = 5000;
417
+ const startTime = Date.now();
418
+ let count = 0;
419
+ while (Date.now() - startTime < timeout) {
420
+ try {
421
+ count = await locator.getGameplayEffectStackCount(effectClassPath);
422
+ if ((count === expectedCount) === !isNot)
423
+ return { pass: !isNot, message: () => 'passed' };
424
+ }
425
+ catch (e) { }
426
+ await new Promise(r => setTimeout(r, 100));
427
+ }
428
+ return { pass: isNot, message: () => `Expected stack count: ${expectedCount}. Got: ${count}`, actual: count, expected: expectedCount };
429
+ });
430
+ },
431
+ async toHaveGameplayEffectLevel(locator, effectClassPath, expectedLevel) {
432
+ const isNot = this.isNot;
433
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveGameplayEffectLevel('${effectClassPath}', ${expectedLevel})`, async () => {
434
+ const timeout = 5000;
435
+ const startTime = Date.now();
436
+ let level = 0;
437
+ while (Date.now() - startTime < timeout) {
438
+ try {
439
+ level = await locator.getGameplayEffectLevel(effectClassPath);
440
+ if ((level === expectedLevel) === !isNot)
441
+ return { pass: !isNot, message: () => 'passed' };
442
+ }
443
+ catch (e) { }
444
+ await new Promise(r => setTimeout(r, 100));
445
+ }
446
+ return { pass: isNot, message: () => `Expected level: ${expectedLevel}. Got: ${level}`, actual: level, expected: expectedLevel };
447
+ });
448
+ },
449
+ async toHaveAttributeBaseValue(locator, attributeSet, attributeName, expectedValue) {
450
+ const isNot = this.isNot;
451
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveAttributeBaseValue('${attributeSet}', '${attributeName}', ${expectedValue})`, async () => {
452
+ const timeout = 5000;
453
+ const startTime = Date.now();
454
+ let val = 0;
455
+ while (Date.now() - startTime < timeout) {
456
+ try {
457
+ val = await locator.getAttributeBaseValue(attributeSet, attributeName);
458
+ if ((val === expectedValue) === !isNot)
459
+ return { pass: !isNot, message: () => 'passed' };
460
+ }
461
+ catch (e) { }
462
+ await new Promise(r => setTimeout(r, 100));
463
+ }
464
+ return { pass: isNot, message: () => `Expected base value: ${expectedValue}. Got: ${val}`, actual: val, expected: expectedValue };
465
+ });
466
+ },
467
+ async toBeExecutingAbility(locator, abilityClassPath) {
468
+ const isNot = this.isNot;
469
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toBeExecutingAbility('${abilityClassPath}')`, async () => {
470
+ const timeout = 5000;
471
+ const startTime = Date.now();
472
+ let exec = false;
473
+ while (Date.now() - startTime < timeout) {
474
+ try {
475
+ exec = await locator.isAbilityExecuting(abilityClassPath);
476
+ if (exec === !isNot)
477
+ return { pass: !isNot, message: () => 'passed' };
478
+ }
479
+ catch (e) { }
480
+ await new Promise(r => setTimeout(r, 100));
481
+ }
482
+ return { pass: isNot, message: () => `Expected executing: ${!isNot}. Got: ${exec}`, actual: exec, expected: !isNot };
483
+ });
484
+ },
485
+ async toHaveGameplayTagCount(locator, tag, expectedCount) {
486
+ const isNot = this.isNot;
487
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveGameplayTagCount('${tag}', ${expectedCount})`, async () => {
488
+ const timeout = 5000;
489
+ const startTime = Date.now();
490
+ let count = 0;
491
+ while (Date.now() - startTime < timeout) {
492
+ try {
493
+ count = await locator.getGameplayTagCount(tag);
494
+ if ((count === expectedCount) === !isNot)
495
+ return { pass: !isNot, message: () => 'passed' };
496
+ }
497
+ catch (e) { }
498
+ await new Promise(r => setTimeout(r, 100));
499
+ }
500
+ return { pass: isNot, message: () => `Expected count: ${expectedCount}. Got: ${count}`, actual: count, expected: expectedCount };
501
+ });
502
+ },
503
+ async toHaveAnyGameplayTags(locator, tags) {
504
+ const isNot = this.isNot;
505
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveAnyGameplayTags([${tags.join(',')}])`, async () => {
506
+ const timeout = 5000;
507
+ const startTime = Date.now();
508
+ let has = false;
509
+ while (Date.now() - startTime < timeout) {
510
+ try {
511
+ has = await locator.hasAnyGameplayTags(tags);
512
+ if (has === !isNot)
513
+ return { pass: !isNot, message: () => 'passed' };
514
+ }
515
+ catch (e) { }
516
+ await new Promise(r => setTimeout(r, 100));
517
+ }
518
+ return { pass: isNot, message: () => `Expected any tags: ${!isNot}. Got: ${has}`, actual: has, expected: !isNot };
519
+ });
520
+ },
521
+ async toHaveAllGameplayTags(locator, tags) {
522
+ const isNot = this.isNot;
523
+ return await test_1.default.step(`${isNot ? 'not.' : ''}toHaveAllGameplayTags([${tags.join(',')}])`, async () => {
524
+ const timeout = 5000;
525
+ const startTime = Date.now();
526
+ let has = false;
527
+ while (Date.now() - startTime < timeout) {
528
+ try {
529
+ has = await locator.hasAllGameplayTags(tags);
530
+ if (has === !isNot)
531
+ return { pass: !isNot, message: () => 'passed' };
532
+ }
533
+ catch (e) { }
534
+ await new Promise(r => setTimeout(r, 100));
535
+ }
536
+ return { pass: isNot, message: () => `Expected all tags: ${!isNot}. Got: ${has}`, actual: has, expected: !isNot };
537
+ });
538
+ },
539
+ });
@@ -0,0 +1,80 @@
1
+ import { ActorLocator, WidgetLocator, SpecterLocator } from '../core/locators';
2
+ declare global {
3
+ namespace PlaywrightTest {
4
+ interface Matchers<R, T> {
5
+ toHavePropertyValue(propertyName: string, expectedValue: any, options?: {
6
+ timeout?: number;
7
+ }): T extends SpecterLocator ? Promise<R> : never;
8
+ toHaveCount(expectedCount: number, options?: {
9
+ timeout?: number;
10
+ }): T extends SpecterLocator ? Promise<R> : never;
11
+ toBeVisible(this: Matchers<R, ActorLocator | WidgetLocator>, options?: {
12
+ onScreen?: boolean;
13
+ timeout?: number;
14
+ }): Promise<R>;
15
+ toBeInViewport(this: Matchers<R, ActorLocator>, options?: {
16
+ timeout?: number;
17
+ }): Promise<R>;
18
+ toBeDestroyed(this: Matchers<R, ActorLocator | SpecterLocator>, options?: {
19
+ timeout?: number;
20
+ }): Promise<R>;
21
+ }
22
+ }
23
+ }
24
+ export interface LocatorMatchers {
25
+ toHavePropertyValue(propertyName: string, expectedValue: any, options?: {
26
+ operator?: '>' | '<' | '>=' | '<=' | '===' | '!=' | 'regex';
27
+ timeout?: number;
28
+ }): Promise<void>;
29
+ toHaveCount(expectedCount: number, options?: {
30
+ timeout?: number;
31
+ }): Promise<void>;
32
+ toBeVisible(options?: {
33
+ onScreen?: boolean;
34
+ timeout?: number;
35
+ }): Promise<void>;
36
+ toBeInViewport(options?: {
37
+ timeout?: number;
38
+ }): Promise<void>;
39
+ toBeDestroyed(options?: {
40
+ timeout?: number;
41
+ }): Promise<void>;
42
+ }
43
+ export declare const locatorExpect: import("playwright/test").Expect<{
44
+ toHavePropertyValue(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, propertyName: string, expectedValue: any, options?: {
45
+ operator?: ">" | "<" | ">=" | "<=" | "===" | "!=" | "regex";
46
+ timeout?: number;
47
+ }): Promise<{
48
+ pass: boolean;
49
+ message: () => string;
50
+ actual?: undefined;
51
+ expected?: undefined;
52
+ } | {
53
+ pass: boolean;
54
+ message: () => string;
55
+ actual: any;
56
+ expected: any;
57
+ }>;
58
+ toHaveCount(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, expectedCount: number, options?: {
59
+ timeout?: number;
60
+ }): Promise<{
61
+ pass: boolean;
62
+ message: () => string;
63
+ }>;
64
+ toBeVisible(this: import("playwright/test").ExpectMatcherState, locator: any, options?: {
65
+ onScreen?: boolean;
66
+ timeout?: number;
67
+ }): Promise<{
68
+ pass: boolean;
69
+ message: () => string;
70
+ }>;
71
+ toBeInViewport(this: import("playwright/test").ExpectMatcherState, locator: any, options?: {
72
+ timeout?: number;
73
+ }): Promise<any>;
74
+ toBeDestroyed(this: import("playwright/test").ExpectMatcherState, locator: any, options?: {
75
+ timeout?: number;
76
+ }): Promise<{
77
+ pass: boolean;
78
+ message: () => string;
79
+ }>;
80
+ }>;