Skip to content

Conversation

@seveibar
Copy link
Contributor

Summary

  • add pad stackup shape definitions and validation for plated holes
  • extend plated hole schema to support per-layer pad stackups while enforcing hole geometry requirements
  • cover the new schema with dedicated tests for defaulting and validation

Testing

  • bunx tsc --noEmit
  • bun test

Codex Task

Comment on lines +7 to +121
test("parse hole with pad stackup defaults hole offset to 0", () => {
const hole = pcb_plated_hole.parse({
type: "pcb_plated_hole",
shape: "hole_with_pad_stackup",
hole_shape: "circle",
hole_diameter: 0.3,
x: 1,
y: 2,
layers: ["top", "bottom"],
pad_stackup: [
{
layer: "top",
shape: {
type: "rect",
width: 0.9,
height: 0.7,
ccw_rotation: 15,
},
},
{
layer: "bottom",
shape: {
type: "polygon",
pad_outline: [
{ x: -0.4, y: -0.3 },
{ x: 0.4, y: -0.3 },
{ x: 0, y: 0.5 },
],
},
},
],
}) as PcbHoleWithPadStackup

expect(hole.hole_offset_x).toBe(0)
expect(hole.hole_offset_y).toBe(0)
expect(hole.pad_stackup[0]?.shape).toEqual({
type: "rect",
width: 0.9,
height: 0.7,
ccw_rotation: 15,
})
expect(hole.pad_stackup[1]?.shape.type).toBe("polygon")
})

test("hole with pad stackup requires hole dimensions for non-circular holes", () => {
expect(() =>
pcb_plated_hole.parse({
type: "pcb_plated_hole",
shape: "hole_with_pad_stackup",
hole_shape: "oval",
x: 0,
y: 0,
layers: ["top"],
pad_stackup: [
{
layer: "top",
shape: {
type: "circle",
outer_diameter: 0.6,
},
},
],
}),
).toThrow()
})

test("hole with pad stackup requires rotation for rotated pill holes", () => {
expect(() =>
pcb_plated_hole.parse({
type: "pcb_plated_hole",
shape: "hole_with_pad_stackup",
hole_shape: "rotated_pill",
hole_width: 0.4,
hole_height: 0.9,
x: 0,
y: 0,
layers: ["top"],
pad_stackup: [
{
layer: "top",
shape: {
type: "pill",
width: 0.6,
height: 0.9,
},
},
],
}),
).toThrow()

const rotatedPillHole = pcb_plated_hole.parse({
type: "pcb_plated_hole",
shape: "hole_with_pad_stackup",
hole_shape: "rotated_pill",
hole_width: 0.4,
hole_height: 0.9,
hole_ccw_rotation: 45,
x: 0,
y: 0,
layers: ["top"],
pad_stackup: [
{
layer: "top",
shape: {
type: "rotated_pill",
width: 0.6,
height: 0.9,
ccw_rotation: 90,
},
},
],
}) as PcbHoleWithPadStackup

expect(rotatedPillHole.hole_ccw_rotation).toBe(45)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file contains 3 test() calls (lines 7, 51, and 73), but according to the style guide rule about test file organization, a *.test.ts file may have AT MOST one test(...) function. After that, the user should split into multiple, numbered files. To fix this, split the tests into separate files like: pcb_hole_with_pad_stackup1.test.ts, pcb_hole_with_pad_stackup2.test.ts, and pcb_hole_with_pad_stackup3.test.ts, with each file containing only one test() call.

Spotted by Graphite Agent (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@seveibar
Copy link
Contributor Author

CC @Abse2001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants