fusiontest 0.2.26__tar.gz → 0.2.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. {fusiontest-0.2.26 → fusiontest-0.2.27}/PKG-INFO +1 -1
  2. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/cli.py +45 -11
  3. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/bugs.py +6 -1
  4. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/runner.py +16 -3
  5. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/PKG-INFO +1 -1
  6. {fusiontest-0.2.26 → fusiontest-0.2.27}/pyproject.toml +1 -1
  7. {fusiontest-0.2.26 → fusiontest-0.2.27}/README.md +0 -0
  8. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/__init__.py +0 -0
  9. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/__init__.py +0 -0
  10. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/sites/shop/bugs.js +0 -0
  11. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/sites/shop/help.html +0 -0
  12. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/sites/shop/index.html +0 -0
  13. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/suites/shop-bugs.yaml +0 -0
  14. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/suites/shop.yaml +0 -0
  15. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/bench/suites/todomvc.yaml +0 -0
  16. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/__init__.py +0 -0
  17. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/action_model.py +0 -0
  18. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/app_errors.py +0 -0
  19. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/goal_verifier.py +0 -0
  20. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/netguard.py +0 -0
  21. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/promise_checker.py +0 -0
  22. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/replay.py +0 -0
  23. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/reproduce.py +0 -0
  24. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/screen_parser.py +0 -0
  25. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/secrets.py +0 -0
  26. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/shared_traces.py +0 -0
  27. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/core/tokens.py +0 -0
  28. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/__init__.py +0 -0
  29. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/fusiontest_dashboard.yaml +0 -0
  30. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/github.yaml +0 -0
  31. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/hacker_news.yaml +0 -0
  32. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/httpbin.yaml +0 -0
  33. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/todomvc.yaml +0 -0
  34. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/demos/wikipedia.yaml +0 -0
  35. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/desktop/__init__.py +0 -0
  36. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/desktop/macos_adapter.py +0 -0
  37. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/desktop/playwright_adapter.py +0 -0
  38. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/desktop/windows_adapter.py +0 -0
  39. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/discovery/__init__.py +0 -0
  40. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/discovery/goal_generator.py +0 -0
  41. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/guardrails/__init__.py +0 -0
  42. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/guardrails/engine.py +0 -0
  43. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/mobile/__init__.py +0 -0
  44. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/mobile/android_adapter.py +0 -0
  45. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/mobile/ios_adapter.py +0 -0
  46. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/reporting/__init__.py +0 -0
  47. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/reporting/reporter.py +0 -0
  48. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/training/__init__.py +0 -0
  49. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/training/data_collector.py +0 -0
  50. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/training/dataset_builder.py +0 -0
  51. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest/training/trainer.py +0 -0
  52. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/SOURCES.txt +0 -0
  53. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/dependency_links.txt +0 -0
  54. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/entry_points.txt +0 -0
  55. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/not-zip-safe +0 -0
  56. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/requires.txt +0 -0
  57. {fusiontest-0.2.26 → fusiontest-0.2.27}/fusiontest.egg-info/top_level.txt +0 -0
  58. {fusiontest-0.2.26 → fusiontest-0.2.27}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusiontest
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: AI-powered UI testing for mobile and desktop — by FusionLeap.io
5
5
  Author-email: FusionLeap <hello@fusionleap.io>
6
6
  License: MIT
@@ -230,10 +230,12 @@ def run(goal, goal_file, platform, app, url, locale, backend, headless, output,
230
230
  progress.stop()
231
231
 
232
232
  # Failure screenshots: saved next to the project, shown in the results.
233
- shots = _save_screenshots(result, Path(cfg.get("screenshots", {}).get("dir", DEFAULT_SCREENSHOT_DIR)))
233
+ shot_dir = Path(cfg.get("screenshots", {}).get("dir", DEFAULT_SCREENSHOT_DIR))
234
+ shots = _save_screenshots(result, shot_dir)
235
+ bug_shots = _save_bug_screenshots(result, shot_dir)
234
236
 
235
237
  # Print results table, then Slack / GitHub annotations if configured
236
- _print_results(result, shots)
238
+ _print_results(result, shots, bug_shots)
237
239
  _notify(result)
238
240
 
239
241
  # Save JSON report locally
@@ -243,8 +245,11 @@ def run(goal, goal_file, platform, app, url, locale, backend, headless, output,
243
245
 
244
246
  # Upload report to FusionTest dashboard
245
247
  uploaded_run_id = _upload_report(result)
246
- if uploaded_run_id and shots and cfg.get("screenshots", {}).get("upload", True):
247
- _upload_screenshots(uploaded_run_id, shots)
248
+ if uploaded_run_id and cfg.get("screenshots", {}).get("upload", True):
249
+ if shots:
250
+ _upload_screenshots(uploaded_run_id, shots)
251
+ if bug_shots:
252
+ _upload_screenshots(uploaded_run_id, bug_shots, kind="bug")
248
253
 
249
254
  # Upload step telemetry (best-effort, non-blocking)
250
255
  if _api_key and _step_log_tmp:
@@ -278,9 +283,28 @@ def _save_screenshots(result, root: Path) -> dict[int, Path]:
278
283
  return saved
279
284
 
280
285
 
281
- def _upload_screenshots(run_id: str, shots: dict[int, Path]) -> None:
282
- """Attach failure screenshots to the uploaded run (best effort). The org can
283
- turn storage off in the dashboard; screenshots are kept 30 days."""
286
+ def _save_bug_screenshots(result, root: Path) -> dict[int, Path]:
287
+ """Write each reported bug's screenshot (taken when it reproduced) to
288
+ <root>/<time>/bug-<NN>-<kind>.png. Returns {bug index: path}."""
289
+ from datetime import datetime, timezone
290
+
291
+ with_shots = [(i, b) for i, b in enumerate(result.bugs_detected) if b.screenshot]
292
+ if not with_shots:
293
+ return {}
294
+ run_dir = root / datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
295
+ run_dir.mkdir(parents=True, exist_ok=True)
296
+ saved: dict[int, Path] = {}
297
+ for i, bug in with_shots:
298
+ path = run_dir / f"bug-{i + 1:02d}-{bug.kind.replace('_', '-')}.png"
299
+ path.write_bytes(bug.screenshot)
300
+ saved[i] = path
301
+ return saved
302
+
303
+
304
+ def _upload_screenshots(run_id: str, shots: dict[int, Path], kind: str = "goal") -> None:
305
+ """Attach failure (kind="goal") or bug (kind="bug") screenshots to the
306
+ uploaded run (best effort). The org can turn storage off in the dashboard;
307
+ screenshots are kept 30 days."""
284
308
  import os
285
309
 
286
310
  import httpx
@@ -289,15 +313,17 @@ def _upload_screenshots(run_id: str, shots: dict[int, Path]) -> None:
289
313
  headers = {"Authorization": f"Bearer {os.getenv('FUSIONTEST_API_KEY', '')}", "Content-Type": "image/png"}
290
314
  stored = 0
291
315
  for index, path in shots.items():
316
+ url = (f"{api_url}/api/runs/{run_id}/bugs/{index}/screenshot" if kind == "bug"
317
+ else f"{api_url}/api/runs/{run_id}/screenshots/{index}")
292
318
  try:
293
- resp = httpx.post(f"{api_url}/api/runs/{run_id}/screenshots/{index}",
294
- content=path.read_bytes(), headers=headers, timeout=30)
319
+ resp = httpx.post(url, content=path.read_bytes(), headers=headers, timeout=30)
295
320
  resp.raise_for_status()
296
321
  stored += bool(resp.json().get("stored"))
297
322
  except Exception as e: # noqa: BLE001 — never fail a run over a screenshot
298
323
  console.print(f"[yellow]Warning:[/yellow] Could not upload screenshot {path.name}: {e}")
299
324
  if stored:
300
- console.print(f"[dim]{stored} failure screenshot(s) attached to the run (kept 30 days).[/dim]")
325
+ what = "bug" if kind == "bug" else "failure"
326
+ console.print(f"[dim]{stored} {what} screenshot(s) attached to the run (kept 30 days).[/dim]")
301
327
 
302
328
 
303
329
  def _load_env() -> None:
@@ -1038,7 +1064,8 @@ def _providers(result, fallback: str) -> str:
1038
1064
  return first + (f" (and {', '.join(names[1:])})" if len(names) > 1 else "")
1039
1065
 
1040
1066
 
1041
- def _print_results(result, screenshots: dict[int, Path] | None = None) -> None:
1067
+ def _print_results(result, screenshots: dict[int, Path] | None = None,
1068
+ bug_screenshots: dict[int, Path] | None = None) -> None:
1042
1069
  if result.success:
1043
1070
  status = "[green]PASS ✓[/green]"
1044
1071
  elif _exit_code(result) == 2:
@@ -1085,6 +1112,13 @@ def _print_results(result, screenshots: dict[int, Path] | None = None) -> None:
1085
1112
  # One line per path, never wrapped, so it can be copied or clicked.
1086
1113
  console.print(f" {index + 1}. {escape(str(path))}", soft_wrap=True)
1087
1114
 
1115
+ if result.bugs_detected:
1116
+ console.print(f"\n[bold red]Bugs found ({len(result.bugs_detected)})[/bold red]")
1117
+ for index, bug in enumerate(result.bugs_detected):
1118
+ console.print(f" {index + 1}. {escape(bug.title)}", soft_wrap=True)
1119
+ if bug_screenshots and index in bug_screenshots:
1120
+ console.print(f" [dim]screenshot: {escape(str(bug_screenshots[index]))}[/dim]", soft_wrap=True)
1121
+
1088
1122
  if result.error:
1089
1123
  console.print(f"\n[yellow]Run stopped early:[/yellow] {escape(result.error)}")
1090
1124
 
@@ -28,9 +28,14 @@ class Bug:
28
28
  evidence: list[str] = field(default_factory=list) # screen text, quoted
29
29
  steps: list[str] = field(default_factory=list) # to reproduce, from the start
30
30
  reproduced: int = 0 # fresh sessions it happened again in (0: not checked)
31
+ # PNG of the screen when it happened again in a fresh session (not in to_dict:
32
+ # uploaded separately).
33
+ screenshot: bytes | None = field(default=None, repr=False, compare=False)
31
34
 
32
35
  def to_dict(self) -> dict:
33
- return asdict(self)
36
+ data = asdict(self)
37
+ data.pop("screenshot")
38
+ return data
34
39
 
35
40
  def __str__(self) -> str:
36
41
  return self.title
@@ -789,6 +789,7 @@ class FusionTestRunner:
789
789
  return Reproduction(confirmed=list(candidates), unconfirmed=[])
790
790
  still = list(range(len(candidates)))
791
791
  sessions = 0
792
+ shots: dict[int, bytes] = {} # id(candidate) -> screen when it happened again
792
793
  for attempt in range(1, self.config.reproduce_times + 1):
793
794
  if not still:
794
795
  break
@@ -802,7 +803,7 @@ class FusionTestRunner:
802
803
  break
803
804
  sessions += 1
804
805
  try:
805
- seen = self._replay_log(adapter, [candidates[i] for i in still], resolver)
806
+ seen = self._replay_log(adapter, [candidates[i] for i in still], resolver, shots)
806
807
  finally:
807
808
  stop = getattr(adapter, "stop", None)
808
809
  if callable(stop):
@@ -812,14 +813,17 @@ class FusionTestRunner:
812
813
  pass
813
814
  still = [i for i in still if id(candidates[i]) in seen]
814
815
  confirmed = [candidates[i] for i in still]
816
+ for c in confirmed:
817
+ c.bug.screenshot = shots.get(id(c))
815
818
  unconfirmed = [c for c in candidates if c not in confirmed]
816
819
  for c in unconfirmed:
817
820
  logger.info(" Not reproduced, not reported: %s", c.report)
818
821
  return Reproduction(confirmed=confirmed, unconfirmed=unconfirmed, sessions=sessions)
819
822
 
820
823
  def _replay_log(self, adapter: object, candidates: list[BugCandidate],
821
- resolver: SecretResolver) -> set[int]:
822
- """Replay the action log on adapter; ids of the candidates that showed up again."""
824
+ resolver: SecretResolver, shots: dict[int, bytes] | None = None) -> set[int]:
825
+ """Replay the action log on adapter; ids of the candidates that showed up again.
826
+ shots: filled with a screenshot of each one at that moment."""
823
827
  seen: set[int] = set()
824
828
  errors: set[tuple[str, str]] = set()
825
829
  last = max(c.at for c in candidates)
@@ -850,6 +854,15 @@ class FusionTestRunner:
850
854
  seen.add(id(c))
851
855
  elif c.evidence and evidence_present(c.evidence, before + "\n" + after):
852
856
  seen.add(id(c))
857
+ if shots is not None and any(id(c) in seen for c in due):
858
+ try:
859
+ shot = adapter.get_screenshot()
860
+ except Exception: # noqa: BLE001 — a screenshot is a nice-to-have
861
+ shot = None
862
+ if shot:
863
+ for c in due:
864
+ if id(c) in seen:
865
+ shots[id(c)] = shot
853
866
 
854
867
  try:
855
868
  check(0, "")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusiontest
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: AI-powered UI testing for mobile and desktop — by FusionLeap.io
5
5
  Author-email: FusionLeap <hello@fusionleap.io>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fusiontest"
7
- version = "0.2.26"
7
+ version = "0.2.27"
8
8
  description = "AI-powered UI testing for mobile and desktop — by FusionLeap.io"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
File without changes
File without changes