Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/service-calendar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ const EVENT_ROW = {

describe('createEvent', () => {
it('writes the auth user id into created_by and the member id into assignee_id', async () => {
const { db, calls } = makeDb(() => ({ data: EVENT_ROW, error: null }));
const { db, calls } = makeDb((call) => ({
data: call.table === 'family_members' ? { id: 'member-2', family_id: 'fam-1' } : EVENT_ROW,
error: null,
}));
const res = await createEvent(scopeWith(db), {
title: ' Dentist ',
startsAt: '2026-09-07T14:00:00Z',
Expand Down Expand Up @@ -141,7 +144,7 @@ describe('createEvent', () => {
});

it('returns the existing row instead of a duplicate when an idempotency key repeats', async () => {
const { db, calls } = makeDb((call) => (call.kind === 'select' ? { data: EVENT_ROW, error: null } : { data: EVENT_ROW, error: null }));
const { db, calls } = makeDb(() => ({ data: { ...EVENT_ROW, idempotency_key: 'retry-1' }, error: null }));
const res = await createEvent(scopeWith(db, { idempotencyKey: 'retry-1' }), {
title: 'Dentist', startsAt: '2026-09-07T14:00:00Z',
});
Expand Down
1 change: 1 addition & 0 deletions tests/service-moving.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ describe('addTask', () => {
it('dates a relative task from move day and never adds the same key twice', async () => {
const db = makeDb();
seedMove(db);
db.seed('family_members', [{ id: MEMBER, family_id: FAMILY }]);
const first = await addTask(scopeWith(db), { title: 'Change the address with Netflix', category: 'address', offsetDays: -14, templateKey: 'address-sub-1', assigneeId: MEMBER });
expect(first.ok && first.data.created).toBe(true);
expect(first.ok && first.data.task).toMatchObject({ family_id: FAMILY, move_id: MOVE, due_date: '2026-09-19', date_mode: 'relative', offset_days: -14, category: 'address', assignee_id: MEMBER, template_key: 'address-sub-1' });
Expand Down
6 changes: 5 additions & 1 deletion tests/tool-meals-memory-messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('groceries.addFromMealPlan', () => {
case 'meal_plans':
return { data: [{ meal_id: 'meal-1', plan_date: '2026-09-08' }], error: null };
case 'meals':
return { data: [{ id: 'meal-1', name: 'Tacos', ingredients: [{ name: 'tortillas', qty: '8' }, { name: 'onion', qty: '1' }] }], error: null };
return { data: [{ id: 'meal-1', family_id: 'fam-1', name: 'Tacos', ingredients: [{ name: 'tortillas', qty: '8' }, { name: 'onion', qty: '1' }] }], error: null };
case 'pantry_items':
return { data: [{ name: 'Onions', quantity: 3 }], error: null };
// A household with nothing recorded answers with NO ROWS. The `default`
Expand Down Expand Up @@ -235,6 +235,10 @@ describe('groceries.addFromMealPlan', () => {
meals: [{ id: 'meal-1', name: 'Tacos', date: '2026-09-08' }],
});
expect(calls[0].filters).toMatchObject({ family_id: 'fam-1', 'gte:plan_date': '2026-09-07', 'lte:plan_date': '2026-09-13' });
// Both the plan expansion and pre-insert ownership check read this family's meal.
const mealReads = calls.filter((call) => call.table === 'meals');
expect(mealReads).toHaveLength(2);
for (const read of mealReads) expect(read.filters).toMatchObject({ family_id: 'fam-1', id: ['meal-1'] });
expect(calls.find((c) => c.table === 'grocery_items' && c.kind === 'insert')?.payload).toMatchObject([{ source_meal_id: 'meal-1' }]);
expect(tool.summarize({}, res.data)).toBe('Added 1 item to the shopping list for 1 planned meal (1 in the pantry)');
});
Expand Down
Loading