velxio/frontend/src/__tests__
David Montero Crespo 81ac2283c6 fix(canvas): wires follow components on rotation
Rotating a part with the 90° button used to leave every wire pinned to
the pre-rotation pixel coordinates — the component visually unhooked
from its cables. Two paths were missing:

  1. useSimulatorStore.updateComponent only triggered updateWirePositions
     for x/y changes. A rotation went through properties.rotation, so
     wires never recomputed.
  2. calculatePinPosition didn't know about rotation. Even when called,
     it returned the unrotated offset, so the new endpoints would still
     have been wrong.
  3. recordRotate (undo/redo) skipped updateWirePositions on both legs,
     so Ctrl+Z after a rotate left the canvas inconsistent.

Fix:

  - calculatePinPosition gets a 5th `rotation` argument. When non-zero,
    it finds the .dynamic-component-wrapper ancestor in the DOM, reads
    its offsetWidth/Height (layout-only, immune to CSS transforms) to
    locate the wrapper centre, and applies a 2D rotation matrix around
    that pivot. The wrapper top-left is recovered as (componentX - 4,
    componentY - 6) to match the offset convention updateWirePositions
    already uses.
  - updateWirePositions and recalculateAllWirePositions read the per-
    component rotation and thread it through.
  - updateComponent recomputes wires whenever properties.rotation
    changes, mirroring the existing x/y path.
  - recordRotate.execute and .undo both call updateWirePositions so
    Ctrl+Z keeps the canvas coherent.

Tests (pin-position-rotation.test.ts, 6 cases): unrotated identity,
90° (left edge → bottom), 180° (point reflection), 360° round-trip,
negative angles, and a store-level integration that rotates a fake
component and asserts wires[0].start moves to the rotated coordinate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:03:32 -03:00
..
fixtures Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
helpers feat(multi-board): add wire-aware cross-board interconnect router 2026-04-25 19:47:40 -03:00
AVRSimulator.test.ts
PinManager.test.ts
RP2040Simulator.test.ts Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
ammeter-waveform.test.ts
arduino-arduino-spi.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
arduino-esp32-uart.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
arduino-pico-digital.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
arduino-pico-i2c.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
arduino-pico-mixed-uart.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
attiny85-simulation.test.ts test: increase timeout for blink sketch compilation test 2026-04-21 17:23:36 -03:00
capacitor-charge-transient.test.ts
circuit-verifier.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
component-metadata-bmp280.test.ts test(metadata): drill into components array for BMP280 lookup 2026-05-09 23:52:36 +02:00
component-to-spice.test.ts
dual-arduino-digital.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-arduino-hw-uart.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-arduino-multi-protocol.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-arduino-software-serial.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-esp32-uart.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-pico-digital.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-pico-multi-protocol.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
dual-pico-serial-passthrough.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
epaper-part-integration.test.ts feat: add support for UC8159c (ACeP 7-colour) display 2026-04-30 00:27:40 -03:00
esp32-dht22-flow.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
esp32-integration.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
esp32-rectifier-integration.test.ts
esp32-servo-pot.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
esp32-wifi-bluetooth.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
esp32-wifi-compile.test.ts
esp32-wifi-webserver-integration.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
esp32c3-blink.test.ts
esp32c3-simulation.test.ts
esp32c3-wifi-bluetooth.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
examples-analog-live.test.ts
examples-analog.test.ts
examples-circuits.test.ts
examples-digital.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
firmware-loader.test.ts
flip-flop-parts.test.ts
i2c-complex-scenarios.test.ts Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
i2c-esp32-multiboard-bridge.test.ts feat(i2c): cross-board bridging across all velxio boards (AVR/RP2040/ESP32 xtensa+riscv) 2026-05-12 17:51:39 -03:00
i2c-esp32-real-firmware.test.ts feat(i2c): cross-board bridging across all velxio boards (AVR/RP2040/ESP32 xtensa+riscv) 2026-05-12 17:51:39 -03:00
i2c-interconnect-bridge.test.ts Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
i2c-lcd-coupling-gap.test.ts Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
i2c-multi-board-slave-gap.test.ts feat(i2c): cross-board bridging across all velxio boards (AVR/RP2040/ESP32 xtensa+riscv) 2026-05-12 17:51:39 -03:00
i2c-real-firmware.test.ts Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
install-libraries.test.ts fix(tests): restore Frontend Tests CI — patch stale RP2040 mocks + install-libraries 2026-05-02 22:46:32 -03:00
instruments.test.ts
integration.test.ts
interactive-parts.test.ts
interconnect-routing.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
issue-122-micropython-esp32.test.ts Add comprehensive tests for Cyw43Emulator functionality and lifecycle 2026-04-29 00:21:26 -03:00
load-example-transitions.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
logic-gate-parts.test.ts
mega-emulation.test.ts Add HD44780Decoder and various I2C sketches 2026-05-12 14:26:33 -03:00
motor-parts.test.ts
multi-board-integration.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
netlist-builder.test.ts
pi3-pico-uart.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
picow-cyw43-integration.test.ts feat(epaper): Add SVG layouts and emulation plan for ePaper panels 2026-04-29 02:33:59 -03:00
pin-position-rotation.test.ts fix(canvas): wires follow components on rotation 2026-05-12 18:03:32 -03:00
protocol-parts.test.ts
rp2040-pio-servo.test.ts
sensor-parts.test.ts
serial-batching.test.ts
simulation-parts.test.ts
simulation.test.ts
spice-ac.test.ts
spice-active.test.ts
spice-avr-mixed.test.ts
spice-digital.test.ts
spice-mosfet-diag.test.ts style: update ESLint rules and clean up code formatting across multiple files 2026-04-21 17:14:27 -03:00
spice-mosfet-pwm.test.ts
spice-npn-switch-diag.test.ts style: update ESLint rules and clean up code formatting across multiple files 2026-04-21 17:14:27 -03:00
spice-npn-switch-integration.test.ts style: update ESLint rules and clean up code formatting across multiple files 2026-04-21 17:14:27 -03:00
spice-passive.test.ts
spice-rectifier-integration.test.ts
spice-rectifier-live-bootstrap.test.ts
spice-rectifier-live-repro.test.ts
spice-relaxation-oscillator.test.ts
spice-relay-integration.test.ts
spice-signal-generator-tran.test.ts
spice-smoke.test.ts
spice-transient.test.ts
ssd168x-decoder.test.ts feat: add support for UC8159c (ACeP 7-colour) display 2026-04-30 00:27:40 -03:00
ssd1306-render.test.ts
triple-pico-digital-chain.test.ts Add end-to-end tests for ESP32 I2C functionality and circuit verification 2026-05-12 16:55:15 -03:00
uc8159c-decoder.test.ts feat: add support for UC8159c (ACeP 7-colour) display 2026-04-30 00:27:40 -03:00
undo-redo.test.ts feat(canvas): undo/redo command pattern + history slice 2026-05-08 12:03:17 -03:00
virtual-i2c-devices.test.ts refactor: rename wokwi-libs/ → third-party/ 2026-05-03 00:58:57 -03:00
voltmeter-waveform.test.ts
waveform-stats.test.ts