Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
536 changes: 536 additions & 0 deletions tests/repros/assets/example-resistors.kicad_pcb

Large diffs are not rendered by default.

282 changes: 282 additions & 0 deletions tests/repros/assets/imported-silkscreen-cardinal-rotations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
[
{
"type": "source_component",
"source_component_id": "source_T0",
"name": "T0",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_T0",
"source_component_id": "source_T0",
"center": {
"x": -9,
"y": 4
},
"width": 2,
"height": 1,
"rotation": 0,
"layer": "top"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_T0",
"pcb_component_id": "pcb_T0",
"anchor_position": {
"x": -9,
"y": 4
},
"anchor_alignment": "center",
"text": "T0",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "top"
},
{
"type": "source_component",
"source_component_id": "source_T90",
"name": "T90",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_T90",
"source_component_id": "source_T90",
"center": {
"x": -3,
"y": 4
},
"width": 2,
"height": 1,
"rotation": 90,
"layer": "top"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_T90",
"pcb_component_id": "pcb_T90",
"anchor_position": {
"x": -3,
"y": 4
},
"anchor_alignment": "center",
"text": "T90",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "top"
},
{
"type": "source_component",
"source_component_id": "source_T180",
"name": "T180",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_T180",
"source_component_id": "source_T180",
"center": {
"x": 3,
"y": 4
},
"width": 2,
"height": 1,
"rotation": 180,
"layer": "top"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_T180",
"pcb_component_id": "pcb_T180",
"anchor_position": {
"x": 3,
"y": 4
},
"anchor_alignment": "center",
"text": "T180",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "top"
},
{
"type": "source_component",
"source_component_id": "source_T270",
"name": "T270",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_T270",
"source_component_id": "source_T270",
"center": {
"x": 9,
"y": 4
},
"width": 2,
"height": 1,
"rotation": 270,
"layer": "top"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_T270",
"pcb_component_id": "pcb_T270",
"anchor_position": {
"x": 9,
"y": 4
},
"anchor_alignment": "center",
"text": "T270",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "top"
},
{
"type": "source_component",
"source_component_id": "source_B0",
"name": "B0",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_B0",
"source_component_id": "source_B0",
"center": {
"x": -9,
"y": -4
},
"width": 2,
"height": 1,
"rotation": 0,
"layer": "bottom"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_B0",
"pcb_component_id": "pcb_B0",
"anchor_position": {
"x": -9,
"y": -4
},
"anchor_alignment": "center",
"text": "B0",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "bottom"
},
{
"type": "source_component",
"source_component_id": "source_B90",
"name": "B90",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_B90",
"source_component_id": "source_B90",
"center": {
"x": -3,
"y": -4
},
"width": 2,
"height": 1,
"rotation": 90,
"layer": "bottom"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_B90",
"pcb_component_id": "pcb_B90",
"anchor_position": {
"x": -3,
"y": -4
},
"anchor_alignment": "center",
"text": "B90",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "bottom"
},
{
"type": "source_component",
"source_component_id": "source_B180",
"name": "B180",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_B180",
"source_component_id": "source_B180",
"center": {
"x": 3,
"y": -4
},
"width": 2,
"height": 1,
"rotation": 180,
"layer": "bottom"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_B180",
"pcb_component_id": "pcb_B180",
"anchor_position": {
"x": 3,
"y": -4
},
"anchor_alignment": "center",
"text": "B180",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "bottom"
},
{
"type": "source_component",
"source_component_id": "source_B270",
"name": "B270",
"ftype": "simple_resistor",
"resistance": 1000
},
{
"type": "pcb_component",
"pcb_component_id": "pcb_B270",
"source_component_id": "source_B270",
"center": {
"x": 9,
"y": -4
},
"width": 2,
"height": 1,
"rotation": 270,
"layer": "bottom"
},
{
"type": "pcb_silkscreen_text",
"pcb_silkscreen_text_id": "text_B270",
"pcb_component_id": "pcb_B270",
"anchor_position": {
"x": 9,
"y": -4
},
"anchor_alignment": "center",
"text": "B270",
"font": "tscircuit2024",
"font_size": 0.8,
"ccw_rotation": 0,
"layer": "bottom"
}
]
49 changes: 49 additions & 0 deletions tests/repros/imported-bottom-silkscreen.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { expect, test } from "bun:test"
import { readFileSync } from "node:fs"
import { KicadToCircuitJsonConverter } from "kicad-to-circuit-json"
import { unrouteCircuitJson } from "lib/utils/autorouting/unrouteCircuitJson"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

test.failing(
"KiCad subcircuit preserves bottom silkscreen layer and rotation",
async () => {
const converter = new KicadToCircuitJsonConverter()
converter.addFile(
"example-resistors.kicad_pcb",
readFileSync(
new URL("./assets/example-resistors.kicad_pcb", import.meta.url),
"utf8",
),
)
converter.runUntilFinished()
const boardContent = converter
.getOutput()
.filter((elm) => elm.type !== "pcb_board")
const { circuit } = getTestFixture()
circuit.add(
<board width={11} height={8} routingDisabled schematicDisabled>
<subcircuit circuitJson={unrouteCircuitJson(boardContent)} />
</board>,
)
await circuit.renderUntilSettled()
await expect(circuit).toMatchPcbSnapshot(import.meta.path)
await expect(circuit).toMatch3dSnapshot(import.meta.path, {
camPos: [11, 19, 8],
diffTolerance: 0.001,
snapshotSuffix: "top",
})
await expect(circuit).toMatch3dSnapshot(import.meta.path, {
camPos: [11, -19, 8],
diffTolerance: 0.001,
snapshotSuffix: "bottom",
})

// Native KiCad: R2 is on B.SilkS, mirrored, with a 0 degree draw rotation.
expect(
circuit.db.pcb_silkscreen_text.getWhere({ text: "R2" }),
).toMatchObject({
layer: "bottom",
ccw_rotation: 0,
})
},
)
42 changes: 42 additions & 0 deletions tests/repros/imported-silkscreen-cardinal-rotations.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { expect, test } from "bun:test"
import type { AnyCircuitElement } from "circuit-json"
import { getTestFixture } from "tests/fixtures/get-test-fixture"
import importedText from "./assets/imported-silkscreen-cardinal-rotations.json"

test.failing(
"imported silkscreen retains board rotation on both sides",
async () => {
const { circuit } = getTestFixture()
circuit.add(
<board width={26} height={16} routingDisabled schematicDisabled>
<pcbnotetext
text="Top row: top / bottom row: bottom; all labels upright"
pcbY={6.5}
fontSize={0.7}
/>
<subcircuit circuitJson={importedText as AnyCircuitElement[]} />
</board>,
)
await circuit.renderUntilSettled()
await expect(circuit).toMatchPcbSnapshot(import.meta.path)
await expect(circuit).toMatch3dSnapshot(import.meta.path, {
camPos: [24, 42, 18],
diffTolerance: 0.001,
snapshotSuffix: "top",
})
await expect(circuit).toMatch3dSnapshot(import.meta.path, {
camPos: [24, -42, 18],
diffTolerance: 0.001,
snapshotSuffix: "bottom",
})

for (const rotation of [0, 90, 180, 270]) {
expect(
circuit.db.pcb_silkscreen_text.getWhere({ text: `T${rotation}` }),
).toMatchObject({ layer: "top", ccw_rotation: 0 })
expect(
circuit.db.pcb_silkscreen_text.getWhere({ text: `B${rotation}` }),
).toMatchObject({ layer: "bottom", ccw_rotation: 0 })
}
},
)
Loading