功能增加:新增后端传播任务执行器,支持异步自动传播、传播进度、结果统计、取消/重试状态同步。 功能增加:传播请求支持指定 SAM2.1 tiny/small/base+/large 权重,并记录 seed mask、source annotation 和传播范围。 功能增加:传播逻辑增加 seed 签名,未变化的 mask 二次传播会跳过,已变化的 mask 会先清理旧自动传播结果再重新生成,避免重复重叠。 功能增加:工作区增加传播范围二次选择、传播进度提示、人工/AI 标注帧红色标识、自动传播帧蓝色标识和当前帧双层边框。 功能增加:新增临时提示组件,让工具操作提示自动消失且不阻塞后续操作。 功能增加:补充项目删除、模板删除、任务失败详情、任务取消/重试等前后端联动状态。 功能增加:新增安装部署文档,补充当前需求冻结、设计冻结、接口契约、测试计划和 AGENTS/README 项目说明。 Bugfix:修复自动传播接口 404、传播后看不到任务进度、传播结果重复堆叠和已编辑帧提示不清晰的问题。 Bugfix:修复 AI 分割框选/点选交互、单候选 mask、删除选点、工作区保存与候选 mask 推送相关问题。 Bugfix:修复 Canvas 多边形顶点拖动告警、工具栏提示缺失、项目库 FPS 展示和若干 UI 文案/可用性问题。 测试:补充 AI 分割、Canvas、Dashboard、FrameTimeline、ProjectLibrary、TemplateRegistry、ToolsPalette、VideoWorkspace、API 和后端任务/AI/dashboard 测试。 验证:npm run lint;npm run test:run;python -m pytest backend/tests -q。
141 lines
4.5 KiB
Python
141 lines
4.5 KiB
Python
def test_dashboard_overview_uses_persisted_records(client, db_session):
|
|
from models import ProcessingTask
|
|
|
|
project_pending = client.post("/api/projects", json={
|
|
"name": "Pending Project",
|
|
"status": "pending",
|
|
}).json()
|
|
project_ready = client.post("/api/projects", json={
|
|
"name": "Ready Project",
|
|
"status": "ready",
|
|
}).json()
|
|
frame = client.post(f"/api/projects/{project_pending['id']}/frames", json={
|
|
"project_id": project_pending["id"],
|
|
"frame_index": 0,
|
|
"image_url": "frames/0.jpg",
|
|
"width": 640,
|
|
"height": 360,
|
|
}).json()
|
|
template = client.post("/api/templates", json={
|
|
"name": "Dashboard Template",
|
|
"color": "#06b6d4",
|
|
"z_index": 0,
|
|
"classes": [],
|
|
"rules": [],
|
|
}).json()
|
|
annotation = client.post("/api/ai/annotate", json={
|
|
"project_id": project_pending["id"],
|
|
"frame_id": frame["id"],
|
|
"template_id": template["id"],
|
|
"mask_data": {"polygons": [[[0.1, 0.1], [0.9, 0.1], [0.9, 0.9]]]},
|
|
})
|
|
assert annotation.status_code == 201
|
|
task = ProcessingTask(
|
|
task_type="parse_video",
|
|
status="running",
|
|
progress=35,
|
|
message="正在使用 FFmpeg/OpenCV 拆帧",
|
|
project_id=project_pending["id"],
|
|
payload={"source_type": "video"},
|
|
)
|
|
db_session.add(task)
|
|
db_session.commit()
|
|
db_session.refresh(task)
|
|
|
|
response = client.get("/api/dashboard/overview")
|
|
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["summary"]["project_count"] == 2
|
|
assert body["summary"]["frame_count"] == 1
|
|
assert body["summary"]["annotation_count"] == 1
|
|
assert body["summary"]["template_count"] == 1
|
|
assert body["summary"]["parsing_task_count"] == 1
|
|
assert body["tasks"] == [
|
|
{
|
|
"id": f"task-{task.id}",
|
|
"task_id": task.id,
|
|
"project_id": project_pending["id"],
|
|
"name": "Pending Project",
|
|
"progress": 35,
|
|
"status": "正在使用 FFmpeg/OpenCV 拆帧",
|
|
"raw_status": "running",
|
|
"frame_count": 0,
|
|
"error": None,
|
|
"updated_at": body["tasks"][0]["updated_at"],
|
|
},
|
|
]
|
|
assert any(item["kind"] == "task" for item in body["activity"])
|
|
assert any(item["kind"] == "annotation" for item in body["activity"])
|
|
assert any(item["kind"] == "template" for item in body["activity"])
|
|
assert all(item["name"] != "Ready Project" for item in body["tasks"])
|
|
|
|
|
|
def test_dashboard_overview_keeps_recent_success_tasks_in_progress_list(client, db_session):
|
|
from models import ProcessingTask
|
|
|
|
project = client.post("/api/projects", json={
|
|
"name": "Completed Project",
|
|
"status": "ready",
|
|
}).json()
|
|
task = ProcessingTask(
|
|
task_type="parse_video",
|
|
status="success",
|
|
progress=100,
|
|
message="解析完成",
|
|
project_id=project["id"],
|
|
payload={"source_type": "video"},
|
|
result={"frames_extracted": 120},
|
|
)
|
|
db_session.add(task)
|
|
db_session.commit()
|
|
db_session.refresh(task)
|
|
|
|
response = client.get("/api/dashboard/overview")
|
|
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["summary"]["parsing_task_count"] == 0
|
|
assert body["tasks"] == [
|
|
{
|
|
"id": f"task-{task.id}",
|
|
"task_id": task.id,
|
|
"project_id": project["id"],
|
|
"name": "Completed Project",
|
|
"progress": 100,
|
|
"status": "解析完成",
|
|
"raw_status": "success",
|
|
"frame_count": 120,
|
|
"error": None,
|
|
"updated_at": body["tasks"][0]["updated_at"],
|
|
},
|
|
]
|
|
|
|
|
|
def test_dashboard_overview_uses_processed_frame_count_for_propagation_tasks(client, db_session):
|
|
from models import ProcessingTask
|
|
|
|
project = client.post("/api/projects", json={
|
|
"name": "Propagation Project",
|
|
"status": "ready",
|
|
}).json()
|
|
task = ProcessingTask(
|
|
task_type="propagate_masks",
|
|
status="running",
|
|
progress=45,
|
|
message="向后传播 胆囊 (1/2)",
|
|
project_id=project["id"],
|
|
payload={"project_id": project["id"]},
|
|
result={"processed_frame_count": 8, "created_annotation_count": 3},
|
|
)
|
|
db_session.add(task)
|
|
db_session.commit()
|
|
db_session.refresh(task)
|
|
|
|
response = client.get("/api/dashboard/overview")
|
|
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["tasks"][0]["task_id"] == task.id
|
|
assert body["tasks"][0]["frame_count"] == 8
|