import { describe, it, expect, beforeEach, vi } from 'vitest' import { render, screen } from '@testing-library/react' import { MemoryRouter } from 'react-router-dom' import { EnvSetup } from './EnvSetup' import { useSession } from '@/store/session' // The chat, starters, runtime and channels all moved to the cockpit rail // (CockpitRail's "agent" variant) — the page itself is now editorial copy + a // proceed gate. Stub the mode call the rail would otherwise make elsewhere. vi.mock('@/lib/api', async (orig) => ({ ...(await orig()), getMode: () => Promise.resolve({ localMode: false }), })) function renderPage() { return render( , ) } function connect(nodeUrl: string | null = 'http://192.168.1.7:8080') { useSession.getState().setDevice({ connected: true, port: 'board · crimson-otter', uptimeS: 0, nodeUrl }) } describe('EnvSetup — Meet your agent', () => { beforeEach(() => { useSession.getState().reset() sessionStorage.clear() }) it('renders the heading and the editorial intro', () => { renderPage() expect(screen.getByRole('heading', { name: /meet your agent/i })).toBeInTheDocument() expect(screen.getByTestId('agent-intro')).toBeInTheDocument() }) it('guides to connect the board first when not connected, and gates Proceed', () => { renderPage() expect(screen.getByText(/connect your board on the previous step/i)).toBeInTheDocument() expect(screen.getByRole('button', { name: /proceed/i })).toBeDisabled() }) it('enables Proceed once the board is connected', () => { connect() renderPage() expect(screen.getByRole('button', { name: /proceed/i })).toBeEnabled() // the connect nudge disappears once online expect(screen.queryByText(/connect your board on the previous step/i)).toBeNull() }) })