fusiontest 0.2.27__tar.gz → 0.2.28__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.27 → fusiontest-0.2.28}/PKG-INFO +4 -1
  2. {fusiontest-0.2.27 → fusiontest-0.2.28}/README.md +3 -0
  3. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/cli.py +220 -0
  4. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/PKG-INFO +4 -1
  5. {fusiontest-0.2.27 → fusiontest-0.2.28}/pyproject.toml +1 -1
  6. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/__init__.py +0 -0
  7. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/__init__.py +0 -0
  8. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/sites/shop/bugs.js +0 -0
  9. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/sites/shop/help.html +0 -0
  10. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/sites/shop/index.html +0 -0
  11. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/suites/shop-bugs.yaml +0 -0
  12. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/suites/shop.yaml +0 -0
  13. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/bench/suites/todomvc.yaml +0 -0
  14. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/__init__.py +0 -0
  15. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/action_model.py +0 -0
  16. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/app_errors.py +0 -0
  17. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/bugs.py +0 -0
  18. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/goal_verifier.py +0 -0
  19. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/netguard.py +0 -0
  20. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/promise_checker.py +0 -0
  21. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/replay.py +0 -0
  22. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/reproduce.py +0 -0
  23. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/runner.py +0 -0
  24. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/screen_parser.py +0 -0
  25. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/secrets.py +0 -0
  26. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/shared_traces.py +0 -0
  27. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/core/tokens.py +0 -0
  28. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/__init__.py +0 -0
  29. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/fusiontest_dashboard.yaml +0 -0
  30. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/github.yaml +0 -0
  31. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/hacker_news.yaml +0 -0
  32. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/httpbin.yaml +0 -0
  33. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/todomvc.yaml +0 -0
  34. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/demos/wikipedia.yaml +0 -0
  35. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/desktop/__init__.py +0 -0
  36. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/desktop/macos_adapter.py +0 -0
  37. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/desktop/playwright_adapter.py +0 -0
  38. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/desktop/windows_adapter.py +0 -0
  39. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/discovery/__init__.py +0 -0
  40. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/discovery/goal_generator.py +0 -0
  41. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/guardrails/__init__.py +0 -0
  42. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/guardrails/engine.py +0 -0
  43. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/mobile/__init__.py +0 -0
  44. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/mobile/android_adapter.py +0 -0
  45. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/mobile/ios_adapter.py +0 -0
  46. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/reporting/__init__.py +0 -0
  47. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/reporting/reporter.py +0 -0
  48. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/training/__init__.py +0 -0
  49. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/training/data_collector.py +0 -0
  50. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/training/dataset_builder.py +0 -0
  51. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest/training/trainer.py +0 -0
  52. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/SOURCES.txt +0 -0
  53. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/dependency_links.txt +0 -0
  54. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/entry_points.txt +0 -0
  55. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/not-zip-safe +0 -0
  56. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/requires.txt +0 -0
  57. {fusiontest-0.2.27 → fusiontest-0.2.28}/fusiontest.egg-info/top_level.txt +0 -0
  58. {fusiontest-0.2.27 → fusiontest-0.2.28}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusiontest
3
- Version: 0.2.27
3
+ Version: 0.2.28
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
@@ -143,6 +143,9 @@ export GROQ_API_KEY=gsk_... # or ANTHROPIC_API_KEY / GEMINI_API_KEY / O
143
143
 
144
144
  fusiontest run --url https://example.com \
145
145
  --goal "Verify the page heading says Example Domain" --headless
146
+
147
+ # No goals yet? Map what works on a test/staging site, and save the flows that do
148
+ fusiontest scan https://staging.example.com --save fusiontest.goals.yaml
146
149
  ```
147
150
 
148
151
  Groq, OpenAI and Ollama work out of the box; for Claude or Gemini add the
@@ -64,6 +64,9 @@ export GROQ_API_KEY=gsk_... # or ANTHROPIC_API_KEY / GEMINI_API_KEY / O
64
64
 
65
65
  fusiontest run --url https://example.com \
66
66
  --goal "Verify the page heading says Example Domain" --headless
67
+
68
+ # No goals yet? Map what works on a test/staging site, and save the flows that do
69
+ fusiontest scan https://staging.example.com --save fusiontest.goals.yaml
67
70
  ```
68
71
 
69
72
  Groq, OpenAI and Ollama work out of the box; for Claude or Gemini add the
@@ -263,6 +263,225 @@ def run(goal, goal_file, platform, app, url, locale, backend, headless, output,
263
263
  sys.exit(_exit_code(result))
264
264
 
265
265
 
266
+ # ── scan (ADR-009) ────────────────────────────────────────────────────────────
267
+
268
+ DEFAULT_SCAN_GOALS = "fusiontest.goals.yaml"
269
+ _LOCAL_SUFFIXES = (".localhost", ".test", ".local", ".internal")
270
+
271
+
272
+ def _is_local_host(host: str) -> bool:
273
+ host = (host or "").lower().strip("[]")
274
+ return host in ("localhost", "127.0.0.1", "::1") or host.endswith(_LOCAL_SUFFIXES)
275
+
276
+
277
+ @main.command()
278
+ @click.argument("url")
279
+ @click.option("--max-flows", type=click.IntRange(1, 30), default=10, show_default=True,
280
+ help="How many flows to discover and check")
281
+ @click.option("--find-bugs", is_flag=True,
282
+ help="Beta: also look for bugs (crashes, server errors, dead links, broken promises), "
283
+ "each confirmed in fresh browser sessions before it's reported")
284
+ @click.option("--backend", type=click.Choice(["gpt4o", "claude", "gemini", "groq", "ollama"]),
285
+ default="gpt4o", show_default=True, help="AI model backend")
286
+ @click.option("--headless/--no-headless", default=True, show_default=True)
287
+ @click.option("--save", "save_path", type=click.Path(dir_okay=False), default=None,
288
+ help=f"Save the flows that work to this goals file (default: ask; {DEFAULT_SCAN_GOALS})")
289
+ @click.option("--yes", "-y", is_flag=True,
290
+ help="Don't ask before scanning a site that isn't local")
291
+ @click.option("--output", "-o", type=click.Path(), help="Write JSON report to this path")
292
+ @click.option("--config", "config_file", type=click.Path(), default=None,
293
+ help="Config file (default: fusiontest.config.yaml if present)")
294
+ def scan(url, max_flows, find_bugs, backend, headless, save_path, yes, output, config_file):
295
+ """Map what works on a site: discover its flows, run each one, report the result.
296
+
297
+ \b
298
+ Scan clicks buttons and submits forms, like a user would. Point it at a
299
+ test or staging site, not production. With --find-bugs (beta) it also
300
+ reports bugs it can confirm. Flows that work can be saved as a goals file
301
+ and run on every deploy with `fusiontest run -f`.
302
+
303
+ \b
304
+ Examples:
305
+ fusiontest scan https://staging.example.com
306
+ fusiontest scan http://localhost:3000 --find-bugs --save fusiontest.goals.yaml
307
+ """
308
+ from urllib.parse import urlsplit
309
+
310
+ from fusiontest.core.runner import FusionTestRunner, RunnerConfig
311
+ from fusiontest.discovery.goal_generator import (
312
+ GoalGenerationError,
313
+ GoalGenerator,
314
+ GoalGeneratorConfig,
315
+ )
316
+
317
+ _load_env()
318
+ if not urlsplit(url).scheme:
319
+ url = f"https://{url}"
320
+ host = urlsplit(url).hostname or url
321
+ config_path = Path(config_file) if config_file else Path("fusiontest.config.yaml")
322
+ cfg = (yaml.safe_load(config_path.read_text()) or {}) if config_path.exists() else {}
323
+ backend = _resolve_backend(backend, cfg)
324
+
325
+ # Exploration is real: it clicks, types and submits.
326
+ if not _is_local_host(host) and not yes:
327
+ if not sys.stdin.isatty():
328
+ console.print(f"[red]Not scanning {escape(host)}:[/red] scan clicks buttons and submits forms. "
329
+ "Use a test or staging site, and pass --yes to confirm.")
330
+ sys.exit(1)
331
+ if not click.confirm(f"Scan clicks buttons and submits forms on {host}, like a user would. "
332
+ "Is this a test or staging site?", default=False):
333
+ sys.exit(1)
334
+
335
+ console.print()
336
+ console.print(Panel.fit(
337
+ f"[bold]FusionTest scan[/bold] {escape(url)}\n"
338
+ f"Backend: [cyan]{backend}[/cyan] · Bug finding: "
339
+ + ("[cyan]on (beta)[/cyan]" if find_bugs else "off"),
340
+ border_style="blue",
341
+ ))
342
+
343
+ # 1. Discover flows grounded in the site's content.
344
+ with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"),
345
+ console=console) as progress:
346
+ progress.add_task("Reading the site and finding flows to check...", total=None)
347
+ try:
348
+ flows = GoalGenerator(GoalGeneratorConfig(max_goals=max_flows)).generate(
349
+ url, preferred_backend=backend)
350
+ except GoalGenerationError as exc:
351
+ console.print(f"[red]Couldn't discover flows:[/red] {escape(str(exc))}")
352
+ sys.exit(2)
353
+ console.print(f"\n[bold]Flows to check ({len(flows)}):[/bold]")
354
+ for i, flow in enumerate(flows, 1):
355
+ console.print(f" {i}. {escape(flow.name)} [dim]— {escape(flow.text)}[/dim]")
356
+ console.print()
357
+
358
+ # 2. Run each flow from the start page. Every flow goes through the AI and
359
+ # is recorded, so the ones that work can be replayed when watched.
360
+ replay_cfg = cfg.get("replay") or {}
361
+ trace_dir = Path(replay_cfg.get("trace_dir") or DEFAULT_TRACE_DIR)
362
+ runner = FusionTestRunner(_build_adapter("playwright", None, url, headless), RunnerConfig(
363
+ backend=backend,
364
+ screenshot_on_failure=True,
365
+ trace_store=_trace_store(trace_dir, bool(replay_cfg.get("shared", True))),
366
+ reverify_every=0,
367
+ detect_bugs=find_bugs,
368
+ fresh_adapter=(lambda: _build_adapter("playwright", None, url, True)) if find_bugs else None,
369
+ ))
370
+ with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"),
371
+ console=console) as progress:
372
+ progress.add_task("Checking each flow" + (" and looking for bugs" if find_bugs else "") + "...",
373
+ total=None)
374
+ try:
375
+ result = runner.run(goals=[f.text for f in flows], name=f"Scan: {host}",
376
+ platform="playwright", url=url)
377
+ finally:
378
+ stop = getattr(runner.adapter, "stop", None)
379
+ if callable(stop):
380
+ try:
381
+ stop()
382
+ except Exception: # noqa: BLE001
383
+ pass
384
+
385
+ # 3. Coverage map, then bugs.
386
+ shot_dir = Path(cfg.get("screenshots", {}).get("dir", DEFAULT_SCREENSHOT_DIR))
387
+ bug_shots = _save_bug_screenshots(result, shot_dir)
388
+ working = _print_coverage(flows, result)
389
+ if find_bugs:
390
+ _print_bugs(result, bug_shots)
391
+ else:
392
+ console.print("\n[dim]Tip: add --find-bugs (beta) to also look for bugs while scanning.[/dim]")
393
+ if result.error:
394
+ console.print(f"\n[yellow]Scan stopped early:[/yellow] {escape(result.error)}")
395
+
396
+ if output:
397
+ _save_report(result, output)
398
+ console.print(f"\n[dim]Report saved to: {output}[/dim]")
399
+ uploaded_run_id = _upload_report(result)
400
+ if uploaded_run_id and bug_shots and cfg.get("screenshots", {}).get("upload", True):
401
+ _upload_screenshots(uploaded_run_id, bug_shots, kind="bug")
402
+
403
+ # 4. Offer to watch the flows that work.
404
+ if working:
405
+ _offer_to_watch(url, working, save_path)
406
+
407
+
408
+ def _print_coverage(flows, result) -> list:
409
+ """The coverage map: each flow and whether it works. Returns the flows that do."""
410
+ table = Table(title="Coverage", header_style="bold", box=None, pad_edge=False, title_justify="left")
411
+ table.add_column("#", style="dim", width=3)
412
+ table.add_column("Flow", min_width=24)
413
+ table.add_column("Result", width=16)
414
+ table.add_column("Steps", width=6)
415
+ working = []
416
+ for i, flow in enumerate(flows):
417
+ step = result.steps[i] if i < len(result.steps) else None
418
+ if step is None:
419
+ cell = "[dim]not checked[/dim]"
420
+ elif step.success:
421
+ cell = "[green]works[/green]"
422
+ working.append(flow)
423
+ elif step.infra_error:
424
+ cell = "[yellow]couldn't check[/yellow]"
425
+ else:
426
+ cell = "[red]didn't complete[/red]"
427
+ failed_why = step is not None and not step.success and step.error
428
+ note = f"\n [dim]{escape(step.error[:160])}[/dim]" if failed_why else ""
429
+ table.add_row(str(i + 1), escape(flow.name) + note, cell, str(step.steps_taken) if step else "—")
430
+ console.print(table)
431
+ console.print(f"\n[bold]{len(working)} of {len(flows)} flows work.[/bold] "
432
+ "[dim]A flow that didn't complete may be a bug in the site or a step FusionTest "
433
+ "couldn't work out; the reason is shown under it.[/dim]")
434
+ return working
435
+
436
+
437
+ def _print_bugs(result, bug_shots: dict[int, Path]) -> None:
438
+ console.print()
439
+ if not result.bugs_detected:
440
+ console.print("[green]No bugs confirmed.[/green] [dim](Bug finding is in beta.)[/dim]")
441
+ if result.unconfirmed_bugs:
442
+ console.print(f"[dim]{len(result.unconfirmed_bugs)} suspected bug(s) didn't happen again in a "
443
+ "fresh session, so they're not reported.[/dim]")
444
+ return
445
+ console.print(f"[bold red]Bugs found ({len(result.bugs_detected)})[/bold red] "
446
+ "[dim]— beta: each was confirmed in fresh sessions; precision is still being "
447
+ "measured on our benchmark[/dim]")
448
+ for i, bug in enumerate(result.bugs_detected):
449
+ console.print(f"\n {i + 1}. {escape(bug.title)}", soft_wrap=True)
450
+ if bug.expected or bug.actual:
451
+ console.print(f" [dim]Expected:[/dim] {escape(bug.expected or '—')}")
452
+ console.print(f" [dim]Actual:[/dim] {escape(bug.actual or '—')}")
453
+ if bug.steps:
454
+ console.print(f" [dim]Steps to reproduce ({len(bug.steps)}):[/dim]")
455
+ for n, step in enumerate(bug.steps, 1):
456
+ console.print(f" {n}. {escape(step)}", soft_wrap=True)
457
+ if i in bug_shots:
458
+ console.print(f" [dim]Screenshot: {escape(str(bug_shots[i]))}[/dim]", soft_wrap=True)
459
+
460
+
461
+ def _offer_to_watch(url: str, working: list, save_path: str | None) -> None:
462
+ """Save the flows that work as a goals file, to run on every deploy."""
463
+ path = Path(save_path) if save_path else None
464
+ if path is None:
465
+ if not sys.stdin.isatty():
466
+ console.print(f"\n[dim]Save these {len(working)} working flows with --save {DEFAULT_SCAN_GOALS} "
467
+ "to run them on every deploy.[/dim]")
468
+ return
469
+ if not click.confirm(f"\nWatch these {len(working)} working flows? Save them to {DEFAULT_SCAN_GOALS}",
470
+ default=True):
471
+ return
472
+ path = Path(DEFAULT_SCAN_GOALS)
473
+ if path.exists() and not click.confirm(f"{path} exists. Replace it?", default=False):
474
+ return
475
+ data = {"url": url, "goals": [{"name": f.name, "goal": f.text} for f in working]}
476
+ path.write_text("# Flows that worked when FusionTest scanned this site.\n"
477
+ "# Run them on every deploy: fusiontest run -f " + str(path) + "\n"
478
+ + yaml.safe_dump(data, sort_keys=False, allow_unicode=True))
479
+ console.print(f"\n[green]✓[/green] Saved {len(working)} flow(s) to [cyan]{escape(str(path))}[/cyan]. "
480
+ "Run them on every deploy; they replay from their recordings, without AI calls, "
481
+ "until the site changes:")
482
+ console.print(f" [bold]fusiontest run -f {escape(str(path))}[/bold]", soft_wrap=True)
483
+
484
+
266
485
  def _save_screenshots(result, root: Path) -> dict[int, Path]:
267
486
  """Write each failed goal's screenshot to <root>/<time>/<NN>-<goal>.png.
268
487
  Returns {goal index: path}."""
@@ -1147,6 +1366,7 @@ def _save_report(result, path: str) -> None:
1147
1366
  "stability_score": result.stability_score,
1148
1367
  "total_duration_seconds": result.total_duration_seconds,
1149
1368
  "steps": [s.to_dict() for s in result.steps],
1369
+ "bugs_detected": [b.to_dict() for b in result.bugs_detected],
1150
1370
  }
1151
1371
  with open(path, "w") as f:
1152
1372
  json.dump(data, f, indent=2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fusiontest
3
- Version: 0.2.27
3
+ Version: 0.2.28
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
@@ -143,6 +143,9 @@ export GROQ_API_KEY=gsk_... # or ANTHROPIC_API_KEY / GEMINI_API_KEY / O
143
143
 
144
144
  fusiontest run --url https://example.com \
145
145
  --goal "Verify the page heading says Example Domain" --headless
146
+
147
+ # No goals yet? Map what works on a test/staging site, and save the flows that do
148
+ fusiontest scan https://staging.example.com --save fusiontest.goals.yaml
146
149
  ```
147
150
 
148
151
  Groq, OpenAI and Ollama work out of the box; for Claude or Gemini add the
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fusiontest"
7
- version = "0.2.27"
7
+ version = "0.2.28"
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