Update CI workflows for Python linting by increasing flake8 line length limit to 150 characters for better readability; adjust service-adapters.yml and ci.yml accordingly; update progress documentation
Some checks failed
API Docs (Node.js Express) / test (16) (push) Failing after 5m42s
API Docs (Node.js Express) / test (20) (push) Has been cancelled
API Docs (Node.js Express) / build (push) Has been cancelled
API Docs (Node.js Express) / security (push) Has been cancelled
API Docs (Node.js Express) / test (18) (push) Has been cancelled
LabFusion CI/CD Pipeline / api-gateway (push) Has been cancelled
LabFusion CI/CD Pipeline / service-adapters (push) Has been cancelled
LabFusion CI/CD Pipeline / api-docs (push) Has been cancelled
LabFusion CI/CD Pipeline / frontend (push) Has been cancelled
LabFusion CI/CD Pipeline / integration-tests (push) Has been cancelled
LabFusion CI/CD Pipeline / security-scan (push) Has been cancelled
Docker Build and Push / build-and-push (push) Has been cancelled
Docker Build and Push / security-scan (push) Has been cancelled
Docker Build and Push / deploy-staging (push) Has been cancelled
Docker Build and Push / deploy-production (push) Has been cancelled
Frontend (React) / test (16) (push) Has been cancelled
Frontend (React) / test (18) (push) Has been cancelled
Frontend (React) / test (20) (push) Has been cancelled
Frontend (React) / build (push) Has been cancelled
Frontend (React) / lighthouse (push) Has been cancelled
Frontend (React) / security (push) Has been cancelled
Integration Tests / performance-tests (push) Has been cancelled
Service Adapters (Python FastAPI) / security (push) Has been cancelled
Service Adapters (Python FastAPI) / test (3.1) (push) Has been cancelled
Service Adapters (Python FastAPI) / test (3.11) (push) Has been cancelled
Service Adapters (Python FastAPI) / test (3.12) (push) Has been cancelled
Service Adapters (Python FastAPI) / test (3.9) (push) Has been cancelled
Service Adapters (Python FastAPI) / build (push) Has been cancelled
Integration Tests / integration-tests (push) Has been cancelled

This commit is contained in:
glenn schrooyen
2025-09-12 22:42:47 +02:00
parent 8d1755fd52
commit 8c87c84208
11 changed files with 392 additions and 32 deletions

58
frontend/src/App.test.js Normal file
View File

@@ -0,0 +1,58 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import App from './App'
// Mock the service status hook to avoid API calls during tests
jest.mock('./hooks/useServiceStatus', () => ({
useServiceStatus: () => ({
isOnline: true,
services: {
'api-gateway': { status: 'healthy', lastCheck: new Date().toISOString() },
'service-adapters': { status: 'healthy', lastCheck: new Date().toISOString() },
'api-docs': { status: 'healthy', lastCheck: new Date().toISOString() }
},
isLoading: false,
error: null
})
}))
// Mock the system data hook
jest.mock('./hooks/useServiceStatus', () => ({
useSystemData: () => ({
systemStats: {
cpuUsage: 45.2,
memoryUsage: 2.1,
diskUsage: 75.8
},
recentEvents: [
{
id: '1',
timestamp: new Date().toISOString(),
service: 'api-gateway',
event_type: 'health_check',
metadata: 'Service is healthy'
}
],
isLoading: false,
error: null
})
}))
describe('App Component', () => {
it('renders without crashing', () => {
render(<App />)
expect(screen.getByText(/LabFusion/i)).toBeInTheDocument()
})
it('renders the main dashboard', () => {
render(<App />)
// Check for common dashboard elements
expect(screen.getByText(/Dashboard/i)).toBeInTheDocument()
})
it('shows service status when online', () => {
render(<App />)
// Should show service status information
expect(screen.getByText(/Service Status/i)).toBeInTheDocument()
})
})

View File

@@ -0,0 +1,76 @@
import { formatError, formatServiceData, formatEventData } from './errorHandling'
describe('Error Handling Utils', () => {
describe('formatError', () => {
it('should format error objects correctly', () => {
const error = new Error('Test error message')
const formatted = formatError(error)
expect(formatted).toHaveProperty('message', 'Test error message')
expect(formatted).toHaveProperty('type', 'Error')
})
it('should handle string errors', () => {
const error = 'Simple string error'
const formatted = formatError(error)
expect(formatted).toHaveProperty('message', 'Simple string error')
expect(formatted).toHaveProperty('type', 'string')
})
it('should handle unknown error types', () => {
const error = { someProperty: 'value' }
const formatted = formatError(error)
expect(formatted).toHaveProperty('message', 'Unknown error occurred')
expect(formatted).toHaveProperty('type', 'unknown')
})
})
describe('formatServiceData', () => {
it('should format service data correctly', () => {
const rawData = {
'api-gateway': {
status: 'healthy',
lastCheck: '2024-01-01T00:00:00.000Z'
}
}
const formatted = formatServiceData(rawData)
expect(formatted).toHaveProperty('api-gateway')
expect(formatted['api-gateway']).toHaveProperty('status', 'healthy')
expect(formatted['api-gateway']).toHaveProperty('lastCheck')
})
it('should handle empty data', () => {
const formatted = formatServiceData({})
expect(formatted).toEqual({})
})
})
describe('formatEventData', () => {
it('should format event data correctly', () => {
const rawEvents = [
{
id: '1',
timestamp: '2024-01-01T00:00:00.000Z',
service: 'api-gateway',
event_type: 'health_check'
}
]
const formatted = formatEventData(rawEvents)
expect(Array.isArray(formatted)).toBe(true)
expect(formatted[0]).toHaveProperty('id', '1')
expect(formatted[0]).toHaveProperty('service', 'api-gateway')
})
it('should handle empty events array', () => {
const formatted = formatEventData([])
expect(Array.isArray(formatted)).toBe(true)
expect(formatted).toHaveLength(0)
})
})
})