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
1 change: 1 addition & 0 deletions src/any_circuit_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const any_circuit_element = z.union([
pcb.pcb_trace_missing_error,
pcb.pcb_placement_error,
pcb.pcb_panelization_placement_error,
pcb.pcb_panelization_placement_warning,
pcb.pcb_port_not_matched_error,
pcb.pcb_port_not_connected_error,
pcb.pcb_via_clearance_error,
Expand Down
3 changes: 3 additions & 0 deletions src/pcb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export * from "./pcb_board"
export * from "./pcb_panel"
export * from "./pcb_placement_error"
export * from "./pcb_panelization_placement_error"
export * from "./pcb_panelization_placement_warning"
export * from "./pcb_trace_hint"
export * from "./pcb_silkscreen_line"
export * from "./pcb_silkscreen_path"
Expand Down Expand Up @@ -79,6 +80,7 @@ import type { PcbBoard } from "./pcb_board"
import type { PcbPanel } from "./pcb_panel"
import type { PcbPlacementError } from "./pcb_placement_error"
import type { PcbPanelizationPlacementError } from "./pcb_panelization_placement_error"
import type { PcbPanelizationPlacementWarning } from "./pcb_panelization_placement_warning"
import type { PcbMissingFootprintError } from "./pcb_missing_footprint_error"
import type { ExternalFootprintLoadError } from "./external_footprint_load_error"
import type { PcbManualEditConflictWarning } from "./pcb_manual_edit_conflict_warning"
Expand Down Expand Up @@ -136,6 +138,7 @@ export type PcbCircuitElement =
| PcbPanel
| PcbPlacementError
| PcbPanelizationPlacementError
| PcbPanelizationPlacementWarning
| PcbTraceHint
| PcbSilkscreenLine
| PcbSilkscreenPath
Expand Down
49 changes: 49 additions & 0 deletions src/pcb/pcb_panelization_placement_warning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { z } from "zod"
import { getZodPrefixedIdWithDefault } from "src/common"
import { expectTypesMatch } from "src/utils/expect-types-match"

export const pcb_panelization_placement_warning = z
.object({
type: z.literal("pcb_panelization_placement_warning"),
pcb_panelization_placement_warning_id: getZodPrefixedIdWithDefault(
"pcb_panelization_placement_warning",
),
warning_type: z
.literal("pcb_panelization_placement_warning")
.default("pcb_panelization_placement_warning"),
message: z.string(),
pcb_panel_id: z.string().optional(),
pcb_board_id: z.string().optional(),
subcircuit_id: z.string().optional(),
})
.describe("Defines a panelization placement warning on the PCB")

export type PcbPanelizationPlacementWarningInput = z.input<
typeof pcb_panelization_placement_warning
>
type InferredPcbPanelizationPlacementWarning = z.infer<
typeof pcb_panelization_placement_warning
>

/**
* Defines a panelization placement warning on the PCB
*/
export interface PcbPanelizationPlacementWarning {
type: "pcb_panelization_placement_warning"
pcb_panelization_placement_warning_id: string
warning_type: "pcb_panelization_placement_warning"
message: string
pcb_panel_id?: string
pcb_board_id?: string
subcircuit_id?: string
}

/**
* @deprecated use PcbPanelizationPlacementWarning
*/
export type PCBPanelizationPlacementWarning = PcbPanelizationPlacementWarning

expectTypesMatch<
PcbPanelizationPlacementWarning,
InferredPcbPanelizationPlacementWarning
>(true)
30 changes: 30 additions & 0 deletions tests/pcb_panelization_placement_warning.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { test, expect } from "bun:test"
import { pcb_panelization_placement_warning } from "../src/pcb/pcb_panelization_placement_warning"
import { any_circuit_element } from "../src/any_circuit_element"

test("pcb_panelization_placement_warning parses", () => {
const warning = pcb_panelization_placement_warning.parse({
type: "pcb_panelization_placement_warning",
message: "panelized board placement has minor issues",
pcb_panel_id: "pcb_panel_1",
pcb_board_id: "pcb_board_1",
})

expect(warning.pcb_panelization_placement_warning_id).toBeDefined()
expect(
warning.pcb_panelization_placement_warning_id.startsWith(
"pcb_panelization_placement_warning",
),
).toBe(true)
expect(warning.pcb_panel_id).toBe("pcb_panel_1")
expect(warning.pcb_board_id).toBe("pcb_board_1")
})

test("any_circuit_element includes pcb_panelization_placement_warning", () => {
const parsed = any_circuit_element.parse({
type: "pcb_panelization_placement_warning",
message: "panelized board placement has minor issues",
})

expect(parsed.type).toBe("pcb_panelization_placement_warning")
})
Comment on lines +5 to +30
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 2 test() functions (lines 5 and 23), but according to the style guide rule about test file structure, 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_panelization_placement_warning1.test.ts' and 'pcb_panelization_placement_warning2.test.ts', with each file containing only one test() function.

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

Fix in Graphite


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