Skip to content

feat: add is_extended_promotional column to all component tables (#92)#146

Open
promisingcoder wants to merge 1 commit intotscircuit:mainfrom
promisingcoder:feat/add-extended-promotional-column
Open

feat: add is_extended_promotional column to all component tables (#92)#146
promisingcoder wants to merge 1 commit intotscircuit:mainfrom
promisingcoder:feat/add-extended-promotional-column

Conversation

@promisingcoder
Copy link

Summary

Adds is_extended_promotional boolean column to all 37 derived component tables, making it filterable in the UI.

Changes

  • Added is_extended_promotional to all derived table specs (extraColumns + mapToTable)
  • Updated generated Kysely types
  • Added filter support to capacitors, resistors, and resistor_arrays routes (UI checkbox + query filter)
  • Added 3 test files for the new filter

Test Results

81 pass, 15 fail (all pre-existing), 2 errors (all pre-existing) — no regressions introduced

Fixes #92

/claim

JLCPCB has "extended promotional" parts that act as basic parts for a
limited time. This adds the is_extended_promotional boolean column to
make this information available and filterable across the application.

Changes:
- Add is_extended_promotional to BaseComponent interface and DerivedTableSpec type
- Add the column to all 37 derived table specs (extraColumns + mapToTable)
- Update generated Kysely types to include the new column
- Add is_extended_promotional filter param and UI checkbox to capacitors,
  resistors, and resistor_arrays routes (matching existing is_basic/is_preferred pattern)
- Add tests verifying the new column and filter work correctly

Closes tscircuit#92

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment on lines +1 to +31
import { test, expect } from "bun:test"
import { getTestServer } from "tests/fixtures/get-test-server"

test("GET /capacitors/list JSON response includes is_extended_promotional field", async () => {
const { axios } = await getTestServer()

const res = await axios.get("/capacitors/list?json=true")

expect(res.status).toBe(200)
expect(res.data).toHaveProperty("capacitors")
expect(Array.isArray(res.data.capacitors)).toBe(true)

// If there are any capacitors, verify the field exists
if (res.data.capacitors.length > 0) {
const capacitor = res.data.capacitors[0]
expect(capacitor).toHaveProperty("is_extended_promotional")
expect(typeof capacitor.is_extended_promotional).toBe("boolean")
}
})

test("GET /capacitors/list with is_extended_promotional filter does not error", async () => {
const { axios } = await getTestServer()

const res = await axios.get(
"/capacitors/list?json=true&is_extended_promotional=true",
)

expect(res.status).toBe(200)
expect(res.data).toHaveProperty("capacitors")
expect(Array.isArray(res.data.capacitors)).toBe(true)
})
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, which violates the rule that a *.test.ts file may have AT MOST one test(...). After that, the user should split into multiple, numbered files. The file should be split into two separate files: 'extended-promotional1.test.ts' and 'extended-promotional2.test.ts', with each containing only one test() function.

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

Fix in Graphite


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

Comment on lines +1 to +30
import { test, expect } from "bun:test"
import { getTestServer } from "tests/fixtures/get-test-server"

test("GET /resistor_arrays/list JSON response includes is_extended_promotional field", async () => {
const { axios } = await getTestServer()

const res = await axios.get("/resistor_arrays/list?json=true")

expect(res.status).toBe(200)
expect(res.data).toHaveProperty("resistor_arrays")
expect(Array.isArray(res.data.resistor_arrays)).toBe(true)

if (res.data.resistor_arrays.length > 0) {
const resistorArray = res.data.resistor_arrays[0]
expect(resistorArray).toHaveProperty("is_extended_promotional")
expect(typeof resistorArray.is_extended_promotional).toBe("boolean")
}
})

test("GET /resistor_arrays/list with is_extended_promotional filter does not error", async () => {
const { axios } = await getTestServer()

const res = await axios.get(
"/resistor_arrays/list?json=true&is_extended_promotional=true",
)

expect(res.status).toBe(200)
expect(res.data).toHaveProperty("resistor_arrays")
expect(Array.isArray(res.data.resistor_arrays)).toBe(true)
})
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, which violates the rule that a *.test.ts file may have AT MOST one test(...). After that, the user should split into multiple, numbered files. The file should be split into two separate files: 'extended-promotional1.test.ts' and 'extended-promotional2.test.ts', with each containing only one test() function.

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

Fix in Graphite


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

Comment on lines +1 to +31
import { test, expect } from "bun:test"
import { getTestServer } from "tests/fixtures/get-test-server"

test("GET /resistors/list JSON response includes is_extended_promotional field", async () => {
const { axios } = await getTestServer()

const res = await axios.get("/resistors/list?json=true")

expect(res.status).toBe(200)
expect(res.data).toHaveProperty("resistors")
expect(Array.isArray(res.data.resistors)).toBe(true)

// If there are any resistors, verify the field exists
if (res.data.resistors.length > 0) {
const resistor = res.data.resistors[0]
expect(resistor).toHaveProperty("is_extended_promotional")
expect(typeof resistor.is_extended_promotional).toBe("boolean")
}
})

test("GET /resistors/list with is_extended_promotional filter does not error", async () => {
const { axios } = await getTestServer()

const res = await axios.get(
"/resistors/list?json=true&is_extended_promotional=true",
)

expect(res.status).toBe(200)
expect(res.data).toHaveProperty("resistors")
expect(Array.isArray(res.data.resistors)).toBe(true)
})
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, which violates the rule that a *.test.ts file may have AT MOST one test(...). After that, the user should split into multiple, numbered files. The file should be split into two separate files: 'extended-promotional1.test.ts' and 'extended-promotional2.test.ts', with each containing only one test() function.

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

Fix in Graphite


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

Copy link

@rushabhcodes rushabhcodes left a comment

Choose a reason for hiding this comment

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

test is failing

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add is_extended_promotional column to components (from data source)

2 participants