Skip to content

Commit 2333982

Browse files
author
DavidQ
committed
Convert Object Vector Studio to interactive shape drawing with snap modes and polyline - PR_26133_063-click-drag-shape-creation-and-snap-modes
1 parent fbdb0ba commit 2333982

12 files changed

Lines changed: 1025 additions & 213 deletions
Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
1-
# PR_26133_062 Playwright V8 Coverage Report
1+
# Playwright V8 Coverage Report
22

3-
Task: PR_26133_062-object-vector-future-notes-tool-sort-and-live-point-edit
4-
Date: 2026-05-15
3+
PR: PR_26133_063-click-drag-shape-creation-and-snap-modes
54

6-
## Result
7-
8-
PASS - Coverage reporting was generated during `npm run test:workspace-v2`.
9-
10-
- Coverage source: Playwright/Chromium built-in V8 coverage.
11-
- Thresholds: none enforced.
12-
- Coverage is advisory for this PR.
13-
- Source report: `docs/dev/reports/playwright_v8_coverage_report.txt`.
5+
Source: `docs/dev/reports/playwright_v8_coverage_report.txt` generated by `npm run test:workspace-v2`.
146

157
## Exercised Tool Entry Points
168

17-
```text
18-
(82%) Preview Generator V2 - exercised 19 runtime JS files
19-
(74%) Asset Manager V2 - exercised 13 runtime JS files
20-
(62%) Palette Manager V2 - exercised 12 runtime JS files
21-
(91%) Workspace Manager V2 - exercised 10 runtime JS files
22-
```
9+
- (82%) Preview Generator V2 - exercised 19 runtime JS files
10+
- (74%) Asset Manager V2 - exercised 13 runtime JS files
11+
- (62%) Palette Manager V2 - exercised 12 runtime JS files
12+
- (0%) Tool Template V2 - not exercised by this Playwright run
13+
- (91%) Workspace Manager V2 - exercised 10 runtime JS files
14+
- (0%) Workspace Manager - not exercised by this Playwright run
2315

24-
## Relevant Runtime Coverage
16+
## Changed Runtime JS Files Covered
2517

26-
```text
27-
(94%) src/engine/rendering/ObjectVectorRuntimeAssetService.js - executed lines 1131/1131; executed functions 111/118
28-
(95%) tools/object-vector-studio-v2/js/ToolStarterApp.js - executed lines 5731/5731; executed functions 605/636
29-
```
18+
- (83%) tools/object-vector-studio-v2/js/bootstrap.js - executed lines 107/107; executed functions 5/6
19+
- (94%) src/engine/rendering/ObjectVectorRuntimeAssetService.js - executed lines 1135/1135; executed functions 111/118
20+
- (95%) tools/object-vector-studio-v2/js/services/ObjectVectorStudioV2SchemaService.js - executed lines 454/454; executed functions 55/58
21+
- (95%) tools/object-vector-studio-v2/js/ToolStarterApp.js - executed lines 6198/6198; executed functions 635/666
3022

31-
## Guardrail
32-
33-
```text
34-
(100%) none - no changed runtime JS coverage warnings
35-
```
36-
37-
## PR-Specific Note
23+
## Result
3824

39-
The Workspace V2 run exercised Object Vector Studio V2 Shape/Tools ordering, Angle Snap UI/status behavior, live geometry point-handle editing before mouseup, Object Geometry input refresh during drag, workspace dirty tracking during drag, schema validation, and Asteroids runtime object-vector rendering.
25+
- Coverage generation completed successfully after the workspace-v2 Playwright run.
26+
- Coverage is advisory; no coverage threshold is enforced by this PR.
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# PR_26133_062 Workspace V2 Playwright Results
1+
# Playwright Workspace V2 Results
22

3-
Task: PR_26133_062-object-vector-future-notes-tool-sort-and-live-point-edit
4-
Date: 2026-05-15
3+
PR: PR_26133_063-click-drag-shape-creation-and-snap-modes
54

6-
## Result
5+
## Commands
76

8-
PASS - `npm run test:workspace-v2` completed successfully.
7+
- `node --check tools/object-vector-studio-v2/js/ToolStarterApp.js` - PASS
8+
- `node --check tools/object-vector-studio-v2/js/bootstrap.js` - PASS
9+
- `node --check src/engine/rendering/ObjectVectorRuntimeAssetService.js` - PASS
10+
- `node --check tests/helpers/playwrightV8CoverageReporter.mjs` - PASS
11+
- `node -e "JSON.parse(require('fs').readFileSync('tools/schemas/tools/object-vector-studio-v2.schema.json','utf8')); JSON.parse(require('fs').readFileSync('tools/schemas/game.manifest.schema.json','utf8')); console.log('schema json ok')"` - PASS
12+
- `npm run test:workspace-v2` - PASS, 54 passed
913

10-
- Command: `npm run test:workspace-v2`
11-
- Playwright target: `tests/playwright/tools/WorkspaceManagerV2.spec.mjs --project=playwright --workers=1 --reporter=list`
12-
- Final result: 53 passed, 0 failed.
13-
- Runtime/console guard: Workspace Manager V2, Object Vector Studio V2, and Asteroids runtime scenarios completed with no reported page errors.
14+
## Object Vector Studio V2 Verification
1415

15-
## PR-Specific Coverage
16+
- Selecting Shape/Tools enters drawing mode instead of dropping preset defaults.
17+
- Line creation uses first click, live preview, and second click commit.
18+
- Polygon and Polyline creation use clicked points with Enter/double-click finish once valid.
19+
- Esc cancels active drawing without committing invalid geometry.
20+
- Rectangle, Square, Circle, Ellipse, Arc, Triangle, and Text creation use canvas pointer flows.
21+
- Snap Grid, Snap Point, and Snap None are covered during drawing and point dragging; Snap Point renders visible point targets.
22+
- Palette renders at the top of the right column, and Object Transform renders under Shape/Tools.
23+
- No console/runtime errors were reported by the successful Playwright workspace-v2 run.
1624

17-
- Verified `possible.future.adds.txt` contains the Object Vector atomic-object, future World Vector/Scene instancing, Object/World separation, and future 3D point3d/camera/projection/mesh notes.
18-
- Verified Shape/Tools order is Select first, alphabetical middle, and Text last.
19-
- Verified Angle Snap UI documents current behavior: enabled Angle Snap rounds the Rotate action's entered delta to 15 degree increments; disabled uses the raw entered delta.
20-
- Verified point-handle dragging updates geometry, Object Geometry inputs, preview geometry, selection handle position, and workspace dirty state before mouseup.
21-
- Verified Object Vector Studio V2 and Asteroids runtime scenarios completed without page or console errors.
25+
## Notes
2226

23-
## Additional Validation
24-
25-
- Focused Shape/Tools, Square creation, and dirty-state live edit slices passed:
26-
`npx playwright test tests/playwright/tools/WorkspaceManagerV2.spec.mjs --project=playwright --workers=1 --reporter=list --grep "layout shell|square shapes|dirty state"` completed with 3 passed, 0 failed.
27-
- `git diff --check` passed. The command reported existing Windows LF-to-CRLF warnings for touched files and no whitespace errors.
27+
- A small V8 coverage reporter optimization keeps the required coverage write inside the Playwright afterAll timeout without changing coverage semantics.

src/engine/rendering/ObjectVectorRuntimeAssetService.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function shapeBounds(shape) {
179179
y
180180
};
181181
}
182-
if (geometryTool === "polygon") {
182+
if (geometryTool === "polygon" || geometryTool === "polyline") {
183183
const xValues = shape.geometry.points.map((point) => point.x);
184184
const yValues = shape.geometry.points.map((point) => point.y);
185185
const minX = Math.min(...xValues);
@@ -766,15 +766,17 @@ export class ObjectVectorRuntimeAssetService {
766766
context.lineTo(shape.geometry.point2.x, shape.geometry.point2.y);
767767
return;
768768
}
769-
if (geometryTool === "polygon") {
769+
if (geometryTool === "polygon" || geometryTool === "polyline") {
770770
shape.geometry.points.forEach((point, index) => {
771771
if (index === 0) {
772772
context.moveTo(point.x, point.y);
773773
} else {
774774
context.lineTo(point.x, point.y);
775775
}
776776
});
777-
context.closePath();
777+
if (geometryTool === "polygon") {
778+
context.closePath();
779+
}
778780
return;
779781
}
780782
if (geometryTool === "arc") {
@@ -836,9 +838,11 @@ export class ObjectVectorRuntimeAssetService {
836838
if (geometryTool === "line") {
837839
return `<line x1="${shape.geometry.point1.x}" y1="${shape.geometry.point1.y}" x2="${shape.geometry.point2.x}" y2="${shape.geometry.point2.y}"${style}/>`;
838840
}
839-
if (geometryTool === "polygon") {
841+
if (geometryTool === "polygon" || geometryTool === "polyline") {
840842
const points = shape.geometry.points.map((point) => `${point.x},${point.y}`).join(" ");
841-
return `<polygon points="${points}"${style}/>`;
843+
return geometryTool === "polygon"
844+
? `<polygon points="${points}"${style}/>`
845+
: `<polyline points="${points}"${style}/>`;
842846
}
843847
if (geometryTool === "arc") {
844848
const start = {

tests/helpers/playwrightV8CoverageReporter.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ export class PlaywrightV8CoverageReporter {
135135
return;
136136
}
137137
const lineStarts = this.lineStartOffsets(source);
138+
const sourceLines = source.split(/\r?\n/);
138139
for (const range of this.executedRanges(entry)) {
139140
const startLine = this.lineNumberForOffset(lineStarts, range.startOffset);
140141
const endLine = this.lineNumberForOffset(lineStarts, Math.max(range.startOffset, range.endOffset - 1));
141142
for (let line = startLine; line <= endLine; line += 1) {
142-
if (this.isCountableLine(source, line)) {
143+
if (this.isCountableLine(sourceLines, line)) {
143144
record.executedLines.add(line);
144145
}
145146
}
@@ -206,7 +207,8 @@ export class PlaywrightV8CoverageReporter {
206207
}
207208

208209
isCountableLine(source, oneBasedLineNumber) {
209-
const line = source.split(/\r?\n/)[oneBasedLineNumber - 1] || "";
210+
const sourceLines = Array.isArray(source) ? source : source.split(/\r?\n/);
211+
const line = sourceLines[oneBasedLineNumber - 1] || "";
210212
return this.isCountableText(line);
211213
}
212214

0 commit comments

Comments
 (0)