feat: add is_extended_promotional column to all component tables (#92)#146
feat: add is_extended_promotional column to all component tables (#92)#146promisingcoder wants to merge 1 commit intotscircuit:mainfrom
Conversation
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]>
| 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) | ||
| }) |
There was a problem hiding this comment.
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)
Is this helpful? React 👍 or 👎 to let us know.
| 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) | ||
| }) |
There was a problem hiding this comment.
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)
Is this helpful? React 👍 or 👎 to let us know.
| 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) | ||
| }) |
There was a problem hiding this comment.
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)
Is this helpful? React 👍 or 👎 to let us know.
Summary
Adds
is_extended_promotionalboolean column to all 37 derived component tables, making it filterable in the UI.Changes
is_extended_promotionalto all derived table specs (extraColumns+mapToTable)Test Results
81 pass, 15 fail (all pre-existing), 2 errors (all pre-existing) — no regressions introduced
Fixes #92
/claim