mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
feat(collections): edit a saved place's provider ids, website, phone and price (#2646)
The update contract takes google_place_id, google_ftid, osm_id, website, phone, price and currency like saving does, website with the same normalisation and refusal. REST and update_collection_place share it, so an agent can correct a place instead of re-saving it and losing its labels, ratings, position and id. The assistant's change card names the new fields.
This commit is contained in:
@@ -565,6 +565,51 @@ describe('Tool: update_collection_place / set_collection_place_status / rate_col
|
||||
});
|
||||
expect((await findRow(orm, CollectionPlaces, { id: pid }))?.collection_id).toBe(shared);
|
||||
});
|
||||
|
||||
// #2646: the fields saving takes, through the same contract and checks as REST.
|
||||
it('update_collection_place sets and clears provider ids, website, phone and price, and refuses a script link', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const col = await seedCollection(user.id, 'Listings');
|
||||
const pid = await seedPlace(col, user.id, 'Septime');
|
||||
const update = (h: McpHarness, args: Record<string, unknown>) =>
|
||||
h.client.callTool({ name: 'update_collection_place', arguments: { placeId: pid, ...args } });
|
||||
await withHarness(user.id, async (h) => {
|
||||
const set = parseToolResult(
|
||||
await update(h, {
|
||||
google_place_id: 'ChIJseptime',
|
||||
osm_id: 'node/42',
|
||||
website: 'septime-charonne.fr',
|
||||
phone: '+33 1 43 67 38 29',
|
||||
price: 55,
|
||||
currency: 'EUR',
|
||||
}),
|
||||
) as { place: Record<string, unknown> };
|
||||
expect(set.place).toMatchObject({
|
||||
name: 'Septime',
|
||||
google_place_id: 'ChIJseptime',
|
||||
osm_id: 'node/42',
|
||||
website: 'https://septime-charonne.fr',
|
||||
phone: '+33 1 43 67 38 29',
|
||||
price: 55,
|
||||
currency: 'EUR',
|
||||
});
|
||||
|
||||
const refused = await update(h, { website: 'javascript:alert(1)' });
|
||||
expect(refused.isError).toBe(true);
|
||||
expect((refused.content as { text: string }[])[0].text).toContain('Invalid arguments');
|
||||
|
||||
const cleared = parseToolResult(await update(h, { website: null, phone: null, price: null })) as {
|
||||
place: Record<string, unknown>;
|
||||
};
|
||||
expect(cleared.place).toMatchObject({
|
||||
website: null,
|
||||
phone: null,
|
||||
price: null,
|
||||
currency: 'EUR',
|
||||
google_place_id: 'ChIJseptime',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user