feat(N): workflow pipeline, 3D viewer, worker management, QC tests
- workflow_builder.py: fix broken stubs, add render_order_line_still_task
(resolves step_path from DB instead of passing order_line_id as step_path)
- domains/rendering/tasks.py: add render_order_line_still_task,
export_gltf_for_order_line_task, export_blend_for_order_line_task,
generate_gltf_geometry_task (trimesh STL→GLB, no Blender needed)
- tasks/step_tasks.py: add generate_gltf_geometry_task for CadFile GLB export
- cad router: POST /{id}/generate-gltf-geometry endpoint (admin/PM)
- worker router: GET /celery-workers + POST /scale (docker compose subprocess)
- Dockerfile: pip install -e "[dev]" to enable pytest
- docker-compose.yml: docker socket + compose file mount on backend
- ThreeDViewer.tsx: mode toggle (geometry/production), wireframe, env presets,
download buttons (GLB + .blend)
- CadPreview.tsx: load gltf_geometry/gltf_production/blend_production assets
from MediaAsset table and pass URLs to ThreeDViewer
- ProductDetail.tsx: "View 3D" button → /cad/:id, "Generate GLB" button
- media router/service: cad_file_id filter on GET /api/media
- WorkerManagement.tsx: new page with worker status, queue depth, scale controls
- App.tsx + Layout.tsx: /workers route + sidebar link (admin/PM)
- tests: test_rendering_service.py, test_orders_service.py (backend)
- tests: WorkerActivity.test.tsx, WorkerManagement.test.tsx (frontend)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { describe, test, expect } from 'vitest'
|
||||
|
||||
describe('WorkerActivity Page', () => {
|
||||
test('page module is importable', async () => {
|
||||
const module = await import('../../pages/WorkerActivity')
|
||||
expect(module.default).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('worker API types', () => {
|
||||
test('WorkerActivity interface shape', async () => {
|
||||
// Type-level check: the interface must have the right keys
|
||||
const activity = {
|
||||
cad_processing: [],
|
||||
active_count: 0,
|
||||
failed_count: 0,
|
||||
render_jobs: [],
|
||||
render_active_count: 0,
|
||||
render_failed_count: 0,
|
||||
}
|
||||
expect(activity.cad_processing).toBeInstanceOf(Array)
|
||||
expect(typeof activity.active_count).toBe('number')
|
||||
})
|
||||
|
||||
test('CeleryWorker interface shape', () => {
|
||||
const worker = {
|
||||
name: 'celery@worker1',
|
||||
queues: ['thumbnail_rendering'],
|
||||
active_task_count: 2,
|
||||
active_tasks: [{ name: 'render_still_task', id: 'abc' }],
|
||||
total_tasks_processed: { render_still_task: 42 },
|
||||
}
|
||||
expect(worker.queues).toContain('thumbnail_rendering')
|
||||
expect(worker.active_tasks).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('QueueStatus interface shape', () => {
|
||||
const qs = {
|
||||
queue_depths: { step_processing: 3, thumbnail_rendering: 0 },
|
||||
pending_count: 3,
|
||||
active: [],
|
||||
reserved: [],
|
||||
pending: [],
|
||||
}
|
||||
expect(qs.queue_depths).toHaveProperty('step_processing')
|
||||
expect(qs.pending_count).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('worker API functions', () => {
|
||||
test('getWorkerActivity is a function', async () => {
|
||||
const { getWorkerActivity } = await import('../../api/worker')
|
||||
expect(typeof getWorkerActivity).toBe('function')
|
||||
})
|
||||
|
||||
test('getCeleryWorkers is a function', async () => {
|
||||
const { getCeleryWorkers } = await import('../../api/worker')
|
||||
expect(typeof getCeleryWorkers).toBe('function')
|
||||
})
|
||||
|
||||
test('scaleWorkers is a function', async () => {
|
||||
const { scaleWorkers } = await import('../../api/worker')
|
||||
expect(typeof scaleWorkers).toBe('function')
|
||||
})
|
||||
|
||||
test('getQueueStatus is a function', async () => {
|
||||
const { getQueueStatus } = await import('../../api/worker')
|
||||
expect(typeof getQueueStatus).toBe('function')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,67 @@
|
||||
import { describe, test, expect } from 'vitest'
|
||||
|
||||
describe('WorkerManagement Page', () => {
|
||||
test('page module is importable', async () => {
|
||||
const module = await import('../../pages/WorkerManagement')
|
||||
expect(module.default).toBeDefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('media API', () => {
|
||||
test('getMediaAssets is a function', async () => {
|
||||
const { getMediaAssets } = await import('../../api/media')
|
||||
expect(typeof getMediaAssets).toBe('function')
|
||||
})
|
||||
|
||||
test('MediaFilter supports cad_file_id', () => {
|
||||
// Type-level check: build a filter with cad_file_id
|
||||
const filter = { cad_file_id: 'some-uuid', asset_type: 'gltf_geometry' as const }
|
||||
expect(filter.cad_file_id).toBe('some-uuid')
|
||||
})
|
||||
|
||||
test('MediaAsset interface has all required fields', () => {
|
||||
const asset = {
|
||||
id: 'uuid',
|
||||
tenant_id: null,
|
||||
product_id: null,
|
||||
cad_file_id: null,
|
||||
order_line_id: null,
|
||||
workflow_run_id: null,
|
||||
asset_type: 'still' as const,
|
||||
storage_key: 'path/to/file.png',
|
||||
file_size_bytes: 1024,
|
||||
mime_type: 'image/png',
|
||||
width: 512,
|
||||
height: 512,
|
||||
duration_s: null,
|
||||
render_config: null,
|
||||
is_archived: false,
|
||||
created_at: new Date().toISOString(),
|
||||
download_url: null,
|
||||
}
|
||||
expect(asset.asset_type).toBe('still')
|
||||
expect(asset.cad_file_id).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('cad API', () => {
|
||||
test('generateGltfGeometry is a function', async () => {
|
||||
const { generateGltfGeometry } = await import('../../api/cad')
|
||||
expect(typeof generateGltfGeometry).toBe('function')
|
||||
})
|
||||
|
||||
test('getCadThumbnailUrl returns correct URL', async () => {
|
||||
const { getCadThumbnailUrl } = await import('../../api/cad')
|
||||
const url = getCadThumbnailUrl('test-uuid')
|
||||
expect(url).toBe('/api/cad/test-uuid/thumbnail')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Scale request validation', () => {
|
||||
test('allowed services', () => {
|
||||
const allowed = ['render-worker', 'worker', 'worker-thumbnail']
|
||||
expect(allowed).toContain('render-worker')
|
||||
expect(allowed).toContain('worker-thumbnail')
|
||||
expect(allowed).not.toContain('postgres')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user