Merged
Conversation
Add Jest tests for circuit tool logic (snap, gcd, componentSize, getComponentNodes) in __tests__/canvas/circuit-symbol.test.js and a test helper __tests__/canvas/helpers.js to extract and eval inline scripts from public/tools HTML files. Also relocate favicon to app/favicon.ico and remove several legacy touch/fav icon and image files (apple-touch icons, favicon-16/32, mstile, stringSq) as part of asset cleanup.
Add a new test suite (jsdom) for pure logic functions from circuit_diagram_secjc.html. Tests verify GRID (22.4), snap() behavior, rotatePoint() rotations, componentSize() for various components (transistor, transformer, bulb, battery, resistor), and getComponentNodes() geometry for transistor, transformer and standard components (resistor/arrow). Uses loadCircuitScript helper to import functions under test.
Add a new Jest test file (__tests__/canvas/object-circuit.test.js) that exercises pure logic from object_circuitv2.html. The tests run in the jsdom environment and validate rotatePoint at cardinal angles, getLocalNodes for bulb/battery/switch/unknown types, and getComponentNodes for world-space node positions. The file uses a loadCircuitScript helper and sets up a minimal DOM with SVG and tool buttons to initialise the script.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Jest unit coverage for geometry/logic utilities embedded in the circuit HTML tools by extracting and evaluating their inline scripts under jsdom, plus includes an app favicon for the Next.js host.
Changes:
- Added new Jest test suites for
circuit_diagram_creatorv2.html,circuit_diagram_secjc.html, andobject_circuitv2.htmllogic functions. - Introduced a shared test helper to extract and
evalthe first inline<script>from tool HTML files and return selected symbols. - Added
app/favicon.ico.
Reviewed changes
Copilot reviewed 4 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| app/favicon.ico | Adds favicon asset for the Next.js app. |
| tests/canvas/helpers.js | Test helper for extracting/evaluating inline tool scripts and returning selected exports. |
| tests/canvas/circuit-symbol.test.js | Unit tests for symbol tool logic (snap/gcd/sizing/nodes) via evaluated inline script. |
| tests/canvas/circuit-secjc.test.js | Unit tests for SECJC tool logic (snap/rotate/sizing/nodes) via evaluated inline script. |
| tests/canvas/object-circuit.test.js | Unit tests for object tool logic (rotate/local nodes/world nodes) via evaluated inline script. |
Add two new test suites: - __tests__/canvas/water-tank.test.js: jsdom tests that set up a minimal DOM, load the water_tank_generator IIFE via a helper, and exercise rendering logic (initial SVG render, water polygon visibility based on percent, mode switching, and invalid-input error states). - __tests__/pages/metrics.test.tsx: jsdom tests for the async MetricsPage server component that mock the DB (getDb), call render(await MetricsPage()), and verify aggregate stats, per-tool rows and counts, default-zero behavior when data is absent, and DB error handling. These tests exercise UI behavior and server-component rendering with mocked database responses to catch regressions in rendering and error states.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add new DOM controls to canvas test fixtures (rotate 180, text input, font size, add/update text, zoom in/out/reset) in circuit-symbol and object-circuit tests to match UI changes. Update MetricsPage test to reflect new mocked MAU/export values and adjust expectations. Add a jest.config testPathIgnorePatterns entry to ignore __tests__/canvas/helpers.js during test discovery.
…o feat/update-tests
…-circuit tests Agent-Logs-Url: https://github.com/String-sg/diagrams/sessions/a3e69062-b05e-4798-b3f4-c90adcb3b978 Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Adjust unit tests to reflect changes in component scaling and minor UI label updates. Tests in circuit-symbol now account for COMPONENT_SCALE = 0.8 by using toBeCloseTo for componentSize and node position assertions, and update snap() negative-value check to use Math.abs. object-circuit tests updated zoom button labels (+, −, 100%) and remove some unused text-related controls. water-tank test tightened the water polygon assertion to count polygons (ensuring only the clipPath polygon remains) rather than a simple string absence check.
Update CLAUDE.md test documentation to reflect expanded test suites (now 8 suites, 95 tests), add breakdown of API/pages/canvas tests, canvas helpers notes, and a gotcha about snap(-10) returning -0. Adjust __tests__/canvas/object-circuit.test.js expectations to account for COMPONENT_SCALE=0.8: replace exact object equality with toBeCloseTo assertions and update numeric expected positions (battery node offsets -> ±36.8 local, world positions ~63.2/136.8; rotated battery x positions ~136.8/63.2; switch endpoints -> ±32). Add clarifying comments for the scaled geometry.
Update CLAUDE.md test documentation to reflect expanded test suites (now 8 suites, 95 tests), add breakdown of API/pages/canvas tests, canvas helpers notes, and a gotcha about snap(-10) returning -0. Adjust __tests__/canvas/object-circuit.test.js expectations to account for COMPONENT_SCALE=0.8: replace exact object equality with toBeCloseTo assertions and update numeric expected positions (battery node offsets -> ±36.8 local, world positions ~63.2/136.8; rotated battery x positions ~136.8/63.2; switch endpoints -> ±32). Add clarifying comments for the scaled geometry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
circuit-symbol.test.js: add missing DOM elements (rotate180Btn, zoom buttons, text controls) tobeforeAllcircuit-symbol.test.js: updatecomponentSize()andgetComponentNodes()assertions to reflectCOMPONENT_SCALE = 0.8object-circuit.test.js: updategetLocalNodes()andgetComponentNodes()assertions to reflectCOMPONENT_SCALE = 0.8/BULB_SCALE = 1📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.