diff --git a/lib/components/primitive-components/SmtPad.ts b/lib/components/primitive-components/SmtPad.ts index 8612cf17f..4b7f8443e 100644 --- a/lib/components/primitive-components/SmtPad.ts +++ b/lib/components/primitive-components/SmtPad.ts @@ -87,7 +87,6 @@ export class SmtPad extends PrimitiveComponent { const { _parsedProps: props } = this const isCoveredWithSolderMask = props.coveredWithSolderMask ?? false const shouldCreateSolderPaste = !isCoveredWithSolderMask - if (!props.portHints) return const subcircuit = this.getSubcircuit() @@ -117,6 +116,8 @@ export class SmtPad extends PrimitiveComponent { finalRotationDegrees = (360 - finalRotationDegrees + 360) % 360 } + const portHints = props.portHints?.map((ph) => ph.toString()) ?? [] + let pcb_smtpad: PcbSmtPad | null = null const pcb_component_id = this.parent?.pcb_component_id ?? @@ -128,7 +129,7 @@ export class SmtPad extends PrimitiveComponent { layer: maybeFlipLayer(props.layer ?? "top"), shape: "circle", radius: props.radius!, - port_hints: props.portHints.map((ph) => ph.toString()), + port_hints: portHints, is_covered_with_solder_mask: isCoveredWithSolderMask, x: position.x, y: position.y, @@ -160,7 +161,7 @@ export class SmtPad extends PrimitiveComponent { x: position.x, y: position.y, ccw_rotation: finalRotationDegrees, - port_hints: props.portHints.map((ph) => ph.toString()), + port_hints: portHints, is_covered_with_solder_mask: isCoveredWithSolderMask, subcircuit_id: subcircuit?.subcircuit_id ?? undefined, pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined, @@ -174,7 +175,7 @@ export class SmtPad extends PrimitiveComponent { width: isRotated90Degrees ? props.height! : props.width!, height: isRotated90Degrees ? props.width! : props.height!, corner_radius: props.cornerRadius ?? undefined, - port_hints: props.portHints.map((ph) => ph.toString()), + port_hints: portHints, is_covered_with_solder_mask: isCoveredWithSolderMask, x: position.x, y: position.y, @@ -231,7 +232,7 @@ export class SmtPad extends PrimitiveComponent { x: position.x, y: position.y, ccw_rotation: padRotation, - port_hints: props.portHints.map((ph) => ph.toString()), + port_hints: portHints, is_covered_with_solder_mask: isCoveredWithSolderMask, subcircuit_id: subcircuit?.subcircuit_id ?? undefined, pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined, @@ -269,7 +270,7 @@ export class SmtPad extends PrimitiveComponent { layer: maybeFlipLayer(props.layer ?? "top"), shape: "polygon", points: transformedPoints, - port_hints: props.portHints.map((ph) => ph.toString()), + port_hints: portHints, is_covered_with_solder_mask: isCoveredWithSolderMask, subcircuit_id: subcircuit?.subcircuit_id ?? undefined, pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined, @@ -285,7 +286,7 @@ export class SmtPad extends PrimitiveComponent { radius: props.radius!, height: props.height!, width: props.width!, - port_hints: props.portHints.map((ph) => ph.toString()), + port_hints: portHints, is_covered_with_solder_mask: isCoveredWithSolderMask, subcircuit_id: subcircuit?.subcircuit_id ?? undefined, pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined, diff --git a/tests/components/primitive-components/smtpad-without-port-hints.test.tsx b/tests/components/primitive-components/smtpad-without-port-hints.test.tsx new file mode 100644 index 000000000..8159fadd9 --- /dev/null +++ b/tests/components/primitive-components/smtpad-without-port-hints.test.tsx @@ -0,0 +1,33 @@ +import { expect, test } from "bun:test" +import { getTestFixture } from "tests/fixtures/get-test-fixture" + +/** + * Regression test ensuring smtpads render even when no port hints are provided. + */ +test("smtpad within footprint renders without port hints", () => { + const { circuit } = getTestFixture() + + circuit.add( + + + + + + } + /> + , + ) + + circuit.render() + + const smtpads = circuit.db.pcb_smtpad.list() + + expect(smtpads.length).toBe(2) + for (const smtpad of smtpads) { + expect(smtpad.port_hints).toEqual([]) + } +})