Skip to content

Commit eaede0e

Browse files
TheAuroraAIclaude
andcommitted
test: add pcb snapshot test for polygon smtpads with solder mask coverage
Adds a PCB snapshot test demonstrating polygon-shaped smtpads with coveredWithSolderMask in a 5-segment capacitive touch slider layout. The test verifies: - 5 diamond-shaped polygon pads created correctly - All pads have is_covered_with_solder_mask: true - No solder paste generated for solder-mask-covered pads - Visual PCB snapshot for regression detection Relates to tscircuit/tscircuit#786 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6f979fd commit eaede0e

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { test, expect } from "bun:test"
2+
import { getTestFixture } from "tests/fixtures/get-test-fixture"
3+
4+
/**
5+
* Snapshot test for polygon-shaped smtpads with solder mask coverage.
6+
*
7+
* Demonstrates using polygon smtpads to create a 5-segment capacitive touch
8+
* slider footprint — a common use case where pads must be covered with solder
9+
* mask so the finger is insulated from direct electrical contact.
10+
*
11+
* Relates to: https://github.com/tscircuit/tscircuit/issues/786
12+
*/
13+
test("polygon smtpad with soldermask - capacitive touch slider", () => {
14+
const { project } = getTestFixture()
15+
16+
const segmentCount = 5
17+
const spacing = 3.0 // mm between segment centers
18+
19+
// Diamond-shaped polygon points (relative to pad center)
20+
const diamondPoints = (hw: number, hh: number) => [
21+
{ x: 0, y: hh },
22+
{ x: hw, y: 0 },
23+
{ x: 0, y: -hh },
24+
{ x: -hw, y: 0 },
25+
]
26+
27+
project.add(
28+
<board width="22mm" height="12mm">
29+
<chip
30+
name="U1"
31+
footprint={
32+
<footprint>
33+
{Array.from({ length: segmentCount }, (_, i) => {
34+
const cx = (i - Math.floor(segmentCount / 2)) * spacing
35+
return (
36+
<smtpad
37+
key={i}
38+
shape="polygon"
39+
layer="top"
40+
pcbX={cx}
41+
pcbY={0}
42+
portHints={[`pin${i + 1}`]}
43+
coveredWithSolderMask
44+
points={diamondPoints(1.2, 1.8)}
45+
/>
46+
)
47+
})}
48+
</footprint>
49+
}
50+
/>
51+
</board>,
52+
)
53+
54+
project.render()
55+
56+
// Verify all 5 pads have solder mask coverage set
57+
const pads = project.db.pcb_smtpad.list()
58+
expect(pads).toHaveLength(segmentCount)
59+
for (const pad of pads) {
60+
expect(pad.is_covered_with_solder_mask).toBe(true)
61+
expect(pad.shape).toBe("polygon")
62+
}
63+
64+
// Verify no solder paste is generated for solder-mask-covered pads
65+
expect(project.db.pcb_solder_paste.list()).toHaveLength(0)
66+
67+
// Visual PCB snapshot
68+
expect(project).toMatchPcbSnapshot(import.meta.path)
69+
})

0 commit comments

Comments
 (0)