github-actions[bot] commited on
Commit ·
658eae3
1
Parent(s): f4744e4
Automated Deploy: 8de175120e0bfae6d206f1fc1680ec7621380469
Browse files- README.md +4 -0
- SETUP.md +1 -0
- app.py +315 -3
- frontend/viz2d-demo/e2e/README.md +3 -2
- frontend/viz2d-demo/e2e/real-room-qa.spec.ts +209 -21
- frontend/viz2d-demo/e2e/support/qa-progress-reporter.cjs +4 -0
- frontend/viz2d-demo/scripts/build-qa-summary.mjs +50 -0
README.md
CHANGED
|
@@ -69,10 +69,14 @@ matches by `ETag` and size, and does not use a database. `/qa/runs` deduplicates
|
|
| 69 |
the selected image keys again, downloads the unique Spaces images into
|
| 70 |
`data/qa-runs/{run_id}/`, starts the Playwright test suite from
|
| 71 |
`QA_FRONTEND_DIR`, and stores file-backed run status/results in that run folder.
|
|
|
|
|
|
|
| 72 |
`/qa/runs/{run_id}/events` streams run updates as Server-Sent Events so the
|
| 73 |
debug page does not need to poll while a run is active. Playwright writes
|
| 74 |
incremental progress after every completed test, so the `completed`, `passed`,
|
| 75 |
and `failed` counters update before the final report is generated.
|
|
|
|
|
|
|
| 76 |
|
| 77 |
On Hugging Face, the deploy workflow copies a minimal `frontend/viz2d-demo` QA
|
| 78 |
runner folder into the Space: npm manifests, Playwright config, e2e tests, and
|
|
|
|
| 69 |
the selected image keys again, downloads the unique Spaces images into
|
| 70 |
`data/qa-runs/{run_id}/`, starts the Playwright test suite from
|
| 71 |
`QA_FRONTEND_DIR`, and stores file-backed run status/results in that run folder.
|
| 72 |
+
The Playwright suite uploads each selected image once, then applies the selected
|
| 73 |
+
tiles one by one, removing the previous tile before applying the next tile.
|
| 74 |
`/qa/runs/{run_id}/events` streams run updates as Server-Sent Events so the
|
| 75 |
debug page does not need to poll while a run is active. Playwright writes
|
| 76 |
incremental progress after every completed test, so the `completed`, `passed`,
|
| 77 |
and `failed` counters update before the final report is generated.
|
| 78 |
+
`/qa/runs/{run_id}/report` renders a shareable HTML report with screenshot URLs;
|
| 79 |
+
`/qa/runs/{run_id}/report.md` returns the compact Markdown summary.
|
| 80 |
|
| 81 |
On Hugging Face, the deploy workflow copies a minimal `frontend/viz2d-demo` QA
|
| 82 |
runner folder into the Space: npm manifests, Playwright config, e2e tests, and
|
SETUP.md
CHANGED
|
@@ -92,4 +92,5 @@ POST /qa/runs
|
|
| 92 |
GET /qa/runs/{run_id}
|
| 93 |
GET /qa/runs/{run_id}/events
|
| 94 |
GET /qa/runs/{run_id}/report
|
|
|
|
| 95 |
```
|
|
|
|
| 92 |
GET /qa/runs/{run_id}
|
| 93 |
GET /qa/runs/{run_id}/events
|
| 94 |
GET /qa/runs/{run_id}/report
|
| 95 |
+
GET /qa/runs/{run_id}/report.md
|
| 96 |
```
|
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
import base64
|
| 3 |
import hashlib
|
|
|
|
| 4 |
import io
|
| 5 |
import json
|
| 6 |
import mimetypes
|
|
@@ -4397,6 +4398,32 @@ def qa_title_parts(title: str):
|
|
| 4397 |
return image_name, tile_name
|
| 4398 |
|
| 4399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4400 |
def collect_playwright_specs(suite: dict, entries: list[tuple[str, dict]]):
|
| 4401 |
for spec in suite.get("specs", []) or []:
|
| 4402 |
title = spec.get("title") or "Untitled QA case"
|
|
@@ -4418,11 +4445,36 @@ def parse_qa_results(run_id: str, report_path: Path):
|
|
| 4418 |
for index, (title, test) in enumerate(entries):
|
| 4419 |
playwright_results = test.get("results", []) or [{}]
|
| 4420 |
final_result = playwright_results[-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4421 |
image_name, tile_name = qa_title_parts(title)
|
| 4422 |
before_attachment = qa_find_attachment(final_result, "before-canvas")
|
| 4423 |
after_attachment = qa_find_attachment(final_result, "after-texture-canvas")
|
| 4424 |
gemini_attachment = qa_find_attachment(final_result, "gemini-judge")
|
| 4425 |
-
status = qa_status_from_playwright(final_result.get("status"), test.get("status"))
|
| 4426 |
error = final_result.get("error", {}).get("message") if isinstance(final_result.get("error"), dict) else None
|
| 4427 |
|
| 4428 |
results.append({
|
|
@@ -4430,7 +4482,7 @@ def parse_qa_results(run_id: str, report_path: Path):
|
|
| 4430 |
"imageKey": image_name,
|
| 4431 |
"imageName": image_name,
|
| 4432 |
"tileName": tile_name,
|
| 4433 |
-
"status":
|
| 4434 |
"beforeImageUrl": qa_asset_url(run_id, qa_attachment_path(before_attachment, report_path)),
|
| 4435 |
"afterImageUrl": qa_asset_url(run_id, qa_attachment_path(after_attachment, report_path)),
|
| 4436 |
"gemini": qa_parse_json_text(qa_read_attachment_text(gemini_attachment, report_path)),
|
|
@@ -4481,6 +4533,7 @@ def qa_runner_env(run_root: Path, scenarios: list[dict], use_gemini: bool, backe
|
|
| 4481 |
"QA_HTML_REPORT_DIR": str(run_root / "html-report"),
|
| 4482 |
"QA_PLAYWRIGHT_OUTPUT_DIR": str(run_root / "artifacts"),
|
| 4483 |
"QA_PROGRESS_FILE": str(run_root / "progress.json"),
|
|
|
|
| 4484 |
"QA_RESULTS_DIR": str(run_root / "results"),
|
| 4485 |
"QA_SCENARIOS": json.dumps(scenarios),
|
| 4486 |
"QA_SKIP_GEMINI": "0" if use_gemini else "1",
|
|
@@ -4577,6 +4630,259 @@ def run_playwright_qa(run_id: str, run_root: Path, env: dict, log_file):
|
|
| 4577 |
time.sleep(1)
|
| 4578 |
|
| 4579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4580 |
def run_qa_task(run_id: str, image_keys: list[str], tiles: list[str], descriptions: dict[str, str], use_gemini: bool, backend_url: str):
|
| 4581 |
run = read_qa_run(run_id)
|
| 4582 |
run_root = qa_run_root(run_id)
|
|
@@ -4933,6 +5239,12 @@ async def qa_run_events(run_id: str, request: Request):
|
|
| 4933 |
|
| 4934 |
@app.get("/qa/runs/{run_id}/report")
|
| 4935 |
async def qa_run_report(run_id: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4936 |
root = qa_run_root(run_id)
|
| 4937 |
report_path = root / "qa-summary.md"
|
| 4938 |
if not report_path.exists():
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
import base64
|
| 3 |
import hashlib
|
| 4 |
+
import html
|
| 5 |
import io
|
| 6 |
import json
|
| 7 |
import mimetypes
|
|
|
|
| 4398 |
return image_name, tile_name
|
| 4399 |
|
| 4400 |
|
| 4401 |
+
def qa_grouped_case_metas(result: dict, report_path: Path):
|
| 4402 |
+
metas = []
|
| 4403 |
+
for attachment in result.get("attachments", []) or []:
|
| 4404 |
+
name = str(attachment.get("name") or "")
|
| 4405 |
+
if not name.startswith("qa-case-") or not name.endswith("-meta"):
|
| 4406 |
+
continue
|
| 4407 |
+
meta = qa_parse_json_text(qa_read_attachment_text(attachment, report_path))
|
| 4408 |
+
if not isinstance(meta, dict):
|
| 4409 |
+
continue
|
| 4410 |
+
prefix = str(meta.get("attachmentPrefix") or name.removesuffix("-meta"))
|
| 4411 |
+
metas.append((prefix, meta))
|
| 4412 |
+
|
| 4413 |
+
def sort_key(item):
|
| 4414 |
+
_, meta = item
|
| 4415 |
+
return qa_int(meta.get("caseIndex"), 0)
|
| 4416 |
+
|
| 4417 |
+
return sorted(metas, key=sort_key)
|
| 4418 |
+
|
| 4419 |
+
|
| 4420 |
+
def qa_case_status(meta: dict, fallback_status: str) -> str:
|
| 4421 |
+
status = str(meta.get("status") or "").lower()
|
| 4422 |
+
if status in {"passed", "failed", "skipped"}:
|
| 4423 |
+
return status
|
| 4424 |
+
return fallback_status
|
| 4425 |
+
|
| 4426 |
+
|
| 4427 |
def collect_playwright_specs(suite: dict, entries: list[tuple[str, dict]]):
|
| 4428 |
for spec in suite.get("specs", []) or []:
|
| 4429 |
title = spec.get("title") or "Untitled QA case"
|
|
|
|
| 4445 |
for index, (title, test) in enumerate(entries):
|
| 4446 |
playwright_results = test.get("results", []) or [{}]
|
| 4447 |
final_result = playwright_results[-1]
|
| 4448 |
+
fallback_status = qa_status_from_playwright(final_result.get("status"), test.get("status"))
|
| 4449 |
+
grouped_cases = qa_grouped_case_metas(final_result, report_path)
|
| 4450 |
+
if grouped_cases:
|
| 4451 |
+
has_case_failure = any(qa_case_status(meta, fallback_status) == "failed" for _, meta in grouped_cases)
|
| 4452 |
+
global_error = final_result.get("error", {}).get("message") if isinstance(final_result.get("error"), dict) else None
|
| 4453 |
+
for case_index, (prefix, meta) in enumerate(grouped_cases, start=1):
|
| 4454 |
+
before_attachment = qa_find_attachment(final_result, f"{prefix}-before-canvas")
|
| 4455 |
+
after_attachment = qa_find_attachment(final_result, f"{prefix}-after-texture-canvas")
|
| 4456 |
+
gemini_attachment = qa_find_attachment(final_result, f"{prefix}-gemini-judge")
|
| 4457 |
+
status = qa_case_status(meta, fallback_status)
|
| 4458 |
+
if fallback_status == "failed" and not has_case_failure:
|
| 4459 |
+
status = "failed"
|
| 4460 |
+
case_id = qa_int(meta.get("caseIndex"), case_index)
|
| 4461 |
+
results.append({
|
| 4462 |
+
"id": f"{run_id}-{case_id}",
|
| 4463 |
+
"imageKey": meta.get("imageName") or meta.get("roomName") or title,
|
| 4464 |
+
"imageName": meta.get("imageName") or meta.get("roomName") or title,
|
| 4465 |
+
"tileName": meta.get("tileName") or "Unknown tile",
|
| 4466 |
+
"status": status,
|
| 4467 |
+
"beforeImageUrl": qa_asset_url(run_id, qa_attachment_path(before_attachment, report_path)),
|
| 4468 |
+
"afterImageUrl": qa_asset_url(run_id, qa_attachment_path(after_attachment, report_path)),
|
| 4469 |
+
"gemini": qa_parse_json_text(qa_read_attachment_text(gemini_attachment, report_path)),
|
| 4470 |
+
"error": meta.get("error") if isinstance(meta.get("error"), str) else global_error,
|
| 4471 |
+
})
|
| 4472 |
+
continue
|
| 4473 |
+
|
| 4474 |
image_name, tile_name = qa_title_parts(title)
|
| 4475 |
before_attachment = qa_find_attachment(final_result, "before-canvas")
|
| 4476 |
after_attachment = qa_find_attachment(final_result, "after-texture-canvas")
|
| 4477 |
gemini_attachment = qa_find_attachment(final_result, "gemini-judge")
|
|
|
|
| 4478 |
error = final_result.get("error", {}).get("message") if isinstance(final_result.get("error"), dict) else None
|
| 4479 |
|
| 4480 |
results.append({
|
|
|
|
| 4482 |
"imageKey": image_name,
|
| 4483 |
"imageName": image_name,
|
| 4484 |
"tileName": tile_name,
|
| 4485 |
+
"status": fallback_status,
|
| 4486 |
"beforeImageUrl": qa_asset_url(run_id, qa_attachment_path(before_attachment, report_path)),
|
| 4487 |
"afterImageUrl": qa_asset_url(run_id, qa_attachment_path(after_attachment, report_path)),
|
| 4488 |
"gemini": qa_parse_json_text(qa_read_attachment_text(gemini_attachment, report_path)),
|
|
|
|
| 4533 |
"QA_HTML_REPORT_DIR": str(run_root / "html-report"),
|
| 4534 |
"QA_PLAYWRIGHT_OUTPUT_DIR": str(run_root / "artifacts"),
|
| 4535 |
"QA_PROGRESS_FILE": str(run_root / "progress.json"),
|
| 4536 |
+
"QA_PROGRESS_MODE": "cases",
|
| 4537 |
"QA_RESULTS_DIR": str(run_root / "results"),
|
| 4538 |
"QA_SCENARIOS": json.dumps(scenarios),
|
| 4539 |
"QA_SKIP_GEMINI": "0" if use_gemini else "1",
|
|
|
|
| 4630 |
time.sleep(1)
|
| 4631 |
|
| 4632 |
|
| 4633 |
+
def qa_html(value) -> str:
|
| 4634 |
+
if value is None:
|
| 4635 |
+
return ""
|
| 4636 |
+
return html.escape(str(value), quote=True)
|
| 4637 |
+
|
| 4638 |
+
|
| 4639 |
+
def qa_status_label(status) -> str:
|
| 4640 |
+
value = str(status or "unknown").lower()
|
| 4641 |
+
if value in {"queued", "running", "completed", "failed", "cancelled", "passed", "skipped"}:
|
| 4642 |
+
return value
|
| 4643 |
+
return "unknown"
|
| 4644 |
+
|
| 4645 |
+
|
| 4646 |
+
def qa_yes_no(value) -> str:
|
| 4647 |
+
if isinstance(value, bool):
|
| 4648 |
+
return "yes" if value else "no"
|
| 4649 |
+
return "n/a"
|
| 4650 |
+
|
| 4651 |
+
|
| 4652 |
+
def qa_score_label(value) -> str:
|
| 4653 |
+
if isinstance(value, (int, float)) and np.isfinite(value):
|
| 4654 |
+
return f"{float(value):.2f}"
|
| 4655 |
+
return "n/a"
|
| 4656 |
+
|
| 4657 |
+
|
| 4658 |
+
def qa_list_label(value) -> str:
|
| 4659 |
+
if isinstance(value, list):
|
| 4660 |
+
items = [str(item) for item in value if isinstance(item, str) and item.strip()]
|
| 4661 |
+
if items:
|
| 4662 |
+
return "; ".join(items)
|
| 4663 |
+
return "none"
|
| 4664 |
+
|
| 4665 |
+
|
| 4666 |
+
def qa_metric_html(label: str, value: str) -> str:
|
| 4667 |
+
return f"<span><strong>{qa_html(value)}</strong>{qa_html(label)}</span>"
|
| 4668 |
+
|
| 4669 |
+
|
| 4670 |
+
def qa_image_html(label: str, url) -> str:
|
| 4671 |
+
if not isinstance(url, str) or not url.strip():
|
| 4672 |
+
return f"""
|
| 4673 |
+
<div class="image-panel missing">
|
| 4674 |
+
<span>{qa_html(label)}</span>
|
| 4675 |
+
<p>Missing screenshot</p>
|
| 4676 |
+
</div>
|
| 4677 |
+
"""
|
| 4678 |
+
return f"""
|
| 4679 |
+
<div class="image-panel">
|
| 4680 |
+
<span>{qa_html(label)}</span>
|
| 4681 |
+
<img src="{qa_html(url)}" alt="{qa_html(label)} QA screenshot" loading="lazy" />
|
| 4682 |
+
</div>
|
| 4683 |
+
"""
|
| 4684 |
+
|
| 4685 |
+
|
| 4686 |
+
def qa_gemini_report_html(gemini) -> str:
|
| 4687 |
+
if not isinstance(gemini, dict):
|
| 4688 |
+
return '<p class="muted">Gemini was not used or did not return a judgment for this result.</p>'
|
| 4689 |
+
|
| 4690 |
+
issue_rows = []
|
| 4691 |
+
if gemini.get("coverageGapDetected"):
|
| 4692 |
+
issue_rows.append(f"<li>Coverage gaps: {qa_html(qa_list_label(gemini.get('missedFloorAreas')))}</li>")
|
| 4693 |
+
if gemini.get("directionMismatchDetected"):
|
| 4694 |
+
issue_rows.append(f"<li>Direction issues: {qa_html(qa_list_label(gemini.get('directionIssues')))}</li>")
|
| 4695 |
+
if gemini.get("bleedDetected"):
|
| 4696 |
+
issue_rows.append("<li>Bleed detected on non-target surfaces.</li>")
|
| 4697 |
+
if isinstance(gemini.get("failureReasons"), list) and gemini.get("failureReasons"):
|
| 4698 |
+
issue_rows.append(f"<li>Failure reasons: {qa_html(qa_list_label(gemini.get('failureReasons')))}</li>")
|
| 4699 |
+
|
| 4700 |
+
issues_html = f"<ul>{''.join(issue_rows)}</ul>" if issue_rows else ""
|
| 4701 |
+
metrics_html = "".join([
|
| 4702 |
+
qa_metric_html("overall", qa_yes_no(gemini.get("overallPass"))),
|
| 4703 |
+
qa_metric_html("tile", qa_yes_no(gemini.get("tileApplied"))),
|
| 4704 |
+
qa_metric_html("coverage gap", qa_yes_no(gemini.get("coverageGapDetected"))),
|
| 4705 |
+
qa_metric_html("direction", qa_score_label(gemini.get("directionQuality"))),
|
| 4706 |
+
qa_metric_html("surface", qa_score_label(gemini.get("surfaceCorrectness"))),
|
| 4707 |
+
qa_metric_html("edge", qa_score_label(gemini.get("edgeCompleteness"))),
|
| 4708 |
+
qa_metric_html("occlusion", qa_score_label(gemini.get("occlusionBoundaryQuality"))),
|
| 4709 |
+
qa_metric_html("perspective", qa_score_label(gemini.get("perspectiveQuality"))),
|
| 4710 |
+
qa_metric_html("lighting", qa_score_label(gemini.get("lightingPreserved"))),
|
| 4711 |
+
qa_metric_html("realism", qa_score_label(gemini.get("realism"))),
|
| 4712 |
+
])
|
| 4713 |
+
|
| 4714 |
+
return f"""
|
| 4715 |
+
<div class="gemini">
|
| 4716 |
+
<div class="metrics">{metrics_html}</div>
|
| 4717 |
+
<p>{qa_html(gemini.get("notes") or "No notes returned.")}</p>
|
| 4718 |
+
{issues_html}
|
| 4719 |
+
</div>
|
| 4720 |
+
"""
|
| 4721 |
+
|
| 4722 |
+
|
| 4723 |
+
def qa_result_report_html(result: dict, index: int) -> str:
|
| 4724 |
+
status = qa_status_label(result.get("status"))
|
| 4725 |
+
image_name = result.get("imageName") or result.get("imageKey") or "Unknown image"
|
| 4726 |
+
tile_name = result.get("tileName") or "Unknown tile"
|
| 4727 |
+
error_html = f'<p class="error">{qa_html(result.get("error"))}</p>' if result.get("error") else ""
|
| 4728 |
+
return f"""
|
| 4729 |
+
<article class="result-card status-{status}">
|
| 4730 |
+
<header>
|
| 4731 |
+
<div>
|
| 4732 |
+
<p class="eyebrow">{qa_html(tile_name)}</p>
|
| 4733 |
+
<h2>{index}. {qa_html(image_name)}</h2>
|
| 4734 |
+
</div>
|
| 4735 |
+
<span class="badge status-{status}">{qa_html(status)}</span>
|
| 4736 |
+
</header>
|
| 4737 |
+
<div class="image-stack">
|
| 4738 |
+
{qa_image_html("Before", result.get("beforeImageUrl"))}
|
| 4739 |
+
{qa_image_html("After Tile Applied", result.get("afterImageUrl"))}
|
| 4740 |
+
</div>
|
| 4741 |
+
{error_html}
|
| 4742 |
+
<section>
|
| 4743 |
+
<h3>Gemini Judgment</h3>
|
| 4744 |
+
{qa_gemini_report_html(result.get("gemini"))}
|
| 4745 |
+
</section>
|
| 4746 |
+
</article>
|
| 4747 |
+
"""
|
| 4748 |
+
|
| 4749 |
+
|
| 4750 |
+
def build_qa_report_html(run: dict) -> str:
|
| 4751 |
+
status = qa_status_label(run.get("status"))
|
| 4752 |
+
results = run.get("results") if isinstance(run.get("results"), list) else []
|
| 4753 |
+
result_cards = "\n".join(
|
| 4754 |
+
qa_result_report_html(result, index)
|
| 4755 |
+
for index, result in enumerate(results, start=1)
|
| 4756 |
+
if isinstance(result, dict)
|
| 4757 |
+
)
|
| 4758 |
+
if not result_cards:
|
| 4759 |
+
result_cards = """
|
| 4760 |
+
<section class="empty">
|
| 4761 |
+
<h2>No screenshots yet</h2>
|
| 4762 |
+
<p>The report will include screenshots and Gemini judgment after Playwright writes the final report.</p>
|
| 4763 |
+
</section>
|
| 4764 |
+
"""
|
| 4765 |
+
error_html = f'<p class="error">{qa_html(run.get("error"))}</p>' if run.get("error") else ""
|
| 4766 |
+
title = f"QA Report {run.get('id', '')}".strip()
|
| 4767 |
+
|
| 4768 |
+
return f"""<!doctype html>
|
| 4769 |
+
<html lang="en">
|
| 4770 |
+
<head>
|
| 4771 |
+
<meta charset="utf-8" />
|
| 4772 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 4773 |
+
<title>{qa_html(title)}</title>
|
| 4774 |
+
<style>
|
| 4775 |
+
:root {{
|
| 4776 |
+
color-scheme: light;
|
| 4777 |
+
--bg: #f6f7fb;
|
| 4778 |
+
--panel: #ffffff;
|
| 4779 |
+
--ink: #172033;
|
| 4780 |
+
--muted: #667085;
|
| 4781 |
+
--line: #d8deea;
|
| 4782 |
+
--passed: #177245;
|
| 4783 |
+
--failed: #b4233a;
|
| 4784 |
+
--running: #1d5fbf;
|
| 4785 |
+
}}
|
| 4786 |
+
* {{ box-sizing: border-box; }}
|
| 4787 |
+
body {{
|
| 4788 |
+
margin: 0;
|
| 4789 |
+
background: var(--bg);
|
| 4790 |
+
color: var(--ink);
|
| 4791 |
+
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| 4792 |
+
line-height: 1.5;
|
| 4793 |
+
}}
|
| 4794 |
+
main {{ width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 56px; }}
|
| 4795 |
+
.topbar {{ display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }}
|
| 4796 |
+
h1, h2, h3, p {{ margin-top: 0; }}
|
| 4797 |
+
h1 {{ font-size: clamp(28px, 4vw, 42px); margin-bottom: 8px; }}
|
| 4798 |
+
h2 {{ font-size: 20px; margin-bottom: 4px; }}
|
| 4799 |
+
h3 {{ font-size: 14px; margin-bottom: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }}
|
| 4800 |
+
.eyebrow {{ color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }}
|
| 4801 |
+
.summary, .metrics {{ display: flex; flex-wrap: wrap; gap: 8px; }}
|
| 4802 |
+
.summary span, .metrics span {{
|
| 4803 |
+
border: 1px solid var(--line);
|
| 4804 |
+
border-radius: 8px;
|
| 4805 |
+
background: #fff;
|
| 4806 |
+
color: var(--muted);
|
| 4807 |
+
display: inline-flex;
|
| 4808 |
+
gap: 6px;
|
| 4809 |
+
padding: 7px 10px;
|
| 4810 |
+
font-size: 13px;
|
| 4811 |
+
align-items: baseline;
|
| 4812 |
+
}}
|
| 4813 |
+
.summary strong, .metrics strong {{ color: var(--ink); }}
|
| 4814 |
+
.badge {{
|
| 4815 |
+
border: 1px solid var(--line);
|
| 4816 |
+
border-radius: 999px;
|
| 4817 |
+
background: #fff;
|
| 4818 |
+
color: var(--muted);
|
| 4819 |
+
padding: 6px 10px;
|
| 4820 |
+
font-size: 12px;
|
| 4821 |
+
font-weight: 800;
|
| 4822 |
+
text-transform: uppercase;
|
| 4823 |
+
white-space: nowrap;
|
| 4824 |
+
}}
|
| 4825 |
+
.status-passed, .status-completed {{ color: var(--passed); border-color: #9bd4b5; }}
|
| 4826 |
+
.status-failed {{ color: var(--failed); border-color: #f0a4b3; }}
|
| 4827 |
+
.status-running, .status-queued {{ color: var(--running); border-color: #a9c7ff; }}
|
| 4828 |
+
.result-card, .empty {{
|
| 4829 |
+
background: var(--panel);
|
| 4830 |
+
border: 1px solid var(--line);
|
| 4831 |
+
border-radius: 10px;
|
| 4832 |
+
padding: 18px;
|
| 4833 |
+
margin-top: 18px;
|
| 4834 |
+
box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
|
| 4835 |
+
}}
|
| 4836 |
+
.result-card > header {{ display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }}
|
| 4837 |
+
.image-stack {{ display: grid; gap: 16px; }}
|
| 4838 |
+
.image-panel {{ border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #f8fafc; }}
|
| 4839 |
+
.image-panel span {{ display: block; padding: 8px 10px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }}
|
| 4840 |
+
.image-panel img {{ display: block; width: 100%; height: auto; }}
|
| 4841 |
+
.image-panel.missing {{ padding-bottom: 16px; }}
|
| 4842 |
+
.image-panel.missing p {{ margin: 0; padding: 0 10px; color: var(--muted); }}
|
| 4843 |
+
.gemini {{ margin-top: 8px; }}
|
| 4844 |
+
.gemini p {{ color: var(--ink); margin: 12px 0 0; }}
|
| 4845 |
+
.gemini ul {{ margin: 12px 0 0; padding-left: 20px; color: var(--failed); }}
|
| 4846 |
+
.muted {{ color: var(--muted); }}
|
| 4847 |
+
.error {{
|
| 4848 |
+
border: 1px solid #f0a4b3;
|
| 4849 |
+
border-radius: 8px;
|
| 4850 |
+
background: #fff1f3;
|
| 4851 |
+
color: var(--failed);
|
| 4852 |
+
padding: 10px 12px;
|
| 4853 |
+
white-space: pre-wrap;
|
| 4854 |
+
}}
|
| 4855 |
+
@media (max-width: 720px) {{
|
| 4856 |
+
main {{ width: min(100% - 20px, 1120px); padding-top: 20px; }}
|
| 4857 |
+
.topbar, .result-card > header {{ display: block; }}
|
| 4858 |
+
.badge {{ display: inline-block; margin-top: 8px; }}
|
| 4859 |
+
}}
|
| 4860 |
+
</style>
|
| 4861 |
+
</head>
|
| 4862 |
+
<body>
|
| 4863 |
+
<main>
|
| 4864 |
+
<header class="topbar">
|
| 4865 |
+
<div>
|
| 4866 |
+
<p class="eyebrow">Real Browser QA Report</p>
|
| 4867 |
+
<h1>{qa_html(run.get("id") or "QA run")}</h1>
|
| 4868 |
+
<p class="muted">Generated from backend QA run data. Screenshots are served as report assets, not embedded base64.</p>
|
| 4869 |
+
</div>
|
| 4870 |
+
<span class="badge status-{status}">{qa_html(status)}</span>
|
| 4871 |
+
</header>
|
| 4872 |
+
<section class="summary">
|
| 4873 |
+
{qa_metric_html("done", f"{qa_int(run.get('completed'))}/{qa_int(run.get('total'))}")}
|
| 4874 |
+
{qa_metric_html("passed", str(qa_int(run.get("passed"))))}
|
| 4875 |
+
{qa_metric_html("failed", str(qa_int(run.get("failed"))))}
|
| 4876 |
+
{qa_metric_html("updated", str(run.get("updatedAt") or "unknown"))}
|
| 4877 |
+
</section>
|
| 4878 |
+
{error_html}
|
| 4879 |
+
{result_cards}
|
| 4880 |
+
</main>
|
| 4881 |
+
</body>
|
| 4882 |
+
</html>
|
| 4883 |
+
"""
|
| 4884 |
+
|
| 4885 |
+
|
| 4886 |
def run_qa_task(run_id: str, image_keys: list[str], tiles: list[str], descriptions: dict[str, str], use_gemini: bool, backend_url: str):
|
| 4887 |
run = read_qa_run(run_id)
|
| 4888 |
run_root = qa_run_root(run_id)
|
|
|
|
| 5239 |
|
| 5240 |
@app.get("/qa/runs/{run_id}/report")
|
| 5241 |
async def qa_run_report(run_id: str):
|
| 5242 |
+
run = read_qa_run(run_id)
|
| 5243 |
+
return Response(content=build_qa_report_html(run), media_type="text/html", headers={"Cache-Control": "no-store"})
|
| 5244 |
+
|
| 5245 |
+
|
| 5246 |
+
@app.get("/qa/runs/{run_id}/report.md")
|
| 5247 |
+
async def qa_run_markdown_report(run_id: str):
|
| 5248 |
root = qa_run_root(run_id)
|
| 5249 |
report_path = root / "qa-summary.md"
|
| 5250 |
if not report_path.exists():
|
frontend/viz2d-demo/e2e/README.md
CHANGED
|
@@ -3,8 +3,9 @@
|
|
| 3 |
This suite drives the visualizer through Playwright using every image in `frontend/viz2d-demo/test-images/`
|
| 4 |
and the configured hosted backend.
|
| 5 |
|
| 6 |
-
The default flow uploads each test image,
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
Required CI secrets:
|
| 10 |
|
|
|
|
| 3 |
This suite drives the visualizer through Playwright using every image in `frontend/viz2d-demo/test-images/`
|
| 4 |
and the configured hosted backend.
|
| 5 |
|
| 6 |
+
The default flow uploads each test image once, waits for detection once, then applies each selected tile in sequence
|
| 7 |
+
to the same detected room. After each tile result is captured and judged, the suite removes that tile before applying
|
| 8 |
+
the next one. It does not touch the user-only tile size or rotation sliders.
|
| 9 |
|
| 10 |
Required CI secrets:
|
| 11 |
|
frontend/viz2d-demo/e2e/real-room-qa.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { existsSync, readdirSync } from "node:fs";
|
| 2 |
import path from "node:path";
|
| 3 |
|
| 4 |
import { expect, test, type Locator, type Page, type TestInfo } from "@playwright/test";
|
|
@@ -31,6 +31,18 @@ type QaScenario = {
|
|
| 31 |
textureName: string;
|
| 32 |
};
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".webp"]);
|
| 35 |
const TEST_IMAGES_DIR = path.resolve(process.env.QA_TEST_IMAGES_DIR ?? "test-images");
|
| 36 |
const DEFAULT_SCENARIO_OPTIONS = {
|
|
@@ -51,46 +63,88 @@ const DEFAULT_SCENARIO_OPTIONS = {
|
|
| 51 |
textureDescription: "black and white marble checkerboard tile",
|
| 52 |
textureName: "Black White Marble Checkered",
|
| 53 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
test.describe("real backend room visualizer QA", () => {
|
| 56 |
-
for (const
|
| 57 |
-
test(`${
|
| 58 |
requireBackendUrl();
|
|
|
|
| 59 |
const diagnostics = collectDiagnostics(page);
|
| 60 |
|
| 61 |
await page.goto("/");
|
| 62 |
await expect(page.getByText("Upload a Room Photo")).toBeVisible();
|
| 63 |
|
| 64 |
-
await page.getByTestId("room-file-input").setInputFiles(
|
| 65 |
await expect(page.getByTestId("visualizer-editor")).toBeVisible({ timeout: 30_000 });
|
| 66 |
-
await waitForSurfaceCards(page,
|
| 67 |
|
| 68 |
const canvas = page.getByTestId("visualizer-canvas");
|
| 69 |
const beforeSignature = await waitForUsableCanvas(page, canvas);
|
| 70 |
-
const beforePath = testInfo.outputPath(`${slug(
|
| 71 |
await canvas.screenshot({ path: beforePath });
|
| 72 |
await testInfo.attach("before-canvas", { contentType: "image/png", path: beforePath });
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
await verifyDownload(page, testInfo);
|
| 86 |
-
await runGeminiJudgeIfEnabled(scenario, beforePath, afterTexturePath, testInfo);
|
| 87 |
await attachDiagnostics(testInfo, diagnostics);
|
| 88 |
|
| 89 |
expect(diagnostics.pageErrors, "browser page errors").toEqual([]);
|
|
|
|
| 90 |
});
|
| 91 |
}
|
| 92 |
});
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
async function waitForSurfaceCards(page: Page, timeoutMs: number) {
|
| 95 |
const deadline = Date.now() + timeoutMs;
|
| 96 |
while (Date.now() < deadline) {
|
|
@@ -159,6 +213,31 @@ async function waitForTextureToSettle(page: Page, textureName: string) {
|
|
| 159 |
});
|
| 160 |
}
|
| 161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
async function waitForChangedCanvas(page: Page, canvas: Locator, previous: CanvasSignature, scenario: QaScenario) {
|
| 163 |
const deadline = Date.now() + 60_000;
|
| 164 |
let latest = await readCanvasSignature(canvas);
|
|
@@ -184,7 +263,7 @@ async function waitForChangedCanvas(page: Page, canvas: Locator, previous: Canva
|
|
| 184 |
return latest;
|
| 185 |
}
|
| 186 |
|
| 187 |
-
async function verifyDownload(page: Page, testInfo: TestInfo) {
|
| 188 |
const downloadPromise = page.waitForEvent("download", { timeout: 30_000 });
|
| 189 |
await page.getByLabel("Download image").click();
|
| 190 |
const download = await downloadPromise;
|
|
@@ -192,7 +271,7 @@ async function verifyDownload(page: Page, testInfo: TestInfo) {
|
|
| 192 |
|
| 193 |
const downloadPath = await download.path();
|
| 194 |
if (downloadPath) {
|
| 195 |
-
await testInfo.attach(
|
| 196 |
}
|
| 197 |
}
|
| 198 |
|
|
@@ -201,6 +280,7 @@ async function runGeminiJudgeIfEnabled(
|
|
| 201 |
beforeImagePath: string,
|
| 202 |
afterImagePath: string,
|
| 203 |
testInfo: TestInfo,
|
|
|
|
| 204 |
) {
|
| 205 |
if (flagEnabled("QA_SKIP_GEMINI")) {
|
| 206 |
testInfo.annotations.push({ description: "QA_SKIP_GEMINI is enabled.", type: "gemini-skipped" });
|
|
@@ -220,7 +300,7 @@ async function runGeminiJudgeIfEnabled(
|
|
| 220 |
scenario,
|
| 221 |
});
|
| 222 |
|
| 223 |
-
await testInfo.attach(
|
| 224 |
body: JSON.stringify(result, null, 2),
|
| 225 |
contentType: "application/json",
|
| 226 |
});
|
|
@@ -258,6 +338,82 @@ function assertGeminiResult(result: GeminiJudgeResult, scenario: QaScenario) {
|
|
| 258 |
expect(result.overallPass, `Gemini failure reasons: ${result.failureReasons.join("; ")}`).toBe(true);
|
| 259 |
}
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
function loadScenarios() {
|
| 262 |
const raw = process.env.QA_SCENARIOS?.trim();
|
| 263 |
const overrides = raw ? parseScenarioOverrides(raw) : [];
|
|
@@ -277,6 +433,33 @@ function loadScenarios() {
|
|
| 277 |
return images.map((imagePath, index) => normalizeScenario(imagePath, overrides[index], index));
|
| 278 |
}
|
| 279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
function parseScenarioOverrides(raw: string) {
|
| 281 |
const parsed = JSON.parse(raw) as unknown;
|
| 282 |
if (!Array.isArray(parsed)) {
|
|
@@ -405,6 +588,11 @@ function flagEnabled(name: string) {
|
|
| 405 |
return ["1", "true", "yes", "on"].includes((process.env[name] ?? "").toLowerCase());
|
| 406 |
}
|
| 407 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
function slug(value: string) {
|
| 409 |
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") || "room";
|
| 410 |
}
|
|
|
|
| 1 |
+
import { existsSync, mkdirSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
| 2 |
import path from "node:path";
|
| 3 |
|
| 4 |
import { expect, test, type Locator, type Page, type TestInfo } from "@playwright/test";
|
|
|
|
| 31 |
textureName: string;
|
| 32 |
};
|
| 33 |
|
| 34 |
+
type QaScenarioCase = QaScenario & {
|
| 35 |
+
qaCaseIndex: number;
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
type QaScenarioGroup = {
|
| 39 |
+
imagePath: string;
|
| 40 |
+
roomName: string;
|
| 41 |
+
scenarios: QaScenarioCase[];
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
type QaCaseStatus = "passed" | "failed" | "skipped";
|
| 45 |
+
|
| 46 |
const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".webp"]);
|
| 47 |
const TEST_IMAGES_DIR = path.resolve(process.env.QA_TEST_IMAGES_DIR ?? "test-images");
|
| 48 |
const DEFAULT_SCENARIO_OPTIONS = {
|
|
|
|
| 63 |
textureDescription: "black and white marble checkerboard tile",
|
| 64 |
textureName: "Black White Marble Checkered",
|
| 65 |
};
|
| 66 |
+
const SCENARIO_GROUPS = groupScenarios(loadScenarios());
|
| 67 |
+
const TOTAL_QA_CASES = SCENARIO_GROUPS.reduce((total, group) => total + group.scenarios.length, 0);
|
| 68 |
+
const QA_CASE_PROGRESS = new Map<string, {
|
| 69 |
+
durationMs: number;
|
| 70 |
+
error: string | null;
|
| 71 |
+
imageName: string;
|
| 72 |
+
status: QaCaseStatus;
|
| 73 |
+
title: string;
|
| 74 |
+
tileName: string;
|
| 75 |
+
}>();
|
| 76 |
|
| 77 |
test.describe("real backend room visualizer QA", () => {
|
| 78 |
+
for (const group of SCENARIO_GROUPS) {
|
| 79 |
+
test(`${group.roomName}: apply ${group.scenarios.length} tile(s)`, async ({ page }, testInfo) => {
|
| 80 |
requireBackendUrl();
|
| 81 |
+
writeQaCaseProgress();
|
| 82 |
const diagnostics = collectDiagnostics(page);
|
| 83 |
|
| 84 |
await page.goto("/");
|
| 85 |
await expect(page.getByText("Upload a Room Photo")).toBeVisible();
|
| 86 |
|
| 87 |
+
await page.getByTestId("room-file-input").setInputFiles(group.imagePath);
|
| 88 |
await expect(page.getByTestId("visualizer-editor")).toBeVisible({ timeout: 30_000 });
|
| 89 |
+
await waitForSurfaceCards(page, maxDetectionTimeout(group.scenarios));
|
| 90 |
|
| 91 |
const canvas = page.getByTestId("visualizer-canvas");
|
| 92 |
const beforeSignature = await waitForUsableCanvas(page, canvas);
|
| 93 |
+
const beforePath = testInfo.outputPath(`${slug(group.roomName)}-before.png`);
|
| 94 |
await canvas.screenshot({ path: beforePath });
|
| 95 |
await testInfo.attach("before-canvas", { contentType: "image/png", path: beforePath });
|
| 96 |
|
| 97 |
+
const failures: string[] = [];
|
| 98 |
+
for (const scenario of group.scenarios) {
|
| 99 |
+
await test.step(`apply ${scenario.textureName}`, async () => {
|
| 100 |
+
const startedAt = Date.now();
|
| 101 |
+
const attachmentPrefix = qaCaseAttachmentPrefix(scenario);
|
| 102 |
+
await testInfo.attach(`${attachmentPrefix}-before-canvas`, { contentType: "image/png", path: beforePath });
|
| 103 |
+
|
| 104 |
+
try {
|
| 105 |
+
await selectSurface(page, scenario.surfaceClass);
|
| 106 |
+
await selectTexture(page, scenario);
|
| 107 |
+
await waitForTextureToSettle(page, scenario.textureName);
|
| 108 |
+
await page.mouse.move(8, 8);
|
| 109 |
+
|
| 110 |
+
const afterTextureSignature = await waitForChangedCanvas(page, canvas, beforeSignature, scenario);
|
| 111 |
+
expectUsableCanvas(afterTextureSignature);
|
| 112 |
+
const afterTexturePath = testInfo.outputPath(
|
| 113 |
+
`${slug(scenario.roomName)}-${scenario.qaCaseIndex}-${slug(scenario.textureName)}-after-texture.png`,
|
| 114 |
+
);
|
| 115 |
+
await canvas.screenshot({ path: afterTexturePath });
|
| 116 |
+
await testInfo.attach(`${attachmentPrefix}-after-texture-canvas`, {
|
| 117 |
+
contentType: "image/png",
|
| 118 |
+
path: afterTexturePath,
|
| 119 |
+
});
|
| 120 |
+
|
| 121 |
+
await verifyDownload(page, testInfo, `${attachmentPrefix}-downloaded-render`);
|
| 122 |
+
await runGeminiJudgeIfEnabled(scenario, beforePath, afterTexturePath, testInfo, attachmentPrefix);
|
| 123 |
+
await attachQaCaseMeta(testInfo, scenario, attachmentPrefix, "passed", null, Date.now() - startedAt);
|
| 124 |
+
recordQaCaseProgress(scenario, "passed", null, Date.now() - startedAt);
|
| 125 |
+
} catch (caught) {
|
| 126 |
+
const message = errorMessage(caught);
|
| 127 |
+
failures.push(`${scenario.textureName}: ${message}`);
|
| 128 |
+
await attachQaCaseMeta(testInfo, scenario, attachmentPrefix, "failed", message, Date.now() - startedAt);
|
| 129 |
+
recordQaCaseProgress(scenario, "failed", message, Date.now() - startedAt);
|
| 130 |
+
} finally {
|
| 131 |
+
await removeTextureIfApplied(page, scenario.surfaceClass);
|
| 132 |
+
}
|
| 133 |
+
});
|
| 134 |
+
}
|
| 135 |
|
|
|
|
|
|
|
| 136 |
await attachDiagnostics(testInfo, diagnostics);
|
| 137 |
|
| 138 |
expect(diagnostics.pageErrors, "browser page errors").toEqual([]);
|
| 139 |
+
expect(failures, "tile QA failures").toEqual([]);
|
| 140 |
});
|
| 141 |
}
|
| 142 |
});
|
| 143 |
|
| 144 |
+
function maxDetectionTimeout(scenarios: QaScenario[]) {
|
| 145 |
+
return scenarios.reduce((timeout, scenario) => Math.max(timeout, scenario.detectionTimeoutMs), 0);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
async function waitForSurfaceCards(page: Page, timeoutMs: number) {
|
| 149 |
const deadline = Date.now() + timeoutMs;
|
| 150 |
while (Date.now() < deadline) {
|
|
|
|
| 213 |
});
|
| 214 |
}
|
| 215 |
|
| 216 |
+
async function removeTextureIfApplied(page: Page, surfaceClass: string) {
|
| 217 |
+
const selector = page.getByTestId("texture-selector");
|
| 218 |
+
if (await selector.isVisible().catch(() => false)) {
|
| 219 |
+
await page.getByLabel("Close texture selector").click().catch(async () => {
|
| 220 |
+
await page.getByLabel("Close").click().catch(() => undefined);
|
| 221 |
+
});
|
| 222 |
+
await expect(selector).toBeHidden({ timeout: 10_000 }).catch(() => undefined);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
const exactSurface = page.locator(`[data-testid="surface-card"][data-surface-class="${surfaceClass}"]`).first();
|
| 226 |
+
const surface = await exactSurface.isVisible().catch(() => false) ? exactSurface : page.getByTestId("surface-card").first();
|
| 227 |
+
const removeButton = surface.getByTestId("remove-surface-texture").first();
|
| 228 |
+
const fallbackRemoveButton = surface.locator("button").first();
|
| 229 |
+
const target = await removeButton.isVisible().catch(() => false) ? removeButton : fallbackRemoveButton;
|
| 230 |
+
|
| 231 |
+
if (!(await target.isVisible().catch(() => false))) {
|
| 232 |
+
return;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
await target.click();
|
| 236 |
+
await page.getByTestId("blocking-overlay").waitFor({ state: "hidden", timeout: 60_000 }).catch(() => undefined);
|
| 237 |
+
await expect(surface.getByText("Click to apply texture")).toBeVisible({ timeout: 30_000 }).catch(() => undefined);
|
| 238 |
+
await page.waitForTimeout(500);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
async function waitForChangedCanvas(page: Page, canvas: Locator, previous: CanvasSignature, scenario: QaScenario) {
|
| 242 |
const deadline = Date.now() + 60_000;
|
| 243 |
let latest = await readCanvasSignature(canvas);
|
|
|
|
| 263 |
return latest;
|
| 264 |
}
|
| 265 |
|
| 266 |
+
async function verifyDownload(page: Page, testInfo: TestInfo, attachmentName: string) {
|
| 267 |
const downloadPromise = page.waitForEvent("download", { timeout: 30_000 });
|
| 268 |
await page.getByLabel("Download image").click();
|
| 269 |
const download = await downloadPromise;
|
|
|
|
| 271 |
|
| 272 |
const downloadPath = await download.path();
|
| 273 |
if (downloadPath) {
|
| 274 |
+
await testInfo.attach(attachmentName, { contentType: "image/png", path: downloadPath });
|
| 275 |
}
|
| 276 |
}
|
| 277 |
|
|
|
|
| 280 |
beforeImagePath: string,
|
| 281 |
afterImagePath: string,
|
| 282 |
testInfo: TestInfo,
|
| 283 |
+
attachmentPrefix: string,
|
| 284 |
) {
|
| 285 |
if (flagEnabled("QA_SKIP_GEMINI")) {
|
| 286 |
testInfo.annotations.push({ description: "QA_SKIP_GEMINI is enabled.", type: "gemini-skipped" });
|
|
|
|
| 300 |
scenario,
|
| 301 |
});
|
| 302 |
|
| 303 |
+
await testInfo.attach(`${attachmentPrefix}-gemini-judge`, {
|
| 304 |
body: JSON.stringify(result, null, 2),
|
| 305 |
contentType: "application/json",
|
| 306 |
});
|
|
|
|
| 338 |
expect(result.overallPass, `Gemini failure reasons: ${result.failureReasons.join("; ")}`).toBe(true);
|
| 339 |
}
|
| 340 |
|
| 341 |
+
async function attachQaCaseMeta(
|
| 342 |
+
testInfo: TestInfo,
|
| 343 |
+
scenario: QaScenarioCase,
|
| 344 |
+
attachmentPrefix: string,
|
| 345 |
+
status: QaCaseStatus,
|
| 346 |
+
error: string | null,
|
| 347 |
+
durationMs: number,
|
| 348 |
+
) {
|
| 349 |
+
await testInfo.attach(`${attachmentPrefix}-meta`, {
|
| 350 |
+
body: JSON.stringify({
|
| 351 |
+
attachmentPrefix,
|
| 352 |
+
caseIndex: scenario.qaCaseIndex,
|
| 353 |
+
durationMs,
|
| 354 |
+
error,
|
| 355 |
+
imageName: scenario.roomName,
|
| 356 |
+
imagePath: scenario.imagePath,
|
| 357 |
+
roomName: scenario.roomName,
|
| 358 |
+
status,
|
| 359 |
+
surfaceClass: scenario.surfaceClass,
|
| 360 |
+
tileName: scenario.textureName,
|
| 361 |
+
}, null, 2),
|
| 362 |
+
contentType: "application/json",
|
| 363 |
+
});
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
function recordQaCaseProgress(
|
| 367 |
+
scenario: QaScenarioCase,
|
| 368 |
+
status: QaCaseStatus,
|
| 369 |
+
error: string | null,
|
| 370 |
+
durationMs: number,
|
| 371 |
+
) {
|
| 372 |
+
QA_CASE_PROGRESS.set(qaCaseId(scenario), {
|
| 373 |
+
durationMs,
|
| 374 |
+
error,
|
| 375 |
+
imageName: scenario.roomName,
|
| 376 |
+
status,
|
| 377 |
+
title: `${scenario.roomName}: apply ${scenario.textureName} to ${scenario.surfaceClass}`,
|
| 378 |
+
tileName: scenario.textureName,
|
| 379 |
+
});
|
| 380 |
+
writeQaCaseProgress();
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
function writeQaCaseProgress() {
|
| 384 |
+
const progressFile = process.env.QA_PROGRESS_FILE;
|
| 385 |
+
if (!progressFile) return;
|
| 386 |
+
|
| 387 |
+
const results = [...QA_CASE_PROGRESS.values()];
|
| 388 |
+
const passed = results.filter((entry) => entry.status === "passed").length;
|
| 389 |
+
const failed = results.filter((entry) => entry.status === "failed").length;
|
| 390 |
+
const skipped = results.filter((entry) => entry.status === "skipped").length;
|
| 391 |
+
const completed = passed + failed + skipped;
|
| 392 |
+
const payload = {
|
| 393 |
+
completed,
|
| 394 |
+
failed,
|
| 395 |
+
passed,
|
| 396 |
+
results,
|
| 397 |
+
skipped,
|
| 398 |
+
status: "running",
|
| 399 |
+
total: TOTAL_QA_CASES,
|
| 400 |
+
updatedAt: new Date().toISOString(),
|
| 401 |
+
};
|
| 402 |
+
|
| 403 |
+
mkdirSync(path.dirname(progressFile), { recursive: true });
|
| 404 |
+
const tempFile = `${progressFile}.${process.pid}.tmp`;
|
| 405 |
+
writeFileSync(tempFile, JSON.stringify(payload, null, 2));
|
| 406 |
+
renameSync(tempFile, progressFile);
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
function qaCaseId(scenario: QaScenarioCase) {
|
| 410 |
+
return `${scenario.qaCaseIndex}:${scenario.imagePath}:${scenario.textureName}:${scenario.surfaceClass}`;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
function qaCaseAttachmentPrefix(scenario: QaScenarioCase) {
|
| 414 |
+
return `qa-case-${scenario.qaCaseIndex}`;
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
function loadScenarios() {
|
| 418 |
const raw = process.env.QA_SCENARIOS?.trim();
|
| 419 |
const overrides = raw ? parseScenarioOverrides(raw) : [];
|
|
|
|
| 433 |
return images.map((imagePath, index) => normalizeScenario(imagePath, overrides[index], index));
|
| 434 |
}
|
| 435 |
|
| 436 |
+
function groupScenarios(scenarios: QaScenario[]): QaScenarioGroup[] {
|
| 437 |
+
const groups: QaScenarioGroup[] = [];
|
| 438 |
+
const groupByImagePath = new Map<string, QaScenarioGroup>();
|
| 439 |
+
|
| 440 |
+
for (const [index, scenario] of scenarios.entries()) {
|
| 441 |
+
const qaCase = {
|
| 442 |
+
...scenario,
|
| 443 |
+
qaCaseIndex: index + 1,
|
| 444 |
+
};
|
| 445 |
+
const existing = groupByImagePath.get(scenario.imagePath);
|
| 446 |
+
if (existing) {
|
| 447 |
+
existing.scenarios.push(qaCase);
|
| 448 |
+
continue;
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
const group = {
|
| 452 |
+
imagePath: scenario.imagePath,
|
| 453 |
+
roomName: scenario.roomName,
|
| 454 |
+
scenarios: [qaCase],
|
| 455 |
+
};
|
| 456 |
+
groupByImagePath.set(scenario.imagePath, group);
|
| 457 |
+
groups.push(group);
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
return groups;
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
function parseScenarioOverrides(raw: string) {
|
| 464 |
const parsed = JSON.parse(raw) as unknown;
|
| 465 |
if (!Array.isArray(parsed)) {
|
|
|
|
| 588 |
return ["1", "true", "yes", "on"].includes((process.env[name] ?? "").toLowerCase());
|
| 589 |
}
|
| 590 |
|
| 591 |
+
function errorMessage(error: unknown) {
|
| 592 |
+
if (error instanceof Error) return error.message;
|
| 593 |
+
return String(error);
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
function slug(value: string) {
|
| 597 |
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "") || "room";
|
| 598 |
}
|
frontend/viz2d-demo/e2e/support/qa-progress-reporter.cjs
CHANGED
|
@@ -8,6 +8,7 @@ function normalizeStatus(status) {
|
|
| 8 |
|
| 9 |
class QaProgressReporter {
|
| 10 |
constructor() {
|
|
|
|
| 11 |
this.progressFile = process.env.QA_PROGRESS_FILE;
|
| 12 |
this.resultByTest = new Map();
|
| 13 |
this.testOrder = [];
|
|
@@ -15,6 +16,7 @@ class QaProgressReporter {
|
|
| 15 |
}
|
| 16 |
|
| 17 |
onBegin(_config, suite) {
|
|
|
|
| 18 |
const tests = suite.allTests();
|
| 19 |
this.testOrder = tests.map((test) => this.testKey(test));
|
| 20 |
this.total = tests.length;
|
|
@@ -22,6 +24,7 @@ class QaProgressReporter {
|
|
| 22 |
}
|
| 23 |
|
| 24 |
onTestEnd(test, result) {
|
|
|
|
| 25 |
const key = this.testKey(test);
|
| 26 |
if (!this.testOrder.includes(key)) this.testOrder.push(key);
|
| 27 |
this.resultByTest.set(key, {
|
|
@@ -34,6 +37,7 @@ class QaProgressReporter {
|
|
| 34 |
}
|
| 35 |
|
| 36 |
onEnd(result) {
|
|
|
|
| 37 |
this.write(result.status === "passed" ? "completed" : "failed");
|
| 38 |
}
|
| 39 |
|
|
|
|
| 8 |
|
| 9 |
class QaProgressReporter {
|
| 10 |
constructor() {
|
| 11 |
+
this.disabled = process.env.QA_PROGRESS_MODE === "cases";
|
| 12 |
this.progressFile = process.env.QA_PROGRESS_FILE;
|
| 13 |
this.resultByTest = new Map();
|
| 14 |
this.testOrder = [];
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
onBegin(_config, suite) {
|
| 19 |
+
if (this.disabled) return;
|
| 20 |
const tests = suite.allTests();
|
| 21 |
this.testOrder = tests.map((test) => this.testKey(test));
|
| 22 |
this.total = tests.length;
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
onTestEnd(test, result) {
|
| 27 |
+
if (this.disabled) return;
|
| 28 |
const key = this.testKey(test);
|
| 29 |
if (!this.testOrder.includes(key)) this.testOrder.push(key);
|
| 30 |
this.resultByTest.set(key, {
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
onEnd(result) {
|
| 40 |
+
if (this.disabled) return;
|
| 41 |
this.write(result.status === "passed" ? "completed" : "failed");
|
| 42 |
}
|
| 43 |
|
frontend/viz2d-demo/scripts/build-qa-summary.mjs
CHANGED
|
@@ -41,6 +41,12 @@ async function main() {
|
|
| 41 |
|
| 42 |
for (const entry of entries) {
|
| 43 |
const result = finalResult(entry.test);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
const beforeImage = await imageAttachmentDataUri(result, "before-canvas");
|
| 45 |
const afterImage = await imageAttachmentDataUri(result, "after-texture-canvas");
|
| 46 |
const geminiAttachment = findAttachment(result, "gemini-judge");
|
|
@@ -121,6 +127,50 @@ function displayStatus(test, result) {
|
|
| 121 |
return testStatus || "unknown";
|
| 122 |
}
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
async function imageAttachmentDataUri(result, attachmentName) {
|
| 125 |
const attachment = findAttachment(result, attachmentName);
|
| 126 |
if (!attachment) return null;
|
|
|
|
| 41 |
|
| 42 |
for (const entry of entries) {
|
| 43 |
const result = finalResult(entry.test);
|
| 44 |
+
const groupedEntries = await groupedCaseEntries(entry, result);
|
| 45 |
+
if (groupedEntries.length) {
|
| 46 |
+
hydratedEntries.push(...groupedEntries);
|
| 47 |
+
continue;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
const beforeImage = await imageAttachmentDataUri(result, "before-canvas");
|
| 51 |
const afterImage = await imageAttachmentDataUri(result, "after-texture-canvas");
|
| 52 |
const geminiAttachment = findAttachment(result, "gemini-judge");
|
|
|
|
| 127 |
return testStatus || "unknown";
|
| 128 |
}
|
| 129 |
|
| 130 |
+
async function groupedCaseEntries(entry, result) {
|
| 131 |
+
const metas = await groupedCaseMetas(result);
|
| 132 |
+
const hydratedEntries = [];
|
| 133 |
+
|
| 134 |
+
for (const { meta, prefix } of metas) {
|
| 135 |
+
const beforeImage = await imageAttachmentDataUri(result, `${prefix}-before-canvas`);
|
| 136 |
+
const afterImage = await imageAttachmentDataUri(result, `${prefix}-after-texture-canvas`);
|
| 137 |
+
const geminiAttachment = findAttachment(result, `${prefix}-gemini-judge`);
|
| 138 |
+
const gemini = geminiAttachment ? parseJsonLoose(await readTextAttachment(geminiAttachment)) : null;
|
| 139 |
+
const imageTitle = meta.imageName || meta.roomName || imageName(entry.title);
|
| 140 |
+
const tileName = meta.tileName || "Unknown tile";
|
| 141 |
+
|
| 142 |
+
hydratedEntries.push({
|
| 143 |
+
...entry,
|
| 144 |
+
afterImage,
|
| 145 |
+
beforeImage,
|
| 146 |
+
gemini,
|
| 147 |
+
result,
|
| 148 |
+
status: typeof meta.status === "string" ? meta.status : displayStatus(entry.test, result),
|
| 149 |
+
title: `${imageTitle}: apply ${tileName}`,
|
| 150 |
+
});
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
return hydratedEntries;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
async function groupedCaseMetas(result) {
|
| 157 |
+
const metas = [];
|
| 158 |
+
for (const attachment of asArray(result.attachments)) {
|
| 159 |
+
const name = typeof attachment?.name === "string" ? attachment.name : "";
|
| 160 |
+
if (!name.startsWith("qa-case-") || !name.endsWith("-meta")) continue;
|
| 161 |
+
const meta = parseJsonLoose(await readTextAttachment(attachment));
|
| 162 |
+
if (!meta || typeof meta !== "object" || Array.isArray(meta)) continue;
|
| 163 |
+
metas.push({
|
| 164 |
+
meta,
|
| 165 |
+
prefix: typeof meta.attachmentPrefix === "string" && meta.attachmentPrefix
|
| 166 |
+
? meta.attachmentPrefix
|
| 167 |
+
: name.slice(0, -"-meta".length),
|
| 168 |
+
});
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
return metas.sort((left, right) => Number(left.meta.caseIndex ?? 0) - Number(right.meta.caseIndex ?? 0));
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
async function imageAttachmentDataUri(result, attachmentName) {
|
| 175 |
const attachment = findAttachment(result, attachmentName);
|
| 176 |
if (!attachment) return null;
|