@react-three-dom/cypress 0.1.1 → 0.2.0

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/src/index.d.ts CHANGED
@@ -11,6 +11,12 @@ import type { ObjectMetadata, ObjectInspection, SceneSnapshot } from './types';
11
11
  declare global {
12
12
  namespace Cypress {
13
13
  interface Chainable {
14
+ // ---- Debug ----
15
+ /** Enable debug logging. Mirrors [r3f-dom:*] browser logs to Cypress command log. */
16
+ r3fEnableDebug(): Chainable<void>;
17
+ /** Log the full scene tree to the Cypress command log and browser console. */
18
+ r3fLogScene(): Chainable<void>;
19
+
14
20
  // ---- Interactions ----
15
21
  /** Click a 3D object by testId or uuid. */
16
22
  r3fClick(idOrUuid: string): Chainable<void>;
@@ -26,6 +32,11 @@ declare global {
26
32
  r3fWheel(idOrUuid: string, options?: { deltaY?: number; deltaX?: number }): Chainable<void>;
27
33
  /** Click empty space to trigger onPointerMissed handlers. */
28
34
  r3fPointerMiss(): Chainable<void>;
35
+ /** Draw a freeform path on the canvas (for drawing/annotation apps). */
36
+ r3fDrawPath(
37
+ points: Array<{ x: number; y: number; pressure?: number }>,
38
+ options?: { stepDelayMs?: number; pointerType?: 'mouse' | 'pen' | 'touch'; clickAtEnd?: boolean },
39
+ ): Chainable<{ eventCount: number; pointCount: number }>;
29
40
 
30
41
  // ---- Selection ----
31
42
  /** Select a 3D object (highlights in scene). */
@@ -43,6 +54,16 @@ declare global {
43
54
  /** Get the total number of tracked objects. */
44
55
  r3fGetCount(): Chainable<number>;
45
56
 
57
+ // ---- BIM/CAD queries ----
58
+ /** Get all objects of a given Three.js type (e.g. "Mesh", "Group", "Line"). */
59
+ r3fGetByType(type: string): Chainable<ObjectMetadata[]>;
60
+ /** Get objects that have a specific userData key (and optionally matching value). */
61
+ r3fGetByUserData(key: string, value?: unknown): Chainable<ObjectMetadata[]>;
62
+ /** Count objects of a given Three.js type. */
63
+ r3fGetCountByType(type: string): Chainable<number>;
64
+ /** Batch lookup: get metadata for multiple objects by testId or uuid. */
65
+ r3fGetObjects(ids: string[]): Chainable<Record<string, ObjectMetadata | null>>;
66
+
46
67
  // ---- Waiters ----
47
68
  /** Wait until the scene is ready (bridge available, object count stable). */
48
69
  r3fWaitForSceneReady(options?: {
@@ -56,29 +77,86 @@ declare global {
56
77
  pollIntervalMs?: number;
57
78
  timeout?: number;
58
79
  }): Chainable<void>;
80
+ /** Wait until a specific object (by testId or uuid) exists in the scene. */
81
+ r3fWaitForObject(
82
+ idOrUuid: string,
83
+ options?: {
84
+ bridgeTimeout?: number;
85
+ objectTimeout?: number;
86
+ pollIntervalMs?: number;
87
+ },
88
+ ): Chainable<void>;
89
+ /** Wait until new object(s) appear in the scene (for drawing/annotation apps). */
90
+ r3fWaitForNewObject(options?: {
91
+ type?: string;
92
+ nameContains?: string;
93
+ pollIntervalMs?: number;
94
+ timeout?: number;
95
+ }): Chainable<{ newObjects: ObjectMetadata[]; newUuids: string[]; count: number }>;
59
96
  }
60
97
 
61
98
  interface Assertion {
99
+ // ---- Tier 1: Metadata-based assertions (cheap) ----
62
100
  /** Assert that a 3D object with the given testId/uuid exists. */
63
101
  r3fExist(idOrUuid: string): Assertion;
64
102
  /** Assert that a 3D object is visible. */
65
103
  r3fVisible(idOrUuid: string): Assertion;
66
- /** Assert that a 3D object is in the camera frustum. */
67
- r3fInFrustum(idOrUuid: string): Assertion;
68
104
  /** Assert object position within tolerance. */
69
- r3fPosition(
70
- idOrUuid: string,
71
- expected: [number, number, number],
72
- tolerance?: number,
73
- ): Assertion;
105
+ r3fPosition(idOrUuid: string, expected: [number, number, number], tolerance?: number): Assertion;
106
+ /** Assert object rotation (Euler radians) within tolerance. */
107
+ r3fRotation(idOrUuid: string, expected: [number, number, number], tolerance?: number): Assertion;
108
+ /** Assert object scale within tolerance. */
109
+ r3fScale(idOrUuid: string, expected: [number, number, number], tolerance?: number): Assertion;
110
+ /** Assert object type (Mesh, Group, Line, Points, etc.). */
111
+ r3fType(idOrUuid: string, expectedType: string): Assertion;
112
+ /** Assert object name. */
113
+ r3fName(idOrUuid: string, expectedName: string): Assertion;
114
+ /** Assert geometry type (BoxGeometry, PlaneGeometry, BufferGeometry, etc.). */
115
+ r3fGeometryType(idOrUuid: string, expectedGeoType: string): Assertion;
116
+ /** Assert material type (MeshStandardMaterial, ShaderMaterial, etc.). */
117
+ r3fMaterialType(idOrUuid: string, expectedMatType: string): Assertion;
118
+ /** Assert number of direct children. */
119
+ r3fChildCount(idOrUuid: string, expectedCount: number): Assertion;
120
+ /** Assert object's parent by testId, uuid, or name. */
121
+ r3fParent(idOrUuid: string, expectedParent: string): Assertion;
74
122
  /** Assert InstancedMesh instance count. */
75
123
  r3fInstanceCount(idOrUuid: string, expectedCount: number): Assertion;
124
+
125
+ // ---- Tier 2: Inspection-based assertions (heavier) ----
126
+ /** Assert that a 3D object is in the camera frustum. */
127
+ r3fInFrustum(idOrUuid: string): Assertion;
76
128
  /** Assert world-space bounding box within tolerance. */
77
129
  r3fBounds(
78
130
  idOrUuid: string,
79
131
  expected: { min: [number, number, number]; max: [number, number, number] },
80
132
  tolerance?: number,
81
133
  ): Assertion;
134
+ /** Assert material color (hex string, e.g. '#ff0000'). */
135
+ r3fColor(idOrUuid: string, expectedColor: string): Assertion;
136
+ /** Assert material opacity (0–1) within tolerance. */
137
+ r3fOpacity(idOrUuid: string, expectedOpacity: number, tolerance?: number): Assertion;
138
+ /** Assert material.transparent === true. */
139
+ r3fTransparent(idOrUuid: string): Assertion;
140
+ /** Assert geometry vertex count. */
141
+ r3fVertexCount(idOrUuid: string, expectedCount: number): Assertion;
142
+ /** Assert geometry triangle count. */
143
+ r3fTriangleCount(idOrUuid: string, expectedCount: number): Assertion;
144
+ /** Assert a specific key (and optionally value) in userData. */
145
+ r3fUserData(idOrUuid: string, key: string, expectedValue?: unknown): Assertion;
146
+ /** Assert material has a map texture (optionally by name). */
147
+ r3fMapTexture(idOrUuid: string, expectedMapName?: string): Assertion;
148
+
149
+ // ---- Scene-level assertions ----
150
+ /** Assert total object count in the scene. */
151
+ r3fObjectCount(expected: number): Assertion;
152
+ /** Assert total object count is greater than a minimum. */
153
+ r3fObjectCountGreaterThan(min: number): Assertion;
154
+ /** Assert count of objects of a specific type. */
155
+ r3fCountByType(type: string, expected: number): Assertion;
156
+ /** Assert total triangle count across all meshes. */
157
+ r3fTotalTriangleCount(expected: number): Assertion;
158
+ /** Assert total triangle count is less than a maximum (performance budget). */
159
+ r3fTotalTriangleCountLessThan(max: number): Assertion;
82
160
  }
83
161
  }
84
162
  }