mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
feat(assistant): a card framework every addon package plugs into
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { AssistantApplied } from '@trek/shared';
|
||||
|
||||
import { showOnMapSearch, showOnMapTarget } from './assistantShowOnMap';
|
||||
import { plannerSearchOf, showOnMapTarget } from './assistantShowOnMap';
|
||||
|
||||
const applied = (entity: AssistantApplied['entity'], ids: number[], dayId: number | null): AssistantApplied => ({
|
||||
toolCallId: 'c1',
|
||||
@@ -10,19 +10,34 @@ const applied = (entity: AssistantApplied['entity'], ids: number[], dayId: numbe
|
||||
undoUntil: null,
|
||||
});
|
||||
|
||||
/** The planner's query for what "Show on map" points an applied change at. */
|
||||
const searchOf = (change: AssistantApplied) => {
|
||||
const target = showOnMapTarget(change);
|
||||
return target ? plannerSearchOf({ kind: 'map', ...target }) : null;
|
||||
};
|
||||
|
||||
describe('assistantShowOnMap', () => {
|
||||
it('FE-ASSIST-SHOW-001: a place goes to the place, even when it was put on a day', () => {
|
||||
expect(showOnMapTarget(applied('place', [7], 3))).toEqual({ placeId: 7, dayId: null });
|
||||
expect(showOnMapSearch(applied('place', [7], 3))).toBe('?place=7');
|
||||
expect(searchOf(applied('place', [7], 3))).toBe('?place=7');
|
||||
});
|
||||
|
||||
it('FE-ASSIST-SHOW-002: a stop or a note goes to its day', () => {
|
||||
expect(showOnMapSearch(applied('assignment', [41], 3))).toBe('?day=3');
|
||||
expect(showOnMapSearch(applied('day_note', [9], 4))).toBe('?day=4');
|
||||
it('FE-ASSIST-SHOW-002: a stop, a note or a booking goes to its day', () => {
|
||||
expect(searchOf(applied('assignment', [41], 3))).toBe('?day=3');
|
||||
expect(searchOf(applied('day_note', [9], 4))).toBe('?day=4');
|
||||
expect(searchOf(applied('reservation', [5], 2))).toBe('?day=2');
|
||||
});
|
||||
|
||||
it('FE-ASSIST-SHOW-003: a change with nowhere to point at opens the planner as it is', () => {
|
||||
expect(showOnMapTarget(applied('packing', [2], null))).toEqual({ placeId: null, dayId: null });
|
||||
expect(showOnMapSearch(applied('place', [], null))).toBe('');
|
||||
it('FE-ASSIST-SHOW-003: no target where nothing shows on the map; a place without a spot opens the planner', () => {
|
||||
expect(showOnMapTarget(applied('packing', [2], null))).toBeNull();
|
||||
expect(showOnMapTarget(applied('tour', [2], 3))).toBeNull();
|
||||
expect(showOnMapTarget(applied('memory', [], null))).toBeNull();
|
||||
expect(searchOf(applied('place', [], null))).toBe('');
|
||||
});
|
||||
|
||||
it('FE-ASSIST-SHOW-004: a tab of the trip goes as ?tab= with what the tab reads beside it', () => {
|
||||
const expense = plannerSearchOf({ kind: 'tab', tab: 'finanzplan', params: { expense: '7' } });
|
||||
expect(expense).toBe('?tab=finanzplan&expense=7');
|
||||
expect(plannerSearchOf({ kind: 'tab', tab: 'listen', sub: 'todo' })).toBe('?tab=listen');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user