import React, { useState } from 'react'; import { supabase } from '../services/supabaseClient'; import { BeakerIcon } from './icons/BeakerIcon'; import { LoadingSpinner } from './LoadingSpinner'; import { CheckCircleIcon } from './icons/CheckCircleIcon'; import { XCircleIcon } from './icons/XCircleIcon'; type TestStatus = 'idle' | 'running' | 'pass' | 'fail'; interface TestResult { name: string; status: TestStatus; message: string; } const initialTests: TestResult[] = [ { name: 'Test Admin Login', status: 'idle', message: 'Verifies the seeded admin user can log in.' }, ]; export const DevTestRunner: React.FC = () => { const [testResults, setTestResults] = useState(initialTests); const [isRunning, setIsRunning] = useState(false); const runTests = async () => { setIsRunning(true); // Reset statuses to running setTestResults(prev => prev.map(t => ({ ...t, status: 'running' }))); // --- Test Case 1: Admin Login --- try { const { error } = await supabase.auth.signInWithPassword({ email: 'admin@example.com', password: 'password123', }); if (error) { throw new Error(error.message); } // IMPORTANT: Sign out immediately so the test doesn't affect the app's state await supabase.auth.signOut(); setTestResults(prev => prev.map(t => t.name === 'Test Admin Login' ? { ...t, status: 'pass', message: 'Successfully logged in and out.' } : t )); } catch (e: any) { setTestResults(prev => prev.map(t => t.name === 'Test Admin Login' ? { ...t, status: 'fail', message: `Failed: ${e.message}` } : t )); } setIsRunning(false); }; const getStatusIndicator = (status: TestStatus) => { switch (status) { case 'running': return
; case 'pass': return ; case 'fail': return ; case 'idle': return
; } }; if (!supabase) { return null; } return (

Development Test Runner

Run integration tests to verify your backend setup.

    {testResults.map(test => (
  • {getStatusIndicator(test.status)}

    {test.name}

    {test.message}

  • ))}
); };