- Added VisionApiClient class to interact with the vision system API. - Defined interfaces for system status, machine status, camera status, recordings, and storage stats. - Implemented methods for health checks, system status retrieval, camera control, and storage management. - Introduced utility functions for formatting bytes, durations, and uptime. test: Create manual verification script for Vision API functionality - Added a test script to verify utility functions and API endpoints. - Included tests for health check, system status, cameras, machines, and storage stats. feat: Create experiment repetitions system migration - Added experiment_repetitions table to manage experiment repetitions with scheduling. - Implemented triggers and functions for validation and timestamp management. - Established row-level security policies for user access control. feat: Introduce phase-specific draft management system migration - Created experiment_phase_drafts and experiment_phase_data tables for managing phase-specific drafts and measurements. - Added pecan_diameter_measurements table for individual diameter measurements. - Implemented row-level security policies for user access control. fix: Adjust draft constraints to allow multiple drafts while preventing multiple submitted drafts - Modified constraints on experiment_phase_drafts to allow multiple drafts in 'draft' or 'withdrawn' status. - Ensured only one 'submitted' draft per user per phase per repetition.
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
// Simple test file to verify vision API client functionality
|
|
// This is not a formal test suite, just a manual verification script
|
|
|
|
import { visionApi, formatBytes, formatDuration, formatUptime } from '../lib/visionApi'
|
|
|
|
// Test utility functions
|
|
console.log('Testing utility functions:')
|
|
console.log('formatBytes(1024):', formatBytes(1024)) // Should be "1 KB"
|
|
console.log('formatBytes(1048576):', formatBytes(1048576)) // Should be "1 MB"
|
|
console.log('formatDuration(65):', formatDuration(65)) // Should be "1m 5s"
|
|
console.log('formatUptime(3661):', formatUptime(3661)) // Should be "1h 1m"
|
|
|
|
// Test API endpoints (these will fail if vision system is not running)
|
|
export async function testVisionApi() {
|
|
try {
|
|
console.log('Testing vision API endpoints...')
|
|
|
|
// Test health endpoint
|
|
const health = await visionApi.getHealth()
|
|
console.log('Health check:', health)
|
|
|
|
// Test system status
|
|
const status = await visionApi.getSystemStatus()
|
|
console.log('System status:', status)
|
|
|
|
// Test cameras
|
|
const cameras = await visionApi.getCameras()
|
|
console.log('Cameras:', cameras)
|
|
|
|
// Test machines
|
|
const machines = await visionApi.getMachines()
|
|
console.log('Machines:', machines)
|
|
|
|
// Test storage stats
|
|
const storage = await visionApi.getStorageStats()
|
|
console.log('Storage stats:', storage)
|
|
|
|
// Test recordings
|
|
const recordings = await visionApi.getRecordings()
|
|
console.log('Recordings:', recordings)
|
|
|
|
console.log('All API tests passed!')
|
|
return true
|
|
} catch (error) {
|
|
console.error('API test failed:', error)
|
|
return false
|
|
}
|
|
}
|
|
|
|
// Uncomment the line below to run the test when this file is imported
|
|
// testVisionApi()
|