fix: update all tests and MCP catalog tool for manufacturerId schema migration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, describe, expect, it } from "bun:test";
|
||||
import { globalItems } from "../../src/db/schema.ts";
|
||||
import { globalItems, manufacturers } from "../../src/db/schema.ts";
|
||||
import {
|
||||
createCandidate,
|
||||
createThread,
|
||||
@@ -618,6 +618,15 @@ describe("Thread Service", () => {
|
||||
});
|
||||
|
||||
describe("catalog-linked candidates (globalItemId)", () => {
|
||||
async function insertManufacturer(testDb: any, name: string) {
|
||||
const slug = name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
||||
const [row] = await testDb
|
||||
.insert(manufacturers)
|
||||
.values({ name, slug, website: `https://${slug}.com` })
|
||||
.returning();
|
||||
return row;
|
||||
}
|
||||
|
||||
async function insertGlobalItem(
|
||||
testDb: any,
|
||||
data: {
|
||||
@@ -628,7 +637,14 @@ describe("Thread Service", () => {
|
||||
imageUrl?: string;
|
||||
},
|
||||
) {
|
||||
const [row] = await testDb.insert(globalItems).values(data).returning();
|
||||
const m = await insertManufacturer(testDb, data.brand);
|
||||
const [row] = await testDb.insert(globalItems).values({
|
||||
manufacturerId: m.id,
|
||||
model: data.model,
|
||||
weightGrams: data.weightGrams ?? null,
|
||||
priceCents: data.priceCents ?? null,
|
||||
imageUrl: data.imageUrl ?? null,
|
||||
}).returning();
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user