@specter-automation/test 1.0.117 → 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.
- package/dist/core/expect-all.d.ts +27 -0
- package/dist/core/expect-all.js +66 -0
- package/dist/core/locators/specter-locator.d.ts +14 -0
- package/dist/core/locators/specter-locator.js +25 -2
- package/dist/core/specter-client.d.ts +9 -0
- package/dist/core/specter-client.js +128 -0
- package/dist/core/specter-matcher-report.d.ts +42 -0
- package/dist/core/specter-matcher-report.js +54 -0
- package/dist/core/specter-reporter.d.ts +5 -0
- package/dist/core/specter-reporter.js +116 -80
- package/dist/core/test-wrapper.js +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/matchers/actor-matchers.js +24 -86
- package/dist/matchers/ai-matchers.js +20 -76
- package/dist/matchers/gas-matchers.js +33 -48
- package/dist/matchers/instrument.d.ts +13 -0
- package/dist/matchers/instrument.js +150 -0
- package/dist/matchers/locator-matchers.js +12 -54
- package/dist/matchers/material-matchers.js +14 -61
- package/dist/matchers/widget-matchers.js +12 -48
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const ws_1 = __importDefault(require("ws"));
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
|
+
const specter_matcher_report_1 = require("./specter-matcher-report");
|
|
41
42
|
function extractLocatorFromExpectTitle(title) {
|
|
42
43
|
if (!title.startsWith('expect('))
|
|
43
44
|
return '';
|
|
@@ -55,12 +56,47 @@ function extractLocatorFromExpectTitle(title) {
|
|
|
55
56
|
}
|
|
56
57
|
return '';
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Pulls the locator out of a Specter matcher step title:
|
|
61
|
+
* `[Server] toHaveGameplayTag('Status.Stunned') @ enemies[0] (getByTag('Spawned_c36e0554'))`
|
|
62
|
+
*/
|
|
63
|
+
function extractLocatorFromMatcherTitle(title) {
|
|
64
|
+
const afterArgs = title.indexOf(') @ ');
|
|
65
|
+
if (afterArgs !== -1) {
|
|
66
|
+
return title.substring(afterArgs + 4).trim();
|
|
67
|
+
}
|
|
68
|
+
const at = title.lastIndexOf(' @ ');
|
|
69
|
+
if (at !== -1) {
|
|
70
|
+
return title.substring(at + 3).trim();
|
|
71
|
+
}
|
|
72
|
+
return extractLocatorFromExpectTitle(title.replace(/^\[[^\]]*\]\s*/, ''));
|
|
73
|
+
}
|
|
74
|
+
/** Short, display-ready text for the runner. Kept under 300 chars like errorMessage, to stay well within Unreal's FName/FString UI limits. */
|
|
75
|
+
function toDisplayText(value) {
|
|
76
|
+
if (value === undefined)
|
|
77
|
+
return '';
|
|
78
|
+
let text;
|
|
79
|
+
if (typeof value === 'string') {
|
|
80
|
+
text = value;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
try {
|
|
84
|
+
text = JSON.stringify(value);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
text = String(value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return text.length > 300 ? text.substring(0, 297) + '...' : text;
|
|
91
|
+
}
|
|
58
92
|
class SpecterReporter {
|
|
59
93
|
ws = null;
|
|
60
94
|
isConnected = false;
|
|
61
95
|
queue = [];
|
|
62
96
|
testStepCounters = new Map();
|
|
63
97
|
stepIdMap = new WeakMap();
|
|
98
|
+
/** Playwright's outer `Expect "<matcher>"` steps for Specter matchers. They are shown under their wrapper step's name. */
|
|
99
|
+
specterExpectSteps = new WeakSet();
|
|
64
100
|
constructor() {
|
|
65
101
|
this.connect();
|
|
66
102
|
}
|
|
@@ -122,6 +158,21 @@ class SpecterReporter {
|
|
|
122
158
|
}
|
|
123
159
|
return false;
|
|
124
160
|
}
|
|
161
|
+
/** The step opened by instrumentMatchers directly under a Specter expect step. */
|
|
162
|
+
isSpecterWrapper(step) {
|
|
163
|
+
return step.category === 'test.step' && !!step.parent && this.specterExpectSteps.has(step.parent);
|
|
164
|
+
}
|
|
165
|
+
readMatcherReport(step) {
|
|
166
|
+
const attachment = step.attachments?.find(a => a.name === specter_matcher_report_1.SPECTER_MATCHER_ATTACHMENT && a.body);
|
|
167
|
+
if (!attachment?.body)
|
|
168
|
+
return undefined;
|
|
169
|
+
try {
|
|
170
|
+
return JSON.parse(attachment.body.toString('utf-8'));
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
125
176
|
getParentStepName(step) {
|
|
126
177
|
let current = step.parent;
|
|
127
178
|
// Categories that are allowed to act as "Parents" in your UI
|
|
@@ -143,60 +194,32 @@ class SpecterReporter {
|
|
|
143
194
|
}
|
|
144
195
|
onStepBegin(test, result, step) {
|
|
145
196
|
console.log(`[REPORTER DEBUG] Step Begin: "${step.title}" | Category: "${step.category}" | Parent: "${step.parent ? step.parent.title : 'None'}" ("${step.parent ? step.parent.category : ''}")`);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'Expect "toHaveGameplayTag"',
|
|
151
|
-
'Expect "toHaveGameplayEffect"'
|
|
152
|
-
];
|
|
153
|
-
// 1. Ignore the outer Playwright-generated expect steps for custom matchers
|
|
154
|
-
if (step.category === 'expect' && customMatchers.includes(step.title)) {
|
|
197
|
+
// 1. Playwright's outer expect step for a Specter matcher: announced by its wrapper step below,
|
|
198
|
+
// which carries the locator in its title.
|
|
199
|
+
if (step.category === 'expect' && (0, specter_matcher_report_1.parseSpecterExpectTitle)(step.title)) {
|
|
200
|
+
this.specterExpectSteps.add(step);
|
|
155
201
|
return;
|
|
156
202
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (step.category === 'test.step' && step.title.startsWith('expect(')) {
|
|
160
|
-
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
203
|
+
const isCustomWrapper = this.isSpecterWrapper(step);
|
|
204
|
+
// 2. Ignore other expect wrapper steps (e.g. from helpers that title steps "expect(...)")
|
|
205
|
+
if (step.category === 'test.step' && step.title.startsWith('expect(') && !isCustomWrapper) {
|
|
206
|
+
return;
|
|
163
207
|
}
|
|
164
|
-
// 3. Ignore inner expect steps nested under
|
|
208
|
+
// 3. Ignore inner expect steps nested under matchers
|
|
165
209
|
if (this.isNestedExpect(step) && !isCustomWrapper) {
|
|
166
210
|
return;
|
|
167
211
|
}
|
|
168
212
|
const uniqueTestKey = `${test.parent.title} > ${test.title}`;
|
|
169
213
|
let uniqueStepName = step.title;
|
|
170
214
|
let category = step.category;
|
|
171
|
-
// 4.
|
|
215
|
+
// 4. Rename the wrapper to `Expect "<matcher>" @ <locator>` and report it as the expect step
|
|
172
216
|
if (isCustomWrapper) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
assertionName = match[1];
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
assertionName = parentTitle.replace(/^Expect\s+/, '');
|
|
181
|
-
}
|
|
182
|
-
let locator = '';
|
|
183
|
-
if (step.title.includes('@')) {
|
|
184
|
-
const parts = step.title.split('@');
|
|
185
|
-
locator = parts[parts.length - 1].trim();
|
|
186
|
-
}
|
|
187
|
-
else if (step.title.startsWith('expect(')) {
|
|
188
|
-
locator = extractLocatorFromExpectTitle(step.title);
|
|
189
|
-
}
|
|
190
|
-
const isNot = step.title.includes('.not.') || step.title.startsWith('not.');
|
|
191
|
-
const prefix = isNot ? `not.${assertionName}` : assertionName;
|
|
192
|
-
if (locator) {
|
|
193
|
-
uniqueStepName = `Expect "${prefix}" @ ${locator}`;
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
uniqueStepName = `Expect "${prefix}"`;
|
|
197
|
-
}
|
|
217
|
+
const parsed = (0, specter_matcher_report_1.parseSpecterExpectTitle)(step.parent.title);
|
|
218
|
+
const prefix = parsed.isNot ? `not.${parsed.matcher}` : parsed.matcher;
|
|
219
|
+
const locator = extractLocatorFromMatcherTitle(step.title);
|
|
220
|
+
uniqueStepName = locator ? `Expect "${prefix}" @ ${locator}` : `Expect "${prefix}"`;
|
|
198
221
|
category = 'expect';
|
|
199
|
-
// Cache the
|
|
222
|
+
// Cache the name on the outer expect step so its end event uses the same name
|
|
200
223
|
this.stepIdMap.set(step.parent, uniqueStepName);
|
|
201
224
|
}
|
|
202
225
|
this.stepIdMap.set(step, uniqueStepName);
|
|
@@ -205,62 +228,75 @@ class SpecterReporter {
|
|
|
205
228
|
payload: {
|
|
206
229
|
testName: uniqueTestKey,
|
|
207
230
|
stepName: uniqueStepName,
|
|
208
|
-
|
|
231
|
+
// The wrapper stands in for its outer expect step, so report the expect step's parent
|
|
232
|
+
// (the same parent its step_ended event will carry), not the expect step itself.
|
|
233
|
+
parentStepName: this.getParentStepName(isCustomWrapper ? step.parent : step),
|
|
209
234
|
category: category
|
|
210
235
|
}
|
|
211
236
|
});
|
|
212
237
|
}
|
|
213
238
|
customStepDurations = new WeakMap();
|
|
214
239
|
onStepEnd(test, result, step) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
'Expect "toHaveAttributeValue"',
|
|
219
|
-
'Expect "toHaveGameplayTag"',
|
|
220
|
-
'Expect "toHaveGameplayEffect"',
|
|
221
|
-
'Expect "toHaveMaterialScalarParameter"',
|
|
222
|
-
'Expect "toHaveMaterialVectorParameter"',
|
|
223
|
-
'Expect "toHaveMaterial"',
|
|
224
|
-
'Expect "toBeDynamicMaterial"',
|
|
225
|
-
'Expect "toHaveMaterialTextureParameter"'
|
|
226
|
-
];
|
|
227
|
-
// 1. Handle outer Playwright-generated expect steps for custom matchers
|
|
228
|
-
if (step.category === 'expect' && customMatchers.includes(step.title)) {
|
|
229
|
-
const rewrittenName = this.stepIdMap.get(step);
|
|
230
|
-
if (!rewrittenName) {
|
|
231
|
-
return; // Ignore if not a custom matcher we tracked
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// 2. Ignore custom expect wrapper steps entirely (they are replaced by the outer step ending)
|
|
235
|
-
const isCustomWrapper = step.category === 'test.step' && step.parent && step.parent.category === 'expect' && customMatchers.includes(step.parent.title);
|
|
236
|
-
if (isCustomWrapper || (step.category === 'test.step' && step.title.startsWith('expect('))) {
|
|
240
|
+
const uniqueTestKey = `${test.parent.title} > ${test.title}`;
|
|
241
|
+
// 1. The wrapper's timing is reported by its outer expect step, which ends right after it
|
|
242
|
+
if (this.isSpecterWrapper(step) || (step.category === 'test.step' && step.title.startsWith('expect('))) {
|
|
237
243
|
if (step.parent) {
|
|
238
244
|
this.customStepDurations.set(step.parent, step.duration);
|
|
239
245
|
}
|
|
240
246
|
return;
|
|
241
247
|
}
|
|
242
|
-
//
|
|
243
|
-
if (this.isNestedExpect(step)
|
|
248
|
+
// 2. Ignore inner expect steps nested under matchers
|
|
249
|
+
if (this.isNestedExpect(step)) {
|
|
244
250
|
return;
|
|
245
251
|
}
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
252
|
+
const isSpecterExpect = this.specterExpectSteps.has(step);
|
|
253
|
+
let uniqueStepName = this.stepIdMap.get(step) || step.title;
|
|
254
|
+
// 3. A Specter expect step whose wrapper never started (the matcher failed before it could):
|
|
255
|
+
// announce it now so the runner still shows the failure.
|
|
256
|
+
if (isSpecterExpect && !this.stepIdMap.has(step)) {
|
|
257
|
+
uniqueStepName = step.title;
|
|
258
|
+
this.send({
|
|
259
|
+
event: 'step_started',
|
|
260
|
+
payload: {
|
|
261
|
+
testName: uniqueTestKey,
|
|
262
|
+
stepName: uniqueStepName,
|
|
263
|
+
parentStepName: this.getParentStepName(step),
|
|
264
|
+
category: 'expect'
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
249
268
|
let duration = step.duration || 0;
|
|
250
269
|
if (this.customStepDurations.has(step)) {
|
|
251
270
|
duration = this.customStepDurations.get(step);
|
|
252
271
|
}
|
|
272
|
+
const payload = {
|
|
273
|
+
testName: uniqueTestKey,
|
|
274
|
+
stepName: uniqueStepName,
|
|
275
|
+
parentStepName: this.getParentStepName(step),
|
|
276
|
+
category: isSpecterExpect ? 'expect' : step.category,
|
|
277
|
+
status: step.error ? 'failed' : 'passed',
|
|
278
|
+
duration: duration,
|
|
279
|
+
errorMessage: step.error ? this.formatError(step.error, result) : ''
|
|
280
|
+
};
|
|
281
|
+
// 4. Structured result for the runner's results grid (Specter matchers only)
|
|
282
|
+
const report = isSpecterExpect ? this.readMatcherReport(step) : undefined;
|
|
283
|
+
if (report) {
|
|
284
|
+
payload.matcherResult = {
|
|
285
|
+
matcher: report.matcher,
|
|
286
|
+
isNot: report.isNot,
|
|
287
|
+
pass: report.pass,
|
|
288
|
+
locator: report.locator,
|
|
289
|
+
locatorLabel: report.locatorLabel ?? '',
|
|
290
|
+
client: report.client ?? '',
|
|
291
|
+
expected: report.expected ?? null,
|
|
292
|
+
actual: report.actual ?? null,
|
|
293
|
+
expectedText: toDisplayText(report.expected),
|
|
294
|
+
actualText: toDisplayText(report.actual)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
253
297
|
this.send({
|
|
254
298
|
event: 'step_ended',
|
|
255
|
-
payload
|
|
256
|
-
testName: uniqueTestKey,
|
|
257
|
-
stepName: uniqueStepName,
|
|
258
|
-
parentStepName: this.getParentStepName(step),
|
|
259
|
-
category: category,
|
|
260
|
-
status: step.error ? 'failed' : 'passed',
|
|
261
|
-
duration: duration,
|
|
262
|
-
errorMessage: step.error ? this.formatError(step.error, result) : ''
|
|
263
|
-
}
|
|
299
|
+
payload
|
|
264
300
|
});
|
|
265
301
|
}
|
|
266
302
|
formatError(error, result) {
|
|
@@ -51,6 +51,13 @@ exports.test = test_1.test.extend({
|
|
|
51
51
|
await socket.connect();
|
|
52
52
|
await use(socket);
|
|
53
53
|
socket.disconnect();
|
|
54
|
+
if (process.env.SPECTER_AUTO_STOP_PIE === 'true') {
|
|
55
|
+
try {
|
|
56
|
+
const editorPort = process.env.SPECTER_EDITOR_PORT || '8079';
|
|
57
|
+
await specter_client_1.SpecterTransport.sendEditorCommand('stopPIE', `ws://127.0.0.1:${editorPort}`);
|
|
58
|
+
}
|
|
59
|
+
catch (e) { }
|
|
60
|
+
}
|
|
54
61
|
}, { scope: 'worker' }], // <-- This is the magic flag
|
|
55
62
|
// TEST FIXTURE: Runs before/after every single test block
|
|
56
63
|
world: async ({ specter }, use, testInfo) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { SpecterTransport, SpecterWorld, VectorUtils } from './core/specter-clie
|
|
|
3
3
|
export type { SpecterPayload, SpawnOptions, Vector3, Rotator, LinearColor, Color, Vector2D, SpecterRegistry, SpecterFunctionRegistry, LoadMapOptions, SpecterGrantedAbility, SpecterActiveEffect, SpecterActorSnapshot, RegisteredGameplayTags } from './core/specter-client';
|
|
4
4
|
export { SpecterLocator, WidgetLocator, ActorLocator, AiControllerLocator, type WidgetGeometry } from './core/locators';
|
|
5
5
|
export { default as SpecterReporter } from './core/specter-reporter';
|
|
6
|
+
export { expectAll } from './core/expect-all';
|
|
7
|
+
export { SPECTER_MATCHER_ATTACHMENT } from './core/specter-matcher-report';
|
|
8
|
+
export type { SpecterMatcherReport } from './core/specter-matcher-report';
|
|
6
9
|
export type { UnrealKey } from './core/specter-keys';
|
|
7
10
|
export type { SpecterActorEvents, SpecterWidgetEvents, SpecterWorldEvents, CustomActorEvents, CustomWidgetEvents, CustomWorldEvents, ActorEventMap, WidgetEventMap, WorldEventMap, EventPredicate, WaitForEventOptions } from './core/events';
|
|
8
11
|
export { SpecterInputSequence } from './core/specter-input-sequence';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.aiExpect = exports.materialExpect = exports.runConditionalInputLoop = exports.evaluateCondition = exports.SpecterNetwork = exports.SpecterInputSequence = exports.SpecterReporter = exports.AiControllerLocator = exports.ActorLocator = exports.WidgetLocator = exports.SpecterLocator = exports.VectorUtils = exports.SpecterWorld = exports.SpecterTransport = exports.expect = exports.test = void 0;
|
|
6
|
+
exports.aiExpect = exports.materialExpect = exports.runConditionalInputLoop = exports.evaluateCondition = exports.SpecterNetwork = exports.SpecterInputSequence = exports.SPECTER_MATCHER_ATTACHMENT = exports.expectAll = exports.SpecterReporter = exports.AiControllerLocator = exports.ActorLocator = exports.WidgetLocator = exports.SpecterLocator = exports.VectorUtils = exports.SpecterWorld = exports.SpecterTransport = exports.expect = exports.test = void 0;
|
|
7
7
|
var test_wrapper_1 = require("./core/test-wrapper");
|
|
8
8
|
Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_wrapper_1.test; } });
|
|
9
9
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_wrapper_1.expect; } });
|
|
@@ -18,6 +18,10 @@ Object.defineProperty(exports, "ActorLocator", { enumerable: true, get: function
|
|
|
18
18
|
Object.defineProperty(exports, "AiControllerLocator", { enumerable: true, get: function () { return locators_1.AiControllerLocator; } });
|
|
19
19
|
var specter_reporter_1 = require("./core/specter-reporter");
|
|
20
20
|
Object.defineProperty(exports, "SpecterReporter", { enumerable: true, get: function () { return __importDefault(specter_reporter_1).default; } });
|
|
21
|
+
var expect_all_1 = require("./core/expect-all");
|
|
22
|
+
Object.defineProperty(exports, "expectAll", { enumerable: true, get: function () { return expect_all_1.expectAll; } });
|
|
23
|
+
var specter_matcher_report_1 = require("./core/specter-matcher-report");
|
|
24
|
+
Object.defineProperty(exports, "SPECTER_MATCHER_ATTACHMENT", { enumerable: true, get: function () { return specter_matcher_report_1.SPECTER_MATCHER_ATTACHMENT; } });
|
|
21
25
|
var specter_input_sequence_1 = require("./core/specter-input-sequence");
|
|
22
26
|
Object.defineProperty(exports, "SpecterInputSequence", { enumerable: true, get: function () { return specter_input_sequence_1.SpecterInputSequence; } });
|
|
23
27
|
var specter_network_1 = require("./core/specter-network");
|
|
@@ -1,41 +1,9 @@
|
|
|
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.actorExpect = void 0;
|
|
37
|
-
const test_1 =
|
|
38
|
-
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
const instrument_1 = require("./instrument");
|
|
6
|
+
exports.actorExpect = test_1.expect.extend((0, instrument_1.instrumentMatchers)({
|
|
39
7
|
async toHaveMovedFurtherThan(locator, startLocation, expectedDistance, options) {
|
|
40
8
|
const assertionName = 'toHaveMovedFurtherThan';
|
|
41
9
|
const timeout = options?.timeout ?? 5000;
|
|
@@ -504,10 +472,7 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
504
472
|
async toBePossessed(locator, options) {
|
|
505
473
|
const isNot = this.isNot;
|
|
506
474
|
const timeout = options?.timeout ?? 5000;
|
|
507
|
-
|
|
508
|
-
const portStr = locator.portTag || '';
|
|
509
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
|
|
510
|
-
return await test_1.default.step(stepName, async () => {
|
|
475
|
+
return await (async () => {
|
|
511
476
|
let lastInfo = null;
|
|
512
477
|
try {
|
|
513
478
|
await test_1.expect.poll(async () => {
|
|
@@ -523,15 +488,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
523
488
|
`Received: ${lastInfo ? (lastInfo.isPossessed ? `Possessed by ${lastInfo.controllerClass}` : 'Unpossessed') : 'null'}`
|
|
524
489
|
};
|
|
525
490
|
}
|
|
526
|
-
});
|
|
491
|
+
})();
|
|
527
492
|
},
|
|
528
493
|
async toBePlayerControlled(locator, options) {
|
|
529
494
|
const isNot = this.isNot;
|
|
530
495
|
const timeout = options?.timeout ?? 5000;
|
|
531
|
-
|
|
532
|
-
const portStr = locator.portTag || '';
|
|
533
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
|
|
534
|
-
return await test_1.default.step(stepName, async () => {
|
|
496
|
+
return await (async () => {
|
|
535
497
|
let lastInfo = null;
|
|
536
498
|
try {
|
|
537
499
|
await test_1.expect.poll(async () => {
|
|
@@ -547,15 +509,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
547
509
|
`Received controller: ${lastInfo?.controllerClass || 'None (Unpossessed)'}`
|
|
548
510
|
};
|
|
549
511
|
}
|
|
550
|
-
});
|
|
512
|
+
})();
|
|
551
513
|
},
|
|
552
514
|
async toBeLocallyControlled(locator, options) {
|
|
553
515
|
const isNot = this.isNot;
|
|
554
516
|
const timeout = options?.timeout ?? 5000;
|
|
555
|
-
|
|
556
|
-
const portStr = locator.portTag || '';
|
|
557
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}`;
|
|
558
|
-
return await test_1.default.step(stepName, async () => {
|
|
517
|
+
return await (async () => {
|
|
559
518
|
let lastInfo = null;
|
|
560
519
|
try {
|
|
561
520
|
await test_1.expect.poll(async () => {
|
|
@@ -571,15 +530,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
571
530
|
`Received: isLocallyControlled=${lastInfo?.isLocallyControlled}`
|
|
572
531
|
};
|
|
573
532
|
}
|
|
574
|
-
});
|
|
533
|
+
})();
|
|
575
534
|
},
|
|
576
535
|
async toHaveController(locator, expectedControllerClass, options) {
|
|
577
536
|
const isNot = this.isNot;
|
|
578
537
|
const timeout = options?.timeout ?? 5000;
|
|
579
|
-
|
|
580
|
-
const portStr = locator.portTag || '';
|
|
581
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}(${expectedControllerClass ? JSON.stringify(expectedControllerClass) : ''})`;
|
|
582
|
-
return await test_1.default.step(stepName, async () => {
|
|
538
|
+
return await (async () => {
|
|
583
539
|
let lastInfo = null;
|
|
584
540
|
try {
|
|
585
541
|
await test_1.expect.poll(async () => {
|
|
@@ -600,15 +556,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
600
556
|
`Received: ${lastInfo?.controllerClass || 'None (Unpossessed)'}`
|
|
601
557
|
};
|
|
602
558
|
}
|
|
603
|
-
});
|
|
559
|
+
})();
|
|
604
560
|
},
|
|
605
561
|
async toBeFalling(locator, options) {
|
|
606
562
|
const isNot = this.isNot;
|
|
607
563
|
const timeout = options?.timeout ?? 5000;
|
|
608
|
-
|
|
609
|
-
const portStr = locator.portTag || '';
|
|
610
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
|
|
611
|
-
return await test_1.default.step(stepName, async () => {
|
|
564
|
+
return await (async () => {
|
|
612
565
|
// 1. Initial State Check: 0ms return if already in desired state
|
|
613
566
|
let current = await locator.isFalling();
|
|
614
567
|
if (isNot ? !current : current) {
|
|
@@ -646,15 +599,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
646
599
|
`Received: isFalling=${current}`
|
|
647
600
|
};
|
|
648
601
|
}
|
|
649
|
-
});
|
|
602
|
+
})();
|
|
650
603
|
},
|
|
651
604
|
async toBeSwimming(locator, options) {
|
|
652
605
|
const isNot = this.isNot;
|
|
653
606
|
const timeout = options?.timeout ?? 5000;
|
|
654
|
-
|
|
655
|
-
const portStr = locator.portTag || '';
|
|
656
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
|
|
657
|
-
return await test_1.default.step(stepName, async () => {
|
|
607
|
+
return await (async () => {
|
|
658
608
|
// 1. Initial State Check
|
|
659
609
|
let current = await locator.isSwimming();
|
|
660
610
|
if (isNot ? !current : current) {
|
|
@@ -681,15 +631,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
681
631
|
`Received: isSwimming=${current}`
|
|
682
632
|
};
|
|
683
633
|
}
|
|
684
|
-
});
|
|
634
|
+
})();
|
|
685
635
|
},
|
|
686
636
|
async toBeFlying(locator, options) {
|
|
687
637
|
const isNot = this.isNot;
|
|
688
638
|
const timeout = options?.timeout ?? 5000;
|
|
689
|
-
|
|
690
|
-
const portStr = locator.portTag || '';
|
|
691
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
|
|
692
|
-
return await test_1.default.step(stepName, async () => {
|
|
639
|
+
return await (async () => {
|
|
693
640
|
// 1. Initial State Check
|
|
694
641
|
let current = await locator.isFlying();
|
|
695
642
|
if (isNot ? !current : current) {
|
|
@@ -716,15 +663,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
716
663
|
`Received: isFlying=${current}`
|
|
717
664
|
};
|
|
718
665
|
}
|
|
719
|
-
});
|
|
666
|
+
})();
|
|
720
667
|
},
|
|
721
668
|
async toBeCrouching(locator, options) {
|
|
722
669
|
const isNot = this.isNot;
|
|
723
670
|
const timeout = options?.timeout ?? 5000;
|
|
724
|
-
|
|
725
|
-
const portStr = locator.portTag || '';
|
|
726
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
|
|
727
|
-
return await test_1.default.step(stepName, async () => {
|
|
671
|
+
return await (async () => {
|
|
728
672
|
// 1. Initial State Check
|
|
729
673
|
let current = await locator.isCrouching();
|
|
730
674
|
if (isNot ? !current : current) {
|
|
@@ -749,15 +693,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
749
693
|
`Received: isCrouching=${current}`
|
|
750
694
|
};
|
|
751
695
|
}
|
|
752
|
-
});
|
|
696
|
+
})();
|
|
753
697
|
},
|
|
754
698
|
async toBeMovingOnGround(locator, options) {
|
|
755
699
|
const isNot = this.isNot;
|
|
756
700
|
const timeout = options?.timeout ?? 5000;
|
|
757
|
-
|
|
758
|
-
const portStr = locator.portTag || '';
|
|
759
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
|
|
760
|
-
return await test_1.default.step(stepName, async () => {
|
|
701
|
+
return await (async () => {
|
|
761
702
|
// 1. Initial State Check
|
|
762
703
|
let current = await locator.isMovingOnGround();
|
|
763
704
|
if (isNot ? !current : current) {
|
|
@@ -795,15 +736,12 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
795
736
|
`Received: isMovingOnGround=${current}`
|
|
796
737
|
};
|
|
797
738
|
}
|
|
798
|
-
});
|
|
739
|
+
})();
|
|
799
740
|
},
|
|
800
741
|
async toHaveMovementMode(locator, expectedMode, options) {
|
|
801
742
|
const isNot = this.isNot;
|
|
802
743
|
const timeout = options?.timeout ?? 5000;
|
|
803
|
-
|
|
804
|
-
const portStr = locator.portTag || '';
|
|
805
|
-
const stepName = `${portStr}expect(${locator.toString()}).${prefix}('${expectedMode}')`;
|
|
806
|
-
return await test_1.default.step(stepName, async () => {
|
|
744
|
+
return await (async () => {
|
|
807
745
|
// 1. Initial State Check
|
|
808
746
|
const info = await locator.getMovementMode();
|
|
809
747
|
let lastMode = typeof info === 'string' ? info : (info?.movementMode ?? info?.mode ?? 'None');
|
|
@@ -836,6 +774,6 @@ exports.actorExpect = test_1.expect.extend({
|
|
|
836
774
|
`Received: '${lastMode}'`
|
|
837
775
|
};
|
|
838
776
|
}
|
|
839
|
-
});
|
|
777
|
+
})();
|
|
840
778
|
}
|
|
841
|
-
});
|
|
779
|
+
}));
|