Files
MealQuest/web/src/test/ApiProviders.tsx
T
dev_agentandClaude Opus 5.5 04f12f52b9
CI / ci (push) Successful in 1m55s
CI / ci (pull_request) Successful in 1m56s
Show every settings home status line (mock 1p review fixes)
The Regular dinners, Google Calendar and Notifications & Google Chat rows
now show status lines and read them from the server:

- Regular dinners: "N on rotation" from GET /api/v1/dinners?status=regular
  (Feature 12). Until that endpoint exists the server answers 404 and the
  row says "Rotation count unavailable"; no count is invented.
- Google Calendar: "Connected · <calendar name>" from
  GET /api/v1/settings/calendar (Feature 16). Until then a 404 shows the
  truthful "Not connected".
- Notifications & Google Chat: "Push on · <Google Chat space>" from
  GET /api/v1/settings/notifications. Until then a 404 shows
  "Push off · Google Chat not connected".

Only a 404 not_found counts as a missing endpoint; any other failure or a
malformed response shows in the error banner.

The AI assistant row names the model as the handoff does ("Anthropic ·
Claude Sonnet"), shows an unknown model by its id, and says "No model
chosen" for the seeded empty model instead of a trailing separator.

Maestro task: 97b50e29-b8a7-4e99-918d-99fa1b239313

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 09:35:51 -04:00

31 lines
1.5 KiB
TypeScript

import { QueryClientProvider } from '@tanstack/react-query'
import { useState, type ReactNode } from 'react'
import { ApiProvider, createApiClient, createQueryClient, createVerifiedSession } from '../api/index.ts'
import { createNetworkStatus } from '../pwa/networkStatus.ts'
import { errorResponse, fakeLocation, jsonResponse } from './fetchStub.ts'
// SETTINGS_API answers the settings home's requests, for stubFetchByPath, as
// today's server does: the dinners, Google Calendar and notifications status
// endpoints do not exist yet.
export const SETTINGS_API = {
'/api/v1/dinners?status=regular': () => errorResponse(404, 'not_found'),
'/api/v1/settings/calendar': () => errorResponse(404, 'not_found'),
'/api/v1/settings/notifications': () => errorResponse(404, 'not_found'),
'/api/v1/settings/household': () => jsonResponse(200, { timezone: 'America/New_York', dinner_time: '17:30' }),
'/api/v1/settings/ai': () => jsonResponse(200, { provider: 'anthropic', model: 'claude-sonnet-4-5' }),
}
// ApiProviders gives the pages under test what App gives them: an API client
// on https://mealquest.test and a fresh query client.
export function ApiProviders({ children }: { children: ReactNode }) {
const [api] = useState(() =>
createApiClient(fakeLocation(), createNetworkStatus(window), createVerifiedSession(localStorage)),
)
const [queryClient] = useState(createQueryClient)
return (
<ApiProvider client={api}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</ApiProvider>
)
}