test(assistant): shared card tests, wiki rows and ratchets after the card packages

This commit is contained in:
Maurice
2026-10-22 15:50:57 +02:00
parent 0f5ecb70a2
commit fd01a090fc
16 changed files with 329 additions and 85 deletions
@@ -3,7 +3,8 @@
*
* The links the chat opens the planner with while it is on screen: another
* tab of the trip switches there and leaves the URL, and the parts' own links
* (tours, bookings, road trip) take nothing yet.
* (tours, bookings, road trip) are each handed the planner, the workspace and
* the query (each part's own test covers what it does with them).
*/
import { renderHook } from '@testing-library/react';
import type { ReactNode } from 'react';
@@ -12,6 +13,11 @@ import { describe, expect, it, vi } from 'vitest';
import { useAssistantEntityLinks } from './useAssistantEntityLinks';
const parts = vi.hoisted(() => ({ tour: vi.fn(), booking: vi.fn(), roadtrip: vi.fn() }));
vi.mock('./deepLinks/useTourDeepLink', () => ({ useTourDeepLink: parts.tour }));
vi.mock('./deepLinks/useBookingDeepLink', () => ({ useBookingDeepLink: parts.booking }));
vi.mock('./deepLinks/useRoadtripDeepLink', () => ({ useRoadtripDeepLink: parts.roadtrip }));
type Options = Parameters<typeof useAssistantEntityLinks>[0];
function setup(path: string) {
@@ -37,9 +43,14 @@ describe('useAssistantEntityLinks', () => {
expect(hook.result.current.search).toBe('?expense=7');
});
it("FE-PLANNER-ENTITYLINK-002: the parts' own links take nothing yet, and nothing switches without a tab", () => {
it("FE-PLANNER-ENTITYLINK-002: each part's own link gets the planner, the workspace and the query; nothing switches without a tab", () => {
const { planner, hook } = setup('/trips/5?tour=12');
expect(planner.handleTabChange).not.toHaveBeenCalled();
expect(hook.result.current.search).toBe('?tour=12');
for (const part of [parts.tour, parts.booking, parts.roadtrip]) {
const links = part.mock.lastCall?.[0] as { planner: unknown; searchParams: URLSearchParams };
expect(links.planner).toBe(planner);
expect(links.searchParams.get('tour')).toBe('12');
}
});
});