diff --git a/tests/repros/__snapshots__/imported-bottom-silkscreen-bottom-simple-3d.snap.png b/tests/repros/__snapshots__/imported-bottom-silkscreen-bottom-simple-3d.snap.png new file mode 100644 index 0000000000..c322b41483 Binary files /dev/null and b/tests/repros/__snapshots__/imported-bottom-silkscreen-bottom-simple-3d.snap.png differ diff --git a/tests/repros/__snapshots__/imported-bottom-silkscreen-pcb.snap.svg b/tests/repros/__snapshots__/imported-bottom-silkscreen-pcb.snap.svg new file mode 100644 index 0000000000..0c6d76866a --- /dev/null +++ b/tests/repros/__snapshots__/imported-bottom-silkscreen-pcb.snap.svg @@ -0,0 +1 @@ +R1R2RR1RR2 \ No newline at end of file diff --git a/tests/repros/__snapshots__/imported-bottom-silkscreen-top-simple-3d.snap.png b/tests/repros/__snapshots__/imported-bottom-silkscreen-top-simple-3d.snap.png new file mode 100644 index 0000000000..e7d5022a28 Binary files /dev/null and b/tests/repros/__snapshots__/imported-bottom-silkscreen-top-simple-3d.snap.png differ diff --git a/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-bottom-simple-3d.snap.png b/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-bottom-simple-3d.snap.png new file mode 100644 index 0000000000..4ff91b040f Binary files /dev/null and b/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-bottom-simple-3d.snap.png differ diff --git a/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-pcb.snap.svg b/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-pcb.snap.svg new file mode 100644 index 0000000000..067982ac65 --- /dev/null +++ b/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-pcb.snap.svg @@ -0,0 +1 @@ +T0T90T180T270B0B90B180B270Top row: top / bottom row: bottom; all labels upright \ No newline at end of file diff --git a/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-top-simple-3d.snap.png b/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-top-simple-3d.snap.png new file mode 100644 index 0000000000..57c7571e60 Binary files /dev/null and b/tests/repros/__snapshots__/imported-silkscreen-cardinal-rotations-top-simple-3d.snap.png differ diff --git a/tests/repros/assets/example-resistors.kicad_pcb b/tests/repros/assets/example-resistors.kicad_pcb new file mode 100644 index 0000000000..d008b8aac5 --- /dev/null +++ b/tests/repros/assets/example-resistors.kicad_pcb @@ -0,0 +1,536 @@ +(kicad_pcb + (version 20241229) + (generator "pcbnew") + (generator_version "9.0") + (general + (thickness 1.6) + (legacy_teardrops no) + ) + (paper "A4") + (layers + (0 "F.Cu" signal) + (2 "B.Cu" signal) + (9 "F.Adhes" user "F.Adhesive") + (11 "B.Adhes" user "B.Adhesive") + (13 "F.Paste" user) + (15 "B.Paste" user) + (5 "F.SilkS" user "F.Silkscreen") + (7 "B.SilkS" user "B.Silkscreen") + (1 "F.Mask" user) + (3 "B.Mask" user) + (17 "Dwgs.User" user "User.Drawings") + (19 "Cmts.User" user "User.Comments") + (21 "Eco1.User" user "User.Eco1") + (23 "Eco2.User" user "User.Eco2") + (25 "Edge.Cuts" user) + (27 "Margin" user) + (31 "F.CrtYd" user "F.Courtyard") + (29 "B.CrtYd" user "B.Courtyard") + (35 "F.Fab" user) + (33 "B.Fab" user) + (39 "User.1" user) + (41 "User.2" user) + (43 "User.3" user) + (45 "User.4" user) + ) + (setup + (pad_to_mask_clearance 0) + (allow_soldermask_bridges_in_footprints no) + (tenting front back) + (pcbplotparams + (layerselection 0x00000000_00000000_55555555_5755f5ff) + (plot_on_all_layers_selection 0x00000000_00000000_00000000_00000000) + (disableapertmacros no) + (usegerberextensions no) + (usegerberattributes yes) + (usegerberadvancedattributes yes) + (creategerberjobfile yes) + (dashed_line_dash_ratio 12.000000) + (dashed_line_gap_ratio 3.000000) + (svgprecision 4) + (plotframeref no) + (mode 1) + (useauxorigin no) + (hpglpennumber 1) + (hpglpenspeed 20) + (hpglpendiameter 15.000000) + (pdf_front_fp_property_popups yes) + (pdf_back_fp_property_popups yes) + (pdf_metadata yes) + (pdf_single_document no) + (dxfpolygonmode yes) + (dxfimperialunits yes) + (dxfusepcbnewfont yes) + (psnegative no) + (psa4output no) + (plot_black_and_white yes) + (sketchpadsonfab no) + (plotpadnumbers no) + (hidednponfab no) + (sketchdnponfab yes) + (crossoutdnponfab yes) + (subtractmaskfromsilk no) + (outputformat 1) + (mirror no) + (drillshape 1) + (scaleselection 1) + (outputdirectory "") + ) + ) + (net 0 "") + (net 1 "unconnected-(R1-Pad2)") + (net 2 "Net-(R1-Pad1)") + (net 3 "unconnected-(R2-Pad2)") + (footprint "Resistor_SMD:R_0402_1005Metric" + (layer "F.Cu") + (uuid "f6c9b24b-2316-45c9-bc9e-74d99412a839") + (at 95.49 73.5) + (descr "Resistor SMD 0402 (1005 Metric), square (rectangular) end terminal, IPC-7351 nominal, (Body size source: IPC-SM-782 page 72, https://www.pcb-3d.com/wordpress/wp-content/uploads/ipc-sm-782a_amendment_1_and_2.pdf), generated with kicad-footprint-generator") + (tags "resistor") + (property "Reference" "R1" + (at 0 -1.17 0) + (layer "F.SilkS") + (uuid "6b031158-df53-4492-8301-5ed3c0e1f5ba") + (effects + (font + (size 1 1) + (thickness 0.15) + ) + ) + ) + (property "Value" "R" + (at 0 1.17 0) + (layer "F.Fab") + (uuid "961ab83c-8ad4-41e4-9c50-23701efd557c") + (effects + (font + (size 1 1) + (thickness 0.15) + ) + ) + ) + (property "Datasheet" "~" + (at 0 0 0) + (layer "F.Fab") + (hide yes) + (uuid "39ae16f6-65cc-4319-b710-f65cdb5658da") + (effects + (font + (size 1.27 1.27) + (thickness 0.15) + ) + ) + ) + (property "Description" "Resistor" + (at 0 0 0) + (layer "F.Fab") + (hide yes) + (uuid "4b110607-9f1e-4078-9c12-631456027a23") + (effects + (font + (size 1.27 1.27) + (thickness 0.15) + ) + ) + ) + (property ki_fp_filters "R_*") + (path "/387dcdf9-86ad-49b7-a867-3dd1ed1d7e94") + (sheetname "/") + (sheetfile "kicad_laser_prefab_example.kicad_sch") + (attr smd) + (fp_line + (start -0.153641 -0.38) + (end 0.153641 -0.38) + (stroke + (width 0.12) + (type solid) + ) + (layer "F.SilkS") + (uuid "80678011-51b9-4dc6-a509-61d876007565") + ) + (fp_line + (start -0.153641 0.38) + (end 0.153641 0.38) + (stroke + (width 0.12) + (type solid) + ) + (layer "F.SilkS") + (uuid "198381be-552c-40d8-9540-16a1cf8c6e37") + ) + (fp_line + (start -0.93 -0.47) + (end 0.93 -0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "F.CrtYd") + (uuid "1632386b-fc62-4c9f-8cff-22a0e47a16ba") + ) + (fp_line + (start -0.93 0.47) + (end -0.93 -0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "F.CrtYd") + (uuid "0cbc4dee-2555-4ba7-8331-7f29cac6ca61") + ) + (fp_line + (start 0.93 -0.47) + (end 0.93 0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "F.CrtYd") + (uuid "fe215931-3dbb-43a1-a150-27c7e96b3384") + ) + (fp_line + (start 0.93 0.47) + (end -0.93 0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "F.CrtYd") + (uuid "38a654de-c1e1-41a0-b375-bd0efb365f74") + ) + (fp_line + (start -0.525 -0.27) + (end 0.525 -0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "F.Fab") + (uuid "b7da3205-428b-4beb-b2a1-c79b6f3ffa0b") + ) + (fp_line + (start -0.525 0.27) + (end -0.525 -0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "F.Fab") + (uuid "c75e8c1f-86d5-4050-889a-5d45547ceab0") + ) + (fp_line + (start 0.525 -0.27) + (end 0.525 0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "F.Fab") + (uuid "3c163cc6-3042-40bb-8fe7-9b0ca1ab2d2d") + ) + (fp_line + (start 0.525 0.27) + (end -0.525 0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "F.Fab") + (uuid "53c01d74-1234-45b0-aca0-296b3b2f3f6f") + ) + (fp_text user "${REFERENCE}" + (at 0 0 0) + (layer "F.Fab") + (uuid "72da033a-4236-4577-9a52-804d0ca8c795") + (effects + (font + (size 0.26 0.26) + (thickness 0.04) + ) + ) + ) + (pad "1" smd roundrect + (at -0.51 0) + (size 0.54 0.64) + (layers "F.Cu" "F.Mask" "F.Paste") + (roundrect_rratio 0.25) + (net 2 "Net-(R1-Pad1)") + (pintype "passive") + (uuid "81ba88f3-4ac8-46b3-8f50-04a2286fa30e") + ) + (pad "2" smd roundrect + (at 0.51 0) + (size 0.54 0.64) + (layers "F.Cu" "F.Mask" "F.Paste") + (roundrect_rratio 0.25) + (net 1 "unconnected-(R1-Pad2)") + (pintype "passive") + (uuid "139c322b-3086-421d-ab92-a4b0d5c19bd9") + ) + (embedded_fonts no) + (model "${KICAD9_3DMODEL_DIR}/Resistor_SMD.3dshapes/R_0402_1005Metric.step" + (offset + (xyz 0 0 0) + ) + (scale + (xyz 1 1 1) + ) + (rotate + (xyz 0 0 0) + ) + ) + ) + (footprint "Resistor_SMD:R_0402_1005Metric" + (layer "B.Cu") + (uuid "fac8e229-72a3-437f-b449-307243847d85") + (at 100.5 70 180) + (descr "Resistor SMD 0402 (1005 Metric), square (rectangular) end terminal, IPC-7351 nominal, (Body size source: IPC-SM-782 page 72, https://www.pcb-3d.com/wordpress/wp-content/uploads/ipc-sm-782a_amendment_1_and_2.pdf), generated with kicad-footprint-generator") + (tags "resistor") + (property "Reference" "R2" + (at 0 1.17 0) + (layer "B.SilkS") + (uuid "1e4b9b2f-608a-490b-b1fe-f2e27151de2e") + (effects + (font + (size 1 1) + (thickness 0.15) + ) + (justify mirror) + ) + ) + (property "Value" "R" + (at 0 -1.17 0) + (layer "B.Fab") + (uuid "9e065418-ddfe-43ba-b3e2-86f71c071b6e") + (effects + (font + (size 1 1) + (thickness 0.15) + ) + (justify mirror) + ) + ) + (property "Datasheet" "~" + (at 0 0 0) + (layer "B.Fab") + (hide yes) + (uuid "9dfd7168-49a8-42d3-b0b3-ebd6f3554919") + (effects + (font + (size 1.27 1.27) + (thickness 0.15) + ) + (justify mirror) + ) + ) + (property "Description" "Resistor" + (at 0 0 0) + (layer "B.Fab") + (hide yes) + (uuid "eca8f9b3-0092-47cd-adca-635edfa16b27") + (effects + (font + (size 1.27 1.27) + (thickness 0.15) + ) + (justify mirror) + ) + ) + (property ki_fp_filters "R_*") + (path "/2109ad12-2358-4156-958b-09ff10032822") + (sheetname "/") + (sheetfile "kicad_laser_prefab_example.kicad_sch") + (attr smd) + (fp_line + (start -0.153641 0.38) + (end 0.153641 0.38) + (stroke + (width 0.12) + (type solid) + ) + (layer "B.SilkS") + (uuid "63a30d37-73ac-47a8-99a5-f5d2de732204") + ) + (fp_line + (start -0.153641 -0.38) + (end 0.153641 -0.38) + (stroke + (width 0.12) + (type solid) + ) + (layer "B.SilkS") + (uuid "d7c9b58a-0539-4ae2-ad92-3ab0bedda73b") + ) + (fp_line + (start 0.93 0.47) + (end 0.93 -0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "B.CrtYd") + (uuid "991f1251-38bd-4555-b271-225408dfeb14") + ) + (fp_line + (start 0.93 -0.47) + (end -0.93 -0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "B.CrtYd") + (uuid "2b146773-1e3a-49cc-9d65-aa951db40862") + ) + (fp_line + (start -0.93 0.47) + (end 0.93 0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "B.CrtYd") + (uuid "bfc36e21-9b14-403f-81b2-63ff468e0f8d") + ) + (fp_line + (start -0.93 -0.47) + (end -0.93 0.47) + (stroke + (width 0.05) + (type solid) + ) + (layer "B.CrtYd") + (uuid "02abbc42-ccf8-409d-ad59-2fd12525caef") + ) + (fp_line + (start 0.525 0.27) + (end 0.525 -0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "B.Fab") + (uuid "1b2f4aba-2a45-41bd-af73-11c34eaced88") + ) + (fp_line + (start 0.525 -0.27) + (end -0.525 -0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "B.Fab") + (uuid "6eac2982-a2f4-4224-a2b7-8f9c1fa768e6") + ) + (fp_line + (start -0.525 0.27) + (end 0.525 0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "B.Fab") + (uuid "35af57b7-4c1a-43bb-b4f7-e0baba8f7e75") + ) + (fp_line + (start -0.525 -0.27) + (end -0.525 0.27) + (stroke + (width 0.1) + (type solid) + ) + (layer "B.Fab") + (uuid "d76eb954-50e9-459e-83e0-6e369a12c27a") + ) + (fp_text user "${REFERENCE}" + (at 0 0 0) + (layer "B.Fab") + (uuid "9823e491-cbb6-4d26-a27b-8cb6e9e494d3") + (effects + (font + (size 0.26 0.26) + (thickness 0.04) + ) + (justify mirror) + ) + ) + (pad "1" smd roundrect + (at -0.51 0 180) + (size 0.54 0.64) + (layers "B.Cu" "B.Mask" "B.Paste") + (roundrect_rratio 0.25) + (net 2 "Net-(R1-Pad1)") + (pintype "passive") + (uuid "1adf6562-0d23-41cf-9669-8784c82803f0") + ) + (pad "2" smd roundrect + (at 0.51 0 180) + (size 0.54 0.64) + (layers "B.Cu" "B.Mask" "B.Paste") + (roundrect_rratio 0.25) + (net 3 "unconnected-(R2-Pad2)") + (pintype "passive") + (uuid "f6646d0a-1a79-4f92-be9e-aacdb2af910d") + ) + (embedded_fonts no) + (model "${KICAD9_3DMODEL_DIR}/Resistor_SMD.3dshapes/R_0402_1005Metric.step" + (offset + (xyz 0 0 0) + ) + (scale + (xyz 1 1 1) + ) + (rotate + (xyz 0 0 0) + ) + ) + ) + (gr_line + (start 103 67) + (end 103 76) + (stroke + (width 0.05) + (type default) + ) + (layer "Edge.Cuts") + (uuid "01c7ef9f-e22a-4814-be92-e4e38f044bef") + ) + (gr_line + (start 103 76) + (end 92.5 76) + (stroke + (width 0.05) + (type default) + ) + (layer "Edge.Cuts") + (uuid "0905f578-06b2-46af-9737-3fe39528ae7b") + ) + (gr_line + (start 92.5 67) + (end 103 67) + (stroke + (width 0.05) + (type default) + ) + (layer "Edge.Cuts") + (uuid "57a8e4b0-416f-4d4a-a850-f0f84d687832") + ) + (gr_line + (start 92.5 76) + (end 92.5 67) + (stroke + (width 0.05) + (type default) + ) + (layer "Edge.Cuts") + (uuid "a3ee52c1-1a7a-4fd9-8e54-138bb4309c3a") + ) + (via + (at 96 70) + (size 0.6) + (drill 0.3) + (layers "F.Cu" "B.Cu") + (net 0) + (uuid "e094ef48-5025-4f2f-a1ff-3e2c434aa17a") + ) + (embedded_fonts no) +) diff --git a/tests/repros/assets/imported-silkscreen-cardinal-rotations.json b/tests/repros/assets/imported-silkscreen-cardinal-rotations.json new file mode 100644 index 0000000000..0ed2599921 --- /dev/null +++ b/tests/repros/assets/imported-silkscreen-cardinal-rotations.json @@ -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" + } +] diff --git a/tests/repros/imported-bottom-silkscreen.test.tsx b/tests/repros/imported-bottom-silkscreen.test.tsx new file mode 100644 index 0000000000..eb4c6eda17 --- /dev/null +++ b/tests/repros/imported-bottom-silkscreen.test.tsx @@ -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( + + + , + ) + 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, + }) + }, +) diff --git a/tests/repros/imported-silkscreen-cardinal-rotations.test.tsx b/tests/repros/imported-silkscreen-cardinal-rotations.test.tsx new file mode 100644 index 0000000000..ebbd244381 --- /dev/null +++ b/tests/repros/imported-silkscreen-cardinal-rotations.test.tsx @@ -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( + + + + , + ) + 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 }) + } + }, +)