@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,214 @@
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.locatorExpect = void 0;
37
+ const test_1 = __importStar(require("@playwright/test"));
38
+ const locators_1 = require("../core/locators");
39
+ exports.locatorExpect = test_1.expect.extend({
40
+ async toHavePropertyValue(locator, propertyName, expectedValue, options) {
41
+ const operator = options?.operator ?? '===';
42
+ const pollTimeout = options?.timeout ?? 5000;
43
+ 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 () => {
48
+ let lastValue;
49
+ try {
50
+ await test_1.expect.poll(async () => {
51
+ // Pass the operator through to the evaluation
52
+ lastValue = await locator.evaluate("GetPropertyValue", {
53
+ propertyName,
54
+ expectedValue,
55
+ operator
56
+ });
57
+ return lastValue.status === 'success';
58
+ }, { timeout: pollTimeout }).toBe(!isNot);
59
+ return { pass: !isNot, message: () => 'passed' };
60
+ }
61
+ catch (e) {
62
+ return {
63
+ pass: isNot,
64
+ message: () => `Timed out waiting for ${propertyName} ${operator} ${expectedValue}. Last value: ${lastValue?.data?.value}`,
65
+ actual: lastValue?.data?.value,
66
+ expected: expectedValue
67
+ };
68
+ }
69
+ });
70
+ },
71
+ async toHaveCount(locator, expectedCount, options) {
72
+ const pollTimeout = options?.timeout ?? 5000;
73
+ const isNot = this.isNot;
74
+ 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 () => {
78
+ let lastCount = -1;
79
+ try {
80
+ const poll = test_1.expect.poll(async () => {
81
+ lastCount = await locator.count();
82
+ return lastCount;
83
+ }, { timeout: pollTimeout });
84
+ if (isNot) {
85
+ await poll.not.toBe(expectedCount);
86
+ }
87
+ else {
88
+ await poll.toBe(expectedCount);
89
+ }
90
+ return { pass: !isNot, message: () => 'passed' };
91
+ }
92
+ catch (e) {
93
+ return {
94
+ pass: isNot,
95
+ message: () => `${this.utils.matcherHint(prefix, locator.toString(), String(expectedCount))}\n\n` +
96
+ `Timed out after ${pollTimeout}ms waiting for count to be ${isNot ? 'not ' : ''}${expectedCount}.\n` +
97
+ `Expected: ${this.utils.printExpected(isNot ? 'not ' + expectedCount : expectedCount)}\n` +
98
+ `Received: ${this.utils.printReceived(lastCount)}\n`
99
+ };
100
+ }
101
+ });
102
+ },
103
+ async toBeVisible(locator, // Accept any to bypass generic strictness
104
+ options) {
105
+ const assertionName = 'toBeVisible';
106
+ // 1. THE BOUNCER: Enforce type safety at runtime
107
+ const isActor = locator instanceof locators_1.ActorLocator;
108
+ const isWidget = locator instanceof locators_1.WidgetLocator;
109
+ if (!isActor && !isWidget) {
110
+ return {
111
+ pass: false,
112
+ message: () => `${this.utils.matcherHint(assertionName, 'locator', '')}\n\n` +
113
+ `Type Error: .toBeVisible() requires an ActorLocator or WidgetLocator.\n` +
114
+ `Did you forget to call .asActor() or .asWidget()?`,
115
+ };
116
+ }
117
+ const pollTimeout = options?.timeout ?? 5000;
118
+ const checkOnScreen = isActor ? (options?.onScreen ?? false) : false; // UMG ignores spatial onScreen bounds
119
+ 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 () => {
124
+ let isVis = false;
125
+ try {
126
+ await test_1.expect.poll(async () => {
127
+ try {
128
+ isVis = await locator.checkVisibility(checkOnScreen);
129
+ return isVis;
130
+ }
131
+ catch (err) {
132
+ const msg = err instanceof Error ? err.message : String(err);
133
+ if (msg.toLowerCase().includes('strict mode')) {
134
+ throw err;
135
+ }
136
+ isVis = false;
137
+ return false;
138
+ }
139
+ }, { timeout: pollTimeout, intervals: [100, 200, 250] }).toBe(!isNot);
140
+ return { pass: !isNot, message: () => 'passed' };
141
+ }
142
+ catch (e) {
143
+ // Extract the actual message whether it's an Error object or a raw string
144
+ const errorMessage = e instanceof Error ? e.message : String(e);
145
+ // 1. Intercept Strict Mode Violations
146
+ if (errorMessage.toLowerCase().includes('strict mode violation')) {
147
+ return {
148
+ pass: false,
149
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), '')}\n\n` +
150
+ `🚨 STRICT MODE ERROR:\n` +
151
+ `${errorMessage}\n\n` +
152
+ `Fix: You must narrow your locator pipeline. Use .first(), .nth(), or .filter().`
153
+ };
154
+ }
155
+ // 2. Standard Visibility Timeout
156
+ return {
157
+ pass: isNot,
158
+ message: () => `${this.utils.matcherHint(assertionName, locator.toString(), '')}\n\n` +
159
+ `Timed out after ${pollTimeout}ms waiting for element to be ${isNot ? 'not visible' : 'visible'}.\n` +
160
+ `Expected: ${this.utils.printExpected(isNot ? 'Not Visible' : 'Visible')}\n` +
161
+ `Received: ${this.utils.printReceived(isNot ? 'Visible' : 'Not Visible')}\n` +
162
+ // Optional: If it failed for a reason OTHER than "0 objects", print it here
163
+ (errorMessage.includes('0 objects') ? '' : `\nUnderlying Engine Error: ${errorMessage}`)
164
+ };
165
+ }
166
+ });
167
+ },
168
+ async toBeInViewport(locator, options) {
169
+ return this.toBeVisible(locator, { onScreen: true, timeout: options?.timeout });
170
+ },
171
+ async toBeDestroyed(locator, options) {
172
+ const assertionName = 'toBeDestroyed';
173
+ const isActor = locator instanceof locators_1.ActorLocator;
174
+ const isWidget = locator instanceof locators_1.WidgetLocator;
175
+ const isLocator = locator instanceof locators_1.SpecterLocator;
176
+ if (!isLocator && !isActor && !isWidget) {
177
+ return {
178
+ pass: false,
179
+ message: () => `${this.utils.matcherHint(assertionName, 'locator', '')}\n\n` +
180
+ `Type Error: .toBeDestroyed() requires an ActorLocator or SpecterLocator.`,
181
+ };
182
+ }
183
+ const pollTimeout = options?.timeout ?? 5000;
184
+ const isNot = this.isNot;
185
+ 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 () => {
189
+ let lastCount = -1;
190
+ try {
191
+ await test_1.expect.poll(async () => {
192
+ try {
193
+ lastCount = await locator.count();
194
+ return lastCount === 0;
195
+ }
196
+ catch {
197
+ lastCount = 0;
198
+ return true;
199
+ }
200
+ }, { timeout: pollTimeout }).toBe(!isNot);
201
+ return { pass: !isNot, message: () => 'passed' };
202
+ }
203
+ catch (e) {
204
+ return {
205
+ pass: isNot,
206
+ message: () => `${this.utils.matcherHint(prefix, locator.toString(), '')}\n\n` +
207
+ `Timed out after ${pollTimeout}ms waiting for target to be ${isNot ? 'not destroyed (alive / existing)' : 'destroyed'}.\n` +
208
+ `Expected count: ${this.utils.printExpected(isNot ? '> 0' : 0)}\n` +
209
+ `Received count: ${this.utils.printReceived(lastCount)}`
210
+ };
211
+ }
212
+ });
213
+ }
214
+ });
@@ -0,0 +1,74 @@
1
+ import { SpecterLocator } from '../core/locators/specter-locator';
2
+ export interface MaterialOptions {
3
+ slotIndex?: number;
4
+ componentName?: string;
5
+ timeout?: number;
6
+ }
7
+ export interface MaterialScalarOptions extends MaterialOptions {
8
+ operator?: '>' | '<' | '>=' | '<=' | '===' | '!=';
9
+ tolerance?: number;
10
+ }
11
+ export interface MaterialVectorOptions extends MaterialOptions {
12
+ tolerance?: number;
13
+ }
14
+ export type ColorInput = {
15
+ r: number;
16
+ g: number;
17
+ b: number;
18
+ a?: number;
19
+ } | [number, number, number, number?] | string;
20
+ declare global {
21
+ namespace PlaywrightTest {
22
+ interface Matchers<R, T> {
23
+ toHaveMaterialScalarParameter(parameterName: string, expectedValue: number, options?: MaterialScalarOptions): T extends SpecterLocator ? Promise<R> : never;
24
+ toHaveMaterialVectorParameter(parameterName: string, expectedColor: ColorInput, options?: MaterialVectorOptions): T extends SpecterLocator ? Promise<R> : never;
25
+ toHaveMaterial(expectedMaterial: string | RegExp, options?: MaterialOptions): T extends SpecterLocator ? Promise<R> : never;
26
+ toBeDynamicMaterial(options?: MaterialOptions): T extends SpecterLocator ? Promise<R> : never;
27
+ toHaveMaterialTextureParameter(parameterName: string, expectedTexture: string | RegExp, options?: MaterialOptions): T extends SpecterLocator ? Promise<R> : never;
28
+ }
29
+ }
30
+ }
31
+ export interface MaterialMatchers {
32
+ toHaveMaterialScalarParameter(parameterName: string, expectedValue: number, options?: MaterialScalarOptions): Promise<void>;
33
+ toHaveMaterialVectorParameter(parameterName: string, expectedColor: ColorInput, options?: MaterialVectorOptions): Promise<void>;
34
+ toHaveMaterial(expectedMaterial: string | RegExp, options?: MaterialOptions): Promise<void>;
35
+ toBeDynamicMaterial(options?: MaterialOptions): Promise<void>;
36
+ toHaveMaterialTextureParameter(parameterName: string, expectedTexture: string | RegExp, options?: MaterialOptions): Promise<void>;
37
+ }
38
+ export declare const materialExpect: import("playwright/test").Expect<{
39
+ toHaveMaterialScalarParameter(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, parameterName: string, expectedValue: number, options?: MaterialScalarOptions): Promise<{
40
+ pass: boolean;
41
+ message: () => string;
42
+ actual: any;
43
+ expected: number;
44
+ }>;
45
+ toHaveMaterialVectorParameter(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, parameterName: string, expectedColor: ColorInput, options?: MaterialVectorOptions): Promise<{
46
+ pass: boolean;
47
+ message: () => string;
48
+ actual: any;
49
+ expected: {
50
+ r: number;
51
+ g: number;
52
+ b: number;
53
+ a: number;
54
+ };
55
+ }>;
56
+ toHaveMaterial(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, expectedMaterial: string | RegExp, options?: MaterialOptions): Promise<{
57
+ pass: boolean;
58
+ message: () => string;
59
+ actual: any;
60
+ expected: string | RegExp;
61
+ }>;
62
+ toBeDynamicMaterial(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, options?: MaterialOptions): Promise<{
63
+ pass: boolean;
64
+ message: () => string;
65
+ actual: any;
66
+ expected: boolean;
67
+ }>;
68
+ toHaveMaterialTextureParameter(this: import("playwright/test").ExpectMatcherState, locator: SpecterLocator, parameterName: string, expectedTexture: string | RegExp, options?: MaterialOptions): Promise<{
69
+ pass: boolean;
70
+ message: () => string;
71
+ actual: any;
72
+ expected: string | RegExp;
73
+ }>;
74
+ }>;
@@ -0,0 +1,295 @@
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.materialExpect = void 0;
37
+ const test_1 = __importStar(require("@playwright/test"));
38
+ function normalizeColor(input) {
39
+ if (typeof input === 'string') {
40
+ let hex = input.trim().replace(/^#/, '');
41
+ if (hex.length === 3) {
42
+ hex = hex.split('').map(c => c + c).join('') + 'FF';
43
+ }
44
+ else if (hex.length === 6) {
45
+ hex += 'FF';
46
+ }
47
+ if (hex.length === 8) {
48
+ const r = parseInt(hex.substring(0, 2), 16) / 255.0;
49
+ const g = parseInt(hex.substring(2, 4), 16) / 255.0;
50
+ const b = parseInt(hex.substring(4, 6), 16) / 255.0;
51
+ const a = parseInt(hex.substring(6, 8), 16) / 255.0;
52
+ return { r, g, b, a };
53
+ }
54
+ return { r: 0, g: 0, b: 0, a: 1 };
55
+ }
56
+ if (Array.isArray(input)) {
57
+ return {
58
+ r: input[0] ?? 0,
59
+ g: input[1] ?? 0,
60
+ b: input[2] ?? 0,
61
+ a: input[3] ?? 1
62
+ };
63
+ }
64
+ if (input && typeof input === 'object') {
65
+ return {
66
+ r: input.r ?? 0,
67
+ g: input.g ?? 0,
68
+ b: input.b ?? 0,
69
+ a: input.a ?? 1
70
+ };
71
+ }
72
+ return { r: 0, g: 0, b: 0, a: 1 };
73
+ }
74
+ function compareScalarValues(actual, expected, operator, tolerance) {
75
+ switch (operator) {
76
+ case '>':
77
+ return actual > expected;
78
+ case '<':
79
+ return actual < expected;
80
+ case '>=':
81
+ return actual >= (expected - tolerance);
82
+ case '<=':
83
+ return actual <= (expected + tolerance);
84
+ case '!=':
85
+ return Math.abs(actual - expected) > tolerance;
86
+ case '===':
87
+ default:
88
+ return Math.abs(actual - expected) <= tolerance;
89
+ }
90
+ }
91
+ function compareVectorValues(actual, expected, tolerance) {
92
+ const diffR = Math.abs((actual.r ?? 0) - (expected.r ?? 0));
93
+ const diffG = Math.abs((actual.g ?? 0) - (expected.g ?? 0));
94
+ const diffB = Math.abs((actual.b ?? 0) - (expected.b ?? 0));
95
+ const diffA = Math.abs((actual.a ?? 1) - (expected.a ?? 1));
96
+ return diffR <= tolerance && diffG <= tolerance && diffB <= tolerance && diffA <= tolerance;
97
+ }
98
+ // ============================================================
99
+ // SHARED RESILIENT POLLING HELPER
100
+ // Retries on WebSocket, Locator, or temporary engine errors
101
+ // ============================================================
102
+ async function poll(fn, check, timeout) {
103
+ const startTime = Date.now();
104
+ let last = undefined;
105
+ while (Date.now() - startTime < timeout) {
106
+ try {
107
+ last = await fn();
108
+ if (check(last))
109
+ return { passed: true, last };
110
+ }
111
+ catch (_) {
112
+ // Swallow temporary pipeline / connection hiccups while polling
113
+ }
114
+ await new Promise(r => setTimeout(r, 100));
115
+ }
116
+ return { passed: false, last };
117
+ }
118
+ exports.materialExpect = test_1.expect.extend({
119
+ async toHaveMaterialScalarParameter(locator, parameterName, expectedValue, options) {
120
+ const operator = options?.operator ?? '===';
121
+ const tolerance = options?.tolerance ?? 0.001;
122
+ const timeout = options?.timeout ?? 5000;
123
+ const slotIndex = options?.slotIndex ?? 0;
124
+ const componentName = options?.componentName;
125
+ const isNot = this.isNot;
126
+ const prefix = isNot ? 'not.toHaveMaterialScalarParameter' : 'toHaveMaterialScalarParameter';
127
+ const portStr = locator.portTag || '';
128
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}('${parameterName}', ${operator}, ${expectedValue})`;
129
+ return await test_1.default.step(stepName, async () => {
130
+ const { passed, last } = await poll(async () => {
131
+ const res = await locator.evaluate('GetMaterialParameter', {
132
+ parameterName,
133
+ parameterType: 'Scalar',
134
+ slotIndex,
135
+ componentName
136
+ }, parameterName, true);
137
+ return res?.data;
138
+ }, data => {
139
+ if (!data || !data.found)
140
+ return false;
141
+ const matches = compareScalarValues(data.value, expectedValue, operator, tolerance);
142
+ return isNot ? !matches : matches;
143
+ }, timeout);
144
+ const receivedValue = last?.found ? last.value : undefined;
145
+ const paramFound = last?.found ?? false;
146
+ return {
147
+ pass: isNot ? !passed : passed,
148
+ message: () => `Timed out waiting for material scalar parameter '${parameterName}' ${operator} ${expectedValue} (slot ${slotIndex}).\n` +
149
+ `Received: ${receivedValue ?? 'undefined'} (parameter found: ${paramFound})`,
150
+ actual: receivedValue,
151
+ expected: expectedValue
152
+ };
153
+ });
154
+ },
155
+ async toHaveMaterialVectorParameter(locator, parameterName, expectedColor, options) {
156
+ const tolerance = options?.tolerance ?? 0.01;
157
+ const timeout = options?.timeout ?? 5000;
158
+ const slotIndex = options?.slotIndex ?? 0;
159
+ const componentName = options?.componentName;
160
+ const normalizedExpected = normalizeColor(expectedColor);
161
+ const isNot = this.isNot;
162
+ const prefix = isNot ? 'not.toHaveMaterialVectorParameter' : 'toHaveMaterialVectorParameter';
163
+ const portStr = locator.portTag || '';
164
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}('${parameterName}', ${JSON.stringify(expectedColor)})`;
165
+ return await test_1.default.step(stepName, async () => {
166
+ const { passed, last } = await poll(async () => {
167
+ const res = await locator.evaluate('GetMaterialParameter', {
168
+ parameterName,
169
+ parameterType: 'Vector',
170
+ slotIndex,
171
+ componentName
172
+ }, parameterName, true);
173
+ return res?.data;
174
+ }, data => {
175
+ if (!data || !data.found || !data.value)
176
+ return false;
177
+ const matches = compareVectorValues(data.value, normalizedExpected, tolerance);
178
+ return isNot ? !matches : matches;
179
+ }, timeout);
180
+ const receivedValue = last?.found ? last.value : undefined;
181
+ const paramFound = last?.found ?? false;
182
+ return {
183
+ pass: isNot ? !passed : passed,
184
+ message: () => `Timed out waiting for material vector parameter '${parameterName}' to match ${JSON.stringify(normalizedExpected)} (slot ${slotIndex}).\n` +
185
+ `Received: ${JSON.stringify(receivedValue)} (hex: ${receivedValue?.hex ?? 'unknown'}) (parameter found: ${paramFound})`,
186
+ actual: receivedValue,
187
+ expected: normalizedExpected
188
+ };
189
+ });
190
+ },
191
+ async toHaveMaterial(locator, expectedMaterial, options) {
192
+ const timeout = options?.timeout ?? 5000;
193
+ const slotIndex = options?.slotIndex ?? 0;
194
+ const componentName = options?.componentName;
195
+ const isNot = this.isNot;
196
+ const prefix = isNot ? 'not.toHaveMaterial' : 'toHaveMaterial';
197
+ const portStr = locator.portTag || '';
198
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}(${expectedMaterial})`;
199
+ return await test_1.default.step(stepName, async () => {
200
+ const { passed, last } = await poll(async () => {
201
+ const res = await locator.evaluate('GetMaterialParameter', {
202
+ parameterType: 'Info',
203
+ slotIndex,
204
+ componentName
205
+ }, undefined, true);
206
+ return res?.data;
207
+ }, data => {
208
+ if (!data?.materialName)
209
+ return false;
210
+ const matName = data.materialName;
211
+ const matches = expectedMaterial instanceof RegExp
212
+ ? expectedMaterial.test(matName)
213
+ : (matName.toLowerCase().includes(expectedMaterial.toLowerCase()) || matName === expectedMaterial);
214
+ return isNot ? !matches : matches;
215
+ }, timeout);
216
+ const receivedName = last?.materialName ?? '';
217
+ return {
218
+ pass: isNot ? !passed : passed,
219
+ message: () => `Timed out waiting for material on slot ${slotIndex} to match '${expectedMaterial}'.\n` +
220
+ `Received: '${receivedName}'`,
221
+ actual: receivedName,
222
+ expected: expectedMaterial
223
+ };
224
+ });
225
+ },
226
+ async toBeDynamicMaterial(locator, options) {
227
+ const timeout = options?.timeout ?? 5000;
228
+ const slotIndex = options?.slotIndex ?? 0;
229
+ const componentName = options?.componentName;
230
+ const isNot = this.isNot;
231
+ const prefix = isNot ? 'not.toBeDynamicMaterial' : 'toBeDynamicMaterial';
232
+ const portStr = locator.portTag || '';
233
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}()`;
234
+ return await test_1.default.step(stepName, async () => {
235
+ const { passed, last } = await poll(async () => {
236
+ const res = await locator.evaluate('GetMaterialParameter', {
237
+ parameterType: 'Info',
238
+ slotIndex,
239
+ componentName
240
+ }, undefined, true);
241
+ return res?.data;
242
+ }, data => {
243
+ if (!data)
244
+ return false;
245
+ const isDyn = data.isDynamic === true;
246
+ return isNot ? !isDyn : isDyn;
247
+ }, timeout);
248
+ const isDynamic = last?.isDynamic ?? false;
249
+ return {
250
+ pass: isNot ? !passed : passed,
251
+ message: () => `Timed out waiting for material '${last?.materialName ?? ''}' on slot ${slotIndex} to ${isNot ? 'not be' : 'be'} dynamic.\n` +
252
+ `Received: isDynamic=${isDynamic}`,
253
+ actual: isDynamic,
254
+ expected: !isNot
255
+ };
256
+ });
257
+ },
258
+ async toHaveMaterialTextureParameter(locator, parameterName, expectedTexture, options) {
259
+ const timeout = options?.timeout ?? 5000;
260
+ const slotIndex = options?.slotIndex ?? 0;
261
+ const componentName = options?.componentName;
262
+ const isNot = this.isNot;
263
+ const prefix = isNot ? 'not.toHaveMaterialTextureParameter' : 'toHaveMaterialTextureParameter';
264
+ const portStr = locator.portTag || '';
265
+ const stepName = `${portStr}expect(${locator.toString()}).${prefix}('${parameterName}', ${expectedTexture})`;
266
+ return await test_1.default.step(stepName, async () => {
267
+ const { passed, last } = await poll(async () => {
268
+ const res = await locator.evaluate('GetMaterialParameter', {
269
+ parameterName,
270
+ parameterType: 'Texture',
271
+ slotIndex,
272
+ componentName
273
+ }, parameterName, true);
274
+ return res?.data;
275
+ }, data => {
276
+ if (!data || !data.found)
277
+ return false;
278
+ const texName = data.value?.textureName ?? '';
279
+ const matches = expectedTexture instanceof RegExp
280
+ ? expectedTexture.test(texName)
281
+ : (texName.toLowerCase().includes(expectedTexture.toLowerCase()) || texName === expectedTexture);
282
+ return isNot ? !matches : matches;
283
+ }, timeout);
284
+ const receivedName = last?.value?.textureName ?? '';
285
+ const paramFound = last?.found ?? false;
286
+ return {
287
+ pass: isNot ? !passed : passed,
288
+ message: () => `Timed out waiting for material texture parameter '${parameterName}' to match '${expectedTexture}' (slot ${slotIndex}).\n` +
289
+ `Received: '${receivedName}' (found: ${paramFound})`,
290
+ actual: receivedName,
291
+ expected: expectedTexture
292
+ };
293
+ });
294
+ }
295
+ });
@@ -0,0 +1,81 @@
1
+ import { WidgetLocator } from '../core/locators/widget-locator';
2
+ declare global {
3
+ namespace PlaywrightTest {
4
+ interface Matchers<R, T> {
5
+ /**
6
+ * Asserts that a UTextBlock or URichTextBlock widget contains exactly the given text.
7
+ * Auto-retries for up to `timeout` ms (default: 5000).
8
+ */
9
+ toHaveText(expectedText: string, options?: {
10
+ timeout?: number;
11
+ }): T extends WidgetLocator ? Promise<R> : never;
12
+ /**
13
+ * Asserts that a UEditableText or UEditableTextBox widget has the given input value.
14
+ * Auto-retries for up to `timeout` ms (default: 5000).
15
+ */
16
+ toHaveValue(expectedValue: string, options?: {
17
+ timeout?: number;
18
+ }): T extends WidgetLocator ? Promise<R> : never;
19
+ /**
20
+ * Asserts that the widget's text contains the given substring.
21
+ * Auto-retries for up to `timeout` ms (default: 5000).
22
+ */
23
+ toContainText(substring: string, options?: {
24
+ timeout?: number;
25
+ }): T extends WidgetLocator ? Promise<R> : never;
26
+ /**
27
+ * Asserts that the widget is enabled (IsWidgetEnabled).
28
+ * Auto-retries for up to `timeout` ms (default: 5000).
29
+ */
30
+ toBeEnabled(options?: {
31
+ timeout?: number;
32
+ }): T extends WidgetLocator ? Promise<R> : never;
33
+ }
34
+ }
35
+ }
36
+ export interface WidgetMatchers {
37
+ toHaveText(expectedText: string, options?: {
38
+ timeout?: number;
39
+ }): Promise<void>;
40
+ toHaveValue(expectedValue: string, options?: {
41
+ timeout?: number;
42
+ }): Promise<void>;
43
+ toContainText(substring: string, options?: {
44
+ timeout?: number;
45
+ }): Promise<void>;
46
+ toBeEnabled(options?: {
47
+ timeout?: number;
48
+ }): Promise<void>;
49
+ }
50
+ export declare const widgetExpect: import("playwright/test").Expect<{
51
+ toHaveText(this: import("playwright/test").ExpectMatcherState, locator: WidgetLocator, expectedText: string, options?: {
52
+ timeout?: number;
53
+ }): Promise<{
54
+ pass: boolean;
55
+ message: () => string;
56
+ actual: string;
57
+ expected: string;
58
+ }>;
59
+ toHaveValue(this: import("playwright/test").ExpectMatcherState, locator: WidgetLocator, expectedValue: string, options?: {
60
+ timeout?: number;
61
+ }): Promise<{
62
+ pass: boolean;
63
+ message: () => string;
64
+ actual: string;
65
+ expected: string;
66
+ }>;
67
+ toContainText(this: import("playwright/test").ExpectMatcherState, locator: WidgetLocator, substring: string, options?: {
68
+ timeout?: number;
69
+ }): Promise<{
70
+ pass: boolean;
71
+ message: () => string;
72
+ actual: string;
73
+ expected: string;
74
+ }>;
75
+ toBeEnabled(this: import("playwright/test").ExpectMatcherState, locator: WidgetLocator, options?: {
76
+ timeout?: number;
77
+ }): Promise<{
78
+ pass: boolean;
79
+ message: () => string;
80
+ }>;
81
+ }>;