diff --git a/backend/tests/lab-links.test.js b/backend/tests/lab-links.test.js index 42459f5..e1e1c68 100644 --- a/backend/tests/lab-links.test.js +++ b/backend/tests/lab-links.test.js @@ -21,11 +21,16 @@ after(() => cleanup()); */ function seedRow(table, provided) { const cols = db.prepare(`PRAGMA table_info(${table})`).all(); - const row = { ...provided }; + const colNames = new Set(cols.map(c => c.name)); + // Keep ONLY keys that are real columns (drops fields absent in this schema — + // robust to drift, e.g. topics may lack slug/subject_id on some branches). + const row = {}; + for (const k of Object.keys(provided)) if (colNames.has(k)) row[k] = provided[k]; + // Fill any required (NOT NULL, no default) column the caller didn't provide. for (const c of cols) { - if (c.pk) continue; // skip primary key (autoincrement) - if (c.name in row) continue; // caller-provided - if (c.notnull && c.dflt_value === null) { // required, no default → fill placeholder + if (c.pk) continue; + if (c.name in row) continue; + if (c.notnull && c.dflt_value === null) { row[c.name] = /INT|REAL|NUM/i.test(c.type) ? 0 : ''; } }