test(18-02): add failing tests for global item service and seed

- 10 test cases covering search, owner count, link/unlink, seed idempotency
- Added globalItems/itemGlobalLinks tables to SQLite schema
- Added Zod schemas and types for global items
- Created 18-item bikepacking gear seed data JSON
This commit is contained in:
2026-04-05 13:05:28 +02:00
parent f7c9f3dc94
commit 3a6876f7e8
8 changed files with 1393 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
[
{
"brand": "Revelate Designs",
"model": "Terrapin System",
"category": "bags",
"weightGrams": 529,
"priceCents": 18500,
"description": "Waterproof saddle bag with 14L capacity, roll-top closure, and integrated Revelate seat bag mount."
},
{
"brand": "Apidura",
"model": "Expedition Handlebar Pack",
"category": "bags",
"weightGrams": 300,
"priceCents": 16000,
"description": "14L waterproof handlebar roll bag with internal dry bag and accessory pocket."
},
{
"brand": "Ortlieb",
"model": "Frame-Pack Toptube",
"category": "bags",
"weightGrams": 180,
"priceCents": 7500,
"description": "4L waterproof top-tube bag with magnetic closure and reflective details."
},
{
"brand": "Revelate Designs",
"model": "Tangle Frame Bag",
"category": "bags",
"weightGrams": 170,
"priceCents": 13500,
"description": "Full-frame bag with water-resistant construction and multiple internal pockets."
},
{
"brand": "Big Agnes",
"model": "Copper Spur HV UL1",
"category": "shelters",
"weightGrams": 879,
"priceCents": 42000,
"description": "Ultralight 1-person freestanding tent with high-volume hub design and DAC Featherlite poles."
},
{
"brand": "Tarptent",
"model": "Protrail Li",
"category": "shelters",
"weightGrams": 454,
"priceCents": 35000,
"description": "Ultralight single-wall trekking pole shelter in Dyneema composite fabric."
},
{
"brand": "Outdoor Research",
"model": "Helium Bivy",
"category": "shelters",
"weightGrams": 510,
"priceCents": 24900,
"description": "Waterproof breathable bivy sack with single-hoop pole and full-zip entry."
},
{
"brand": "Sea to Summit",
"model": "Spark SP1",
"category": "sleep-systems",
"weightGrams": 375,
"priceCents": 28000,
"description": "Ultralight 850+ fill down sleeping bag rated to 40F/4C with Ultra-Dry Down."
},
{
"brand": "Nemo",
"model": "Tensor Ultralight Insulated Regular",
"category": "sleep-systems",
"weightGrams": 425,
"priceCents": 18000,
"description": "3-inch thick insulated sleeping pad with R-value 4.2 and Spaceframe baffles."
},
{
"brand": "Therm-a-Rest",
"model": "NeoAir XLite NXT",
"category": "sleep-systems",
"weightGrams": 354,
"priceCents": 22000,
"description": "Ultralight insulated air pad with R-value 4.5, Triangular Core Matrix, and WingLock valve."
},
{
"brand": "MSR",
"model": "PocketRocket 2",
"category": "cooking",
"weightGrams": 73,
"priceCents": 5500,
"description": "Ultralight canister stove with adjustable flame control, boils 1L in 3.5 minutes."
},
{
"brand": "Toaks",
"model": "Titanium 750ml Pot",
"category": "cooking",
"weightGrams": 103,
"priceCents": 3300,
"description": "Ultralight titanium pot with lid and foldable handles, 750ml capacity."
},
{
"brand": "Katadyn",
"model": "BeFree 1.0L",
"category": "hydration",
"weightGrams": 59,
"priceCents": 4500,
"description": "Ultralight hollow fiber water filter with 0.1 micron filtration and 1L soft flask."
},
{
"brand": "HydraPak",
"model": "Seeker 2L",
"category": "hydration",
"weightGrams": 73,
"priceCents": 1800,
"description": "Collapsible 2L water storage with wide mouth and compatible with Katadyn BeFree filter."
},
{
"brand": "Nitecore",
"model": "NU25 UL",
"category": "lighting",
"weightGrams": 28,
"priceCents": 3600,
"description": "Ultralight USB-C rechargeable headlamp with 400 lumens max and red light mode."
},
{
"brand": "Exposure Lights",
"model": "Revo Dynamo",
"category": "lighting",
"weightGrams": 130,
"priceCents": 22000,
"description": "Dynamo-powered front light with 800 lumens, built-in standlight, and USB charging output."
},
{
"brand": "Surly",
"model": "24-Pack Rack",
"category": "racks",
"weightGrams": 750,
"priceCents": 10000,
"description": "Front rack for bikepacking with 24-pack platform, fits most forks with mid-blade eyelets."
},
{
"brand": "Salsa",
"model": "Anything Cage HD",
"category": "accessories",
"weightGrams": 80,
"priceCents": 2500,
"description": "Heavy-duty bottle cage for oversized loads like dry bags and fuel canisters."
}
]

View File

@@ -127,6 +127,31 @@ export const apiKeys = sqliteTable("api_keys", {
.$defaultFn(() => new Date()),
});
export const globalItems = sqliteTable("global_items", {
id: integer("id").primaryKey({ autoIncrement: true }),
brand: text("brand").notNull(),
model: text("model").notNull(),
category: text("category"),
weightGrams: real("weight_grams"),
priceCents: integer("price_cents"),
imageUrl: text("image_url"),
description: text("description"),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.$defaultFn(() => new Date()),
});
export const itemGlobalLinks = sqliteTable("item_global_links", {
id: integer("id").primaryKey({ autoIncrement: true }),
itemId: integer("item_id")
.notNull()
.references(() => items.id, { onDelete: "cascade" })
.unique(),
globalItemId: integer("global_item_id")
.notNull()
.references(() => globalItems.id, { onDelete: "cascade" }),
});
export const oauthClients = sqliteTable("oauth_clients", {
id: integer("id").primaryKey({ autoIncrement: true }),
clientId: text("client_id").notNull().unique(),

View File

@@ -89,3 +89,12 @@ export const classificationSchema = z.enum(["base", "worn", "consumable"]);
export const updateClassificationSchema = z.object({
classification: classificationSchema,
});
// Global item schemas
export const searchGlobalItemsSchema = z.object({
q: z.string().optional(),
});
export const linkItemSchema = z.object({
globalItemId: z.number().int().positive(),
});

View File

@@ -1,6 +1,8 @@
import type { z } from "zod";
import type {
categories,
globalItems,
itemGlobalLinks,
items,
setupItems,
setups,
@@ -13,8 +15,10 @@ import type {
createItemSchema,
createSetupSchema,
createThreadSchema,
linkItemSchema,
reorderCandidatesSchema,
resolveThreadSchema,
searchGlobalItemsSchema,
syncSetupItemsSchema,
updateCandidateSchema,
updateCategorySchema,
@@ -49,3 +53,7 @@ export type Thread = typeof threads.$inferSelect;
export type ThreadCandidate = typeof threadCandidates.$inferSelect;
export type Setup = typeof setups.$inferSelect;
export type SetupItem = typeof setupItems.$inferSelect;
export type GlobalItem = typeof globalItems.$inferSelect;
export type ItemGlobalLink = typeof itemGlobalLinks.$inferSelect;
export type SearchGlobalItems = z.infer<typeof searchGlobalItemsSchema>;
export type LinkItem = z.infer<typeof linkItemSchema>;