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:
Maurice
2026-11-13 09:33:27 +01:00
parent 72e8b1f8d9
commit cae04e83dd
44 changed files with 289 additions and 13 deletions
@@ -1,5 +1,5 @@
/**
* ASTCOL-020 to ASTCOL-035: the change cards of the collections' writes, as
* ASTCOL-020 to ASTCOL-035 and ASTCOL-037: the change cards of the collections' writes, as
* describeToolCall writes them (the card through the guarded registry, so it
* passed the union), and the lookups they read first.
*/
@@ -104,6 +104,21 @@ describe('collection change cards', () => {
expect(placesOf(removed.card).places[0]?.delta?.removed).toBe(true);
});
it('ASTCOL-037: the provider ids, contact and price fields an update now takes are named once each (#2646)', () => {
const items = itemsValue([savedPlace()]);
const args = {
placeId: 34,
website: 'septime-charonne.fr',
phone: null,
price: 45,
currency: 'EUR',
google_place_id: 'ChIJseptime',
osm_id: 'node/1',
};
const card = placesOf(preview('update_collection_place', args, { items }).card);
expect(card.places[0]?.delta?.fields).toEqual(['website', 'phone', 'price', 'mapEntry']);
});
it('ASTCOL-023: a change of a saved place names its fields, its labels as its own list allows them and the list it moves to', () => {
const items = itemsValue([savedPlace()]);
// In its own list: the labels asked for replace the ones it carries.
@@ -1,9 +1,9 @@
/**
* The link helpers of the collections domain, which read and write the JSON
* TEXT column a list or a saved place keeps its links in.
* COLLECTIONS-HELPERS-001 to 003.
* The pure helpers of the collections domain: the link helpers, which read and
* write the JSON TEXT column a list or a saved place keeps its links in, and the
* listing fields an update writes. COLLECTIONS-HELPERS-001 to 005.
*/
import { parseLinks, serializeLinks } from '../../../src/nest/collections/collections.helpers';
import { listingWriteOf, parseLinks, serializeLinks } from '../../../src/nest/collections/collections.helpers';
import { describe, expect, it } from 'vitest';
@@ -29,3 +29,32 @@ describe('serializeLinks', () => {
expect(serializeLinks(undefined)).toBeNull();
});
});
describe('listingWriteOf', () => {
it('COLLECTIONS-HELPERS-004: writes each provider id, contact and price field the update names, null clearing it', () => {
expect(
listingWriteOf({
google_place_id: 'ChIJseptime',
google_ftid: null,
osm_id: 'node/42',
website: 'https://septime-charonne.fr',
phone: null,
price: 0,
currency: 'EUR',
}),
).toEqual({
google_place_id: 'ChIJseptime',
google_ftid: null,
osm_id: 'node/42',
website: 'https://septime-charonne.fr',
phone: null,
price: 0,
currency: 'EUR',
});
});
it('COLLECTIONS-HELPERS-005: leaves out what the update does not name, so the stored value stays', () => {
expect(listingWriteOf({ name: 'Septime', notes: 'Book ahead' })).toEqual({});
expect(listingWriteOf({ website: undefined, phone: '+33 1' })).toEqual({ phone: '+33 1' });
});
});