fix(assistant): taking a proposal needs place rights, and a card's choices wait while a change runs

Plan this checks place_edit like the tour routes, the include choices of a
run or group stay disabled while the chat applies a change, and a follow-up
can say when it applies, so Confirm the pending bookings shows only when the
card holds a pending booking of this trip.
This commit is contained in:
Maurice
2026-10-22 22:46:35 +00:00
parent cf8cf9058d
commit 3eded5f5be
13 changed files with 195 additions and 39 deletions
@@ -1,9 +1,10 @@
/**
* FE-AI-FOLLOW-001 to FE-AI-FOLLOW-002
* FE-AI-FOLLOW-001 to FE-AI-FOLLOW-003
*
* The follow-ups a card offers under an answer that ends on it: the ones that
* ask for a change only for someone who may make it, and the answer's own
* when none is left for a reader.
* ask for a change only for someone who may make it, the answer's own when
* none is left for a reader, and the ones with a condition only when a card of
* the answer meets it.
*/
import type { AssistantMessage, TrekCard } from '@trek/shared';
import { afterEach, describe, expect, it } from 'vitest';
@@ -41,4 +42,21 @@ describe('card follow-ups', () => {
CARD_LOOKS.vacay.followUps = [{ id: 'planDays', labelKey: 'assistant.followUp.next', edits: true }];
expect(followUpsFor(answer, false).map((f) => f.id)).toEqual(['more', 'next']);
});
it('FE-AI-FOLLOW-003: a follow-up with a condition is offered only when a card of the answer meets it', () => {
const asked: TrekCard[] = [];
CARD_LOOKS.vacay.followUps = [
{ id: 'planDays', labelKey: 'assistant.followUp.next', when: () => false },
{
id: 'holidays',
labelKey: 'assistant.followUp.more',
when: (card) => {
asked.push(card);
return true;
},
},
];
expect(followUpsFor(answer, true).map((f) => f.id)).toEqual(['holidays']);
expect(asked).toEqual([{ kind: 'vacay' }]);
});
});