mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 23:16:46 +00:00
26df56d76c
The three AI addons share one tile in the integration column; a dialog holds the connection, the assistant's limits and AI parsing, which now reads with the assistant's connection unless an install keeps its own. Existing parsing configs stay where they are and keep winning. The chat sees the map on screen, offers next questions under an answer, shows its live step in the window head, previews waiting changes inside the day list, checks whether a day still works, folds a multi-day plan into a week grid, keeps per-trip notes and can estimate costs. An empty or cut-off answer gets one push instead of ending silently, and the assistant's own step and size limits are raised.
128 lines
5.1 KiB
TypeScript
128 lines
5.1 KiB
TypeScript
// FE-MOB-SETINT-001 onwards
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { render, screen } from '../../../helpers/render';
|
|
import { resetAllStores, seedStore } from '../../../helpers/store';
|
|
import { useAddonStore } from '../../../../src/store/addonStore';
|
|
import { useAuthStore } from '../../../../src/store/authStore';
|
|
import { useSettingsStore } from '../../../../src/store/settingsStore';
|
|
import { buildSettings } from '../../../helpers/factories';
|
|
import MSettingsIntegrations from '../../../../src/mobile/screens/settings/MSettingsIntegrations';
|
|
|
|
// The four sections are covered by their own suites — stub them so this file
|
|
// only exercises the addon gating and the initial loadAddons call.
|
|
vi.mock('../../../../src/mobile/screens/settings/MPhotoProvidersSection', () => ({
|
|
default: () => <div data-testid="photo-providers" />,
|
|
}));
|
|
vi.mock('../../../../src/mobile/screens/settings/MAirTrailConnectionSection', () => ({
|
|
default: () => <div data-testid="airtrail" />,
|
|
}));
|
|
vi.mock('../../../../src/mobile/screens/settings/MLlmConnectionSection', () => ({
|
|
default: () => <div data-testid="llm" />,
|
|
}));
|
|
vi.mock('../../../../src/mobile/screens/settings/MAiConnectionSection', () => ({
|
|
default: ({ assistant, parsing }: { assistant: boolean; parsing: boolean }) => (
|
|
<div data-testid="ai" data-assistant={String(assistant)} data-parsing={String(parsing)} />
|
|
),
|
|
}));
|
|
vi.mock('../../../../src/mobile/screens/settings/MSettingsMcp', () => ({
|
|
default: () => <div data-testid="mcp" />,
|
|
}));
|
|
|
|
function seedAddons(ids: string[], loadAddons = vi.fn().mockResolvedValue(undefined)) {
|
|
seedStore(useAddonStore, {
|
|
addons: ids.map((id) => ({ id, name: id, type: 'integration', icon: '', enabled: true })),
|
|
loaded: true,
|
|
loadAddons,
|
|
});
|
|
return loadAddons;
|
|
}
|
|
|
|
describe('MSettingsIntegrations', () => {
|
|
beforeEach(() => {
|
|
resetAllStores();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-001: only the photo providers render when no integration addon is on', () => {
|
|
seedAddons([]);
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.getByTestId('photo-providers')).toBeInTheDocument();
|
|
expect(screen.queryByTestId('airtrail')).not.toBeInTheDocument();
|
|
expect(screen.queryByTestId('llm')).not.toBeInTheDocument();
|
|
expect(screen.queryByTestId('mcp')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-002: the airtrail addon reveals the AirTrail connection section', () => {
|
|
seedAddons(['airtrail']);
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.getByTestId('airtrail')).toBeInTheDocument();
|
|
expect(screen.queryByTestId('llm')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-003: the llm_parsing addon reveals the AI connection, which parsing reads with', () => {
|
|
seedAddons(['llm_parsing']);
|
|
render(<MSettingsIntegrations />);
|
|
|
|
const ai = screen.getByTestId('ai');
|
|
expect(ai).toHaveAttribute('data-parsing', 'true');
|
|
expect(ai).toHaveAttribute('data-assistant', 'false');
|
|
// No personal parsing model saved: its old form is not offered.
|
|
expect(screen.queryByTestId('llm')).not.toBeInTheDocument();
|
|
expect(screen.queryByTestId('airtrail')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-008: a personal parsing model saved earlier keeps its form', () => {
|
|
seedAddons(['llm_parsing']);
|
|
seedStore(useSettingsStore, { settings: buildSettings({ llm_provider: 'openai', llm_model: 'gpt-4o' }) });
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.getByTestId('llm')).toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-004: the mcp addon reveals the MCP configuration', () => {
|
|
seedAddons(['mcp']);
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.getByTestId('mcp')).toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-005: all three sections render together when every addon is on', () => {
|
|
seedAddons(['airtrail', 'llm_parsing', 'mcp']);
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.getByTestId('airtrail')).toBeInTheDocument();
|
|
expect(screen.getByTestId('ai')).toBeInTheDocument();
|
|
expect(screen.getByTestId('mcp')).toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-006: a disabled addon row does not unlock its section', () => {
|
|
seedStore(useAddonStore, {
|
|
addons: [{ id: 'mcp', name: 'MCP', type: 'integration', icon: '', enabled: false }],
|
|
loaded: true,
|
|
loadAddons: vi.fn().mockResolvedValue(undefined),
|
|
});
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.queryByTestId('mcp')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-SETINT-007: the addon list is refreshed once on mount', () => {
|
|
const loadAddons = seedAddons([]);
|
|
const { rerender } = render(<MSettingsIntegrations />);
|
|
rerender(<MSettingsIntegrations />);
|
|
|
|
expect(loadAddons).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('FE-MOB-SETINT-008: a managed install hides the photo providers and AirTrail, as the desktop does', () => {
|
|
seedAddons(['airtrail', 'mcp']);
|
|
seedStore(useAuthStore, { managed: true });
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.queryByTestId('photo-providers')).not.toBeInTheDocument();
|
|
expect(screen.queryByTestId('airtrail')).not.toBeInTheDocument();
|
|
expect(screen.getByTestId('mcp')).toBeInTheDocument();
|
|
});
|
|
});
|