mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
d6850756c6
On a managed install the phone's Integrations section still showed the
Immich and Synology Photos cards and, with the addon on, the AirTrail
connection form. Each asks for the address of a server the reader runs at
home, which a managed install cannot reach, so saving or testing could only
time out. The desktop has hidden both since the managed mode landed
(#1946, 3a0604b3f), whose message says these "connect to a server the
reader runs at home, and there is no route from here to one".
That change gated the phone's AI section but missed these two, and the
user facing addon list still carries a photo provider that was enabled
before the switch, so the cards did render. The phone now applies the same
!managed gate as the desktop IntegrationsTab.
Regression test FE-MOB-SETINT-008 (MSettingsIntegrations.test.tsx) was red
on the old code: "expected document not to contain element, found <div
data-testid="photo-providers"> instead".
No existing assertion changed.
109 lines
4.2 KiB
TypeScript
109 lines
4.2 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 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/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 section', () => {
|
|
seedAddons(['llm_parsing']);
|
|
render(<MSettingsIntegrations />);
|
|
|
|
expect(screen.getByTestId('llm')).toBeInTheDocument();
|
|
expect(screen.queryByTestId('airtrail')).not.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('llm')).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();
|
|
});
|
|
});
|