qa-agent 0.3.0__tar.gz → 0.3.1__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 (85) hide show
  1. {qa_agent-0.3.0/qa_agent.egg-info → qa_agent-0.3.1}/PKG-INFO +7 -29
  2. {qa_agent-0.3.0 → qa_agent-0.3.1}/pyproject.toml +10 -9
  3. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/__init__.py +1 -1
  4. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/agent.py +33 -2
  5. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/cli.py +12 -2
  6. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/config.py +4 -1
  7. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/models.py +36 -0
  8. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/reporters/json_reporter.py +1 -0
  9. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/reporters/markdown.py +54 -1
  10. qa_agent-0.3.1/qa_agent/summarizer.py +165 -0
  11. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/accessibility.py +2 -1
  12. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/errors.py +3 -2
  13. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/keyboard.py +4 -2
  14. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/mouse.py +2 -1
  15. {qa_agent-0.3.0 → qa_agent-0.3.1/qa_agent.egg-info}/PKG-INFO +7 -29
  16. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent.egg-info/SOURCES.txt +2 -16
  17. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent.egg-info/requires.txt +5 -5
  18. qa_agent-0.3.1/qa_agent.egg-info/top_level.txt +1 -0
  19. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_agent.py +5 -5
  20. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_batch.py +3 -1
  21. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_concurrency.py +1 -1
  22. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_config.py +1 -1
  23. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_packaging.py +8 -1
  24. qa_agent-0.3.1/tests/test_summarizer.py +369 -0
  25. qa_agent-0.3.0/qa_agent.egg-info/top_level.txt +0 -4
  26. qa_agent-0.3.0/tests/__init__.py +0 -0
  27. qa_agent-0.3.0/tests/_cli_exit_helper.py +0 -63
  28. qa_agent-0.3.0/tests/conftest.py +0 -211
  29. qa_agent-0.3.0/tests/integration/__init__.py +0 -0
  30. qa_agent-0.3.0/tests/integration/test_smoke.py +0 -232
  31. qa_agent-0.3.0/tests/integration/test_target_coverage.py +0 -80
  32. qa_agent-0.3.0/tests/testers/__init__.py +0 -0
  33. qa_agent-0.3.0/tests/testers/test_accessibility.py +0 -187
  34. qa_agent-0.3.0/tests/testers/test_base.py +0 -186
  35. qa_agent-0.3.0/tests/testers/test_custom.py +0 -410
  36. qa_agent-0.3.0/tests/testers/test_errors.py +0 -526
  37. qa_agent-0.3.0/tests/testers/test_forms.py +0 -762
  38. qa_agent-0.3.0/tests/testers/test_keyboard.py +0 -365
  39. qa_agent-0.3.0/tests/testers/test_mouse.py +0 -552
  40. qa_agent-0.3.0/tests/web/__init__.py +0 -0
  41. qa_agent-0.3.0/tests/web/test_server.py +0 -651
  42. {qa_agent-0.3.0 → qa_agent-0.3.1}/LICENSE +0 -0
  43. {qa_agent-0.3.0 → qa_agent-0.3.1}/README.md +0 -0
  44. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/__main__.py +0 -0
  45. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/ai_planner.py +0 -0
  46. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/batch.py +0 -0
  47. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/concurrency.py +0 -0
  48. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/llm_client.py +0 -0
  49. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/plan_cache.py +0 -0
  50. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/playwright_utils.py +0 -0
  51. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/rate_limiter.py +0 -0
  52. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/reporters/__init__.py +0 -0
  53. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/reporters/base.py +0 -0
  54. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/reporters/console.py +0 -0
  55. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/reporters/pdf.py +0 -0
  56. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/__init__.py +0 -0
  57. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/base.py +0 -0
  58. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/custom.py +0 -0
  59. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/forms.py +0 -0
  60. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/testers/wcag_compliance.py +0 -0
  61. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/__init__.py +0 -0
  62. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/server.py +0 -0
  63. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/static/app.js +0 -0
  64. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/static/index.js +0 -0
  65. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/static/run.js +0 -0
  66. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/static/session.js +0 -0
  67. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/static/sessions.js +0 -0
  68. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/static/style.css +0 -0
  69. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/templates/base.html +0 -0
  70. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/templates/index.html +0 -0
  71. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/templates/run.html +0 -0
  72. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/templates/session.html +0 -0
  73. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent/web/templates/sessions.html +0 -0
  74. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent.egg-info/dependency_links.txt +0 -0
  75. {qa_agent-0.3.0 → qa_agent-0.3.1}/qa_agent.egg-info/entry_points.txt +0 -0
  76. {qa_agent-0.3.0 → qa_agent-0.3.1}/setup.cfg +0 -0
  77. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_ai_planner.py +0 -0
  78. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_cli.py +0 -0
  79. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_llm_client.py +0 -0
  80. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_models.py +0 -0
  81. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_plan_cache.py +0 -0
  82. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_plan_warnings.py +0 -0
  83. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_playwright_utils.py +0 -0
  84. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_rate_limiter.py +0 -0
  85. {qa_agent-0.3.0 → qa_agent-0.3.1}/tests/test_reporters.py +0 -0
@@ -1,30 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qa-agent
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Agentic exploratory QA testing for web applications
5
5
  Author: Bill Richards
6
- License: MIT License
7
-
8
- Copyright (c) 2026 Bill Richards
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
6
+ License-Expression: MIT
28
7
  Project-URL: Homepage, https://github.com/billrichards/qa-agent
29
8
  Project-URL: Repository, https://github.com/billrichards/qa-agent
30
9
  Project-URL: Documentation, https://github.com/billrichards/qa-agent/blob/main/docs/README.md
@@ -33,7 +12,6 @@ Project-URL: Changelog, https://github.com/billrichards/qa-agent/blob/main/CHANG
33
12
  Keywords: qa,testing,playwright,accessibility,agentic,automation,exploratory-testing
34
13
  Classifier: Development Status :: 3 - Alpha
35
14
  Classifier: Intended Audience :: Developers
36
- Classifier: License :: OSI Approved :: MIT License
37
15
  Classifier: Programming Language :: Python :: 3
38
16
  Classifier: Programming Language :: Python :: 3.10
39
17
  Classifier: Programming Language :: Python :: 3.11
@@ -46,18 +24,18 @@ Description-Content-Type: text/markdown
46
24
  License-File: LICENSE
47
25
  Requires-Dist: playwright>=1.40.0
48
26
  Provides-Extra: pdf
49
- Requires-Dist: weasyprint>=60.0; extra == "pdf"
27
+ Requires-Dist: weasyprint>=70.0; extra == "pdf"
50
28
  Provides-Extra: web
51
- Requires-Dist: flask>=3.0; extra == "web"
52
- Requires-Dist: markdown>=3.5; extra == "web"
29
+ Requires-Dist: flask>=3.1.3; extra == "web"
30
+ Requires-Dist: markdown>=3.8.1; extra == "web"
53
31
  Requires-Dist: nh3>=0.2.15; extra == "web"
54
32
  Provides-Extra: dev
55
- Requires-Dist: pytest>=8.0.0; extra == "dev"
33
+ Requires-Dist: pytest>=9.0.3; extra == "dev"
56
34
  Requires-Dist: pytest-playwright>=0.4.0; extra == "dev"
57
35
  Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
58
36
  Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
59
37
  Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
60
- Requires-Dist: black>=23.0.0; extra == "dev"
38
+ Requires-Dist: black>=26.10.1; extra == "dev"
61
39
  Requires-Dist: ruff>=0.4.0; extra == "dev"
62
40
  Requires-Dist: mypy>=1.0.0; extra == "dev"
63
41
  Requires-Dist: build>=1.0.0; extra == "dev"
@@ -1,20 +1,20 @@
1
1
  [build-system]
2
- requires = ["setuptools>=68", "wheel"]
2
+ requires = ["setuptools>=84.1.0", "wheel>=0.46.2"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qa-agent"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "Agentic exploratory QA testing for web applications"
9
9
  readme = "README.md"
10
- license = {file = "LICENSE"}
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
11
12
  requires-python = ">=3.10"
12
13
  authors = [{name = "Bill Richards"}]
13
14
  keywords = ["qa", "testing", "playwright", "accessibility", "agentic", "automation", "exploratory-testing"]
14
15
  classifiers = [
15
16
  "Development Status :: 3 - Alpha",
16
17
  "Intended Audience :: Developers",
17
- "License :: OSI Approved :: MIT License",
18
18
  "Programming Language :: Python :: 3",
19
19
  "Programming Language :: Python :: 3.10",
20
20
  "Programming Language :: Python :: 3.11",
@@ -29,20 +29,20 @@ dependencies = [
29
29
 
30
30
  [project.optional-dependencies]
31
31
  pdf = [
32
- "weasyprint>=60.0",
32
+ "weasyprint>=70.0",
33
33
  ]
34
34
  web = [
35
- "flask>=3.0",
36
- "markdown>=3.5",
35
+ "flask>=3.1.3",
36
+ "markdown>=3.8.1",
37
37
  "nh3>=0.2.15",
38
38
  ]
39
39
  dev = [
40
- "pytest>=8.0.0",
40
+ "pytest>=9.0.3",
41
41
  "pytest-playwright>=0.4.0",
42
42
  "pytest-cov>=5.0.0",
43
43
  "pytest-mock>=3.10.0",
44
44
  "pytest-xdist>=3.0.0",
45
- "black>=23.0.0",
45
+ "black>=26.10.1",
46
46
  "ruff>=0.4.0",
47
47
  "mypy>=1.0.0",
48
48
  "build>=1.0.0",
@@ -64,6 +64,7 @@ Changelog = "https://github.com/billrichards/qa-agent/blob/main/CHANGELOG.md"
64
64
 
65
65
  [tool.setuptools.packages.find]
66
66
  where = ["."]
67
+ include = ["qa_agent*"]
67
68
 
68
69
  [tool.setuptools.package-data]
69
70
  "qa_agent.web" = ["templates/*.html", "static/*"]
@@ -11,7 +11,7 @@ try:
11
11
  __version__ = version("qa-agent")
12
12
  except PackageNotFoundError:
13
13
  # Package not installed (e.g. running from source without install)
14
- __version__ = "0.3.0"
14
+ __version__ = "0.3.1"
15
15
 
16
16
  from .agent import QAAgent # noqa: E402
17
17
  from .batch import BatchJob, BatchRunner # noqa: E402
@@ -170,6 +170,10 @@ class QAAgent:
170
170
 
171
171
  self.session.end_time = datetime.now()
172
172
 
173
+ # Post-run LLM summary (opt-in)
174
+ if self.config.generate_summary:
175
+ self._generate_summary()
176
+
173
177
  # Generate reports
174
178
  self._generate_reports()
175
179
 
@@ -186,6 +190,9 @@ class QAAgent:
186
190
  from .llm_client import LLMError
187
191
  from .plan_cache import PlanCache
188
192
 
193
+ assert self.session is not None
194
+ assert self.config.instructions is not None
195
+
189
196
  cache = PlanCache() if self.config.use_plan_cache else None
190
197
  cache_key = PlanCache.make_key(self.config.instructions, self.config.urls) if cache else None
191
198
 
@@ -232,6 +239,7 @@ class QAAgent:
232
239
 
233
240
  def _apply_test_plan(self):
234
241
  """Print the test plan summary and enqueue any suggested URLs."""
242
+ assert self.test_plan is not None
235
243
  self.console.print_progress(f"Test plan: {self.test_plan.summary}")
236
244
  if self.test_plan.focus_areas:
237
245
  self.console.print_progress(
@@ -259,6 +267,25 @@ class QAAgent:
259
267
  if self.test_plan.notes:
260
268
  self.console.print_progress(f"Notes: {self.test_plan.notes}")
261
269
 
270
+ def _generate_summary(self):
271
+ """Call the LLM post-run to produce a narrative summary of findings."""
272
+ from .summarizer import generate_summary
273
+
274
+ assert self.session is not None
275
+ self.console.print_progress("Generating results summary with AI...")
276
+ result = generate_summary(
277
+ session=self.session,
278
+ provider=self.config.llm_provider,
279
+ model=self.config.ai_model,
280
+ )
281
+ if result:
282
+ self.session.summary = result
283
+ self.console.print_progress("AI summary complete.")
284
+ else:
285
+ self.console.print_progress(
286
+ "Warning: AI summary generation failed — continuing without it."
287
+ )
288
+
262
289
  def _factory(self):
263
290
  """Return the playwright context-manager factory (real or injected mock)."""
264
291
  return self._playwright_factory if self._playwright_factory is not None else sync_playwright
@@ -426,6 +453,7 @@ class QAAgent:
426
453
 
427
454
  # Discover new links
428
455
  if current_depth < self.config.max_depth:
456
+ assert self.page is not None
429
457
  new_links = self._discover_links(self.page, url)
430
458
  for link in new_links:
431
459
  new_url = link['href']
@@ -444,6 +472,7 @@ class QAAgent:
444
472
  is performed once on a bootstrap context and exported as a
445
473
  ``storage_state`` dict that seeds every worker context.
446
474
  """
475
+ assert self.session is not None
447
476
  storage_state = self._bootstrap_auth()
448
477
 
449
478
  if self.config.mode == TestMode.FOCUSED:
@@ -852,13 +881,14 @@ class QAAgent:
852
881
 
853
882
  def _cleanup(self):
854
883
  """Clean up browser resources."""
855
- if self.config.recording.enabled and self.context:
884
+ if self.config.recording.enabled and self.context and self.page:
856
885
  # Get video path
857
886
  try:
858
887
  video = self.page.video
859
888
  if video:
860
889
  video_path = video.path()
861
- self.session.recording_path = video_path
890
+ assert self.session is not None
891
+ self.session.recording_path = str(video_path)
862
892
  except Exception:
863
893
  pass
864
894
 
@@ -869,6 +899,7 @@ class QAAgent:
869
899
 
870
900
  def _generate_reports(self):
871
901
  """Generate all configured reports."""
902
+ assert self.session is not None
872
903
  for reporter in self.reporters:
873
904
  if isinstance(reporter, ConsoleReporter):
874
905
  reporter.generate(self.session)
@@ -23,7 +23,7 @@ def parse_auth_config(auth_str: str | None, auth_file: str | None) -> AuthConfig
23
23
  """Parse authentication configuration from string or file."""
24
24
  if auth_file:
25
25
  try:
26
- with open(auth_file) as f:
26
+ with open(auth_file, encoding="utf-8") as f:
27
27
  auth_data = json.load(f)
28
28
  return AuthConfig(**auth_data)
29
29
  except Exception as e:
@@ -309,6 +309,15 @@ Examples:
309
309
  action="store_true",
310
310
  help="Bypass the test plan cache and always call the AI. Only valid with --instructions or --instructions-file.",
311
311
  )
312
+ parser.add_argument(
313
+ "--summarize",
314
+ action="store_true",
315
+ help=(
316
+ "After the run, call the LLM once to produce a narrative summary: "
317
+ "executive summary, prioritised recommendations, root-cause clusters, "
318
+ "and likely false positives. Appended to Markdown and JSON reports."
319
+ ),
320
+ )
312
321
  args = parser.parse_args()
313
322
 
314
323
  # Validate: --no-cache requires instructions
@@ -354,7 +363,7 @@ Examples:
354
363
  # Handle cookies file
355
364
  if args.cookies:
356
365
  try:
357
- with open(args.cookies) as f:
366
+ with open(args.cookies, encoding="utf-8") as f:
358
367
  cookies = json.load(f)
359
368
  if auth_config:
360
369
  auth_config.cookies = cookies
@@ -422,6 +431,7 @@ Examples:
422
431
  llm_provider=LLMProvider(args.llm_provider),
423
432
  ai_model=args.ai_model or None,
424
433
  use_plan_cache=not args.no_cache,
434
+ generate_summary=args.summarize,
425
435
  workers=args.workers,
426
436
  rate_limit=args.rate_limit,
427
437
  invocation_context="cli",
@@ -30,7 +30,7 @@ class AuthConfig:
30
30
  username_selector: str | None = None # Selector for username field
31
31
  password_selector: str | None = None # Selector for password field
32
32
  submit_selector: str | None = None # Selector for submit button
33
- cookies: dict | None = None # Pre-set cookies for authentication
33
+ cookies: dict | list[dict] | None = None # Pre-set cookies for authentication
34
34
  headers: dict | None = None # Custom headers (e.g., Bearer token)
35
35
 
36
36
 
@@ -101,6 +101,9 @@ class TestConfig:
101
101
  ai_model: str | None = None # None → use the provider's default model
102
102
  use_plan_cache: bool = True # Cache generated test plans to avoid redundant API calls
103
103
 
104
+ # Post-run LLM summary: narrative analysis of findings after the run completes
105
+ generate_summary: bool = False
106
+
104
107
  # Invocation context — used to tailor diagnostic hints
105
108
  invocation_context: Literal["cli", "web"] | None = None
106
109
 
@@ -178,6 +178,40 @@ def _normalize_url(url: str) -> str:
178
178
  return normalised
179
179
 
180
180
 
181
+ @dataclass
182
+ class RootCauseCluster:
183
+ """A cluster of related findings sharing a common root cause."""
184
+ label: str
185
+ finding_titles: list[str]
186
+ root_cause: str
187
+ suggested_fix: str
188
+
189
+
190
+ @dataclass
191
+ class SummaryResult:
192
+ """LLM-generated narrative analysis produced after a test run."""
193
+ executive_summary: str
194
+ priority_recommendations: list[str] = field(default_factory=list)
195
+ root_cause_clusters: list[RootCauseCluster] = field(default_factory=list)
196
+ false_positive_candidates: list[str] = field(default_factory=list)
197
+
198
+ def to_dict(self) -> dict:
199
+ return {
200
+ "executive_summary": self.executive_summary,
201
+ "priority_recommendations": self.priority_recommendations,
202
+ "root_cause_clusters": [
203
+ {
204
+ "label": c.label,
205
+ "finding_titles": c.finding_titles,
206
+ "root_cause": c.root_cause,
207
+ "suggested_fix": c.suggested_fix,
208
+ }
209
+ for c in self.root_cause_clusters
210
+ ],
211
+ "false_positive_candidates": self.false_positive_candidates,
212
+ }
213
+
214
+
181
215
  @dataclass
182
216
  class TestSession:
183
217
  """Complete test session results."""
@@ -190,6 +224,7 @@ class TestSession:
190
224
  findings_by_severity: dict[str, int] = field(default_factory=dict)
191
225
  findings_by_category: dict[str, int] = field(default_factory=dict)
192
226
  recording_path: str | None = None
227
+ summary: "SummaryResult | None" = None
193
228
 
194
229
  def add_page_analysis(self, page: PageAnalysis):
195
230
  """Add page analysis and update totals."""
@@ -272,4 +307,5 @@ class TestSession:
272
307
  "recording_path": self.recording_path,
273
308
  "status": self.status,
274
309
  "findings": [f.to_dict() for f in self.get_deduplicated_findings()],
310
+ "summary": self.summary.to_dict() if self.summary else None,
275
311
  }
@@ -72,6 +72,7 @@ class JSONReporter(BaseReporter):
72
72
  for page in session.pages_tested
73
73
  ],
74
74
  "findings": [finding.to_dict() for finding in session.get_deduplicated_findings()],
75
+ "ai_summary": session.summary.to_dict() if session.summary else None,
75
76
  }
76
77
 
77
78
  def get_json_string(self, session: "TestSession") -> str:
@@ -8,7 +8,7 @@ from typing import TYPE_CHECKING
8
8
  from .base import BaseReporter
9
9
 
10
10
  if TYPE_CHECKING:
11
- from ..models import Finding, TestSession
11
+ from ..models import Finding, SummaryResult, TestSession
12
12
 
13
13
 
14
14
  class MarkdownReporter(BaseReporter):
@@ -80,6 +80,10 @@ class MarkdownReporter(BaseReporter):
80
80
  lines.append(f"| {emoji} {cat_name} | {count} |")
81
81
  lines.append("")
82
82
 
83
+ # AI summary section
84
+ if session.summary:
85
+ lines.extend(self._format_summary(session.summary))
86
+
83
87
  # Test reliability warnings
84
88
  plan_warnings = session.config_summary.get("plan_warnings", [])
85
89
  if plan_warnings:
@@ -171,6 +175,55 @@ class MarkdownReporter(BaseReporter):
171
175
 
172
176
  return "\n".join(lines)
173
177
 
178
+ def _format_summary(self, summary: "SummaryResult") -> list[str]:
179
+ """Format the AI summary block."""
180
+ lines: list[str] = []
181
+
182
+ lines.append("## AI Analysis")
183
+ lines.append("")
184
+ lines.append("> *Generated by LLM after the test run. Treat as advisory — verify before acting.*")
185
+ lines.append("")
186
+
187
+ lines.append("### Executive Summary")
188
+ lines.append("")
189
+ lines.append(summary.executive_summary)
190
+ lines.append("")
191
+
192
+ if summary.priority_recommendations:
193
+ lines.append("### Priority Recommendations")
194
+ lines.append("")
195
+ for rec in summary.priority_recommendations:
196
+ lines.append(f"1. {rec}")
197
+ lines.append("")
198
+
199
+ if summary.root_cause_clusters:
200
+ lines.append("### Root Cause Clusters")
201
+ lines.append("")
202
+ for cluster in summary.root_cause_clusters:
203
+ lines.append(f"#### {cluster.label}")
204
+ lines.append("")
205
+ lines.append(f"**Root cause:** {cluster.root_cause}")
206
+ lines.append("")
207
+ lines.append(f"**Suggested fix:** {cluster.suggested_fix}")
208
+ lines.append("")
209
+ lines.append("**Related findings:**")
210
+ for title in cluster.finding_titles:
211
+ lines.append(f"- {title}")
212
+ lines.append("")
213
+
214
+ if summary.false_positive_candidates:
215
+ lines.append("### Possible False Positives")
216
+ lines.append("")
217
+ lines.append(
218
+ "> These findings may be test artifacts rather than real bugs — review before filing."
219
+ )
220
+ lines.append("")
221
+ for candidate in summary.false_positive_candidates:
222
+ lines.append(f"- {candidate}")
223
+ lines.append("")
224
+
225
+ return lines
226
+
174
227
  def _escape_html_tags(self, text: str) -> str:
175
228
  """Wrap HTML tags in backticks so they render correctly in markdown previews.
176
229
 
@@ -0,0 +1,165 @@
1
+ """Post-run result summary via LLM.
2
+
3
+ After all testers complete, this module calls the LLM once with the full
4
+ findings list and produces a ``SummaryResult`` — a narrative analysis that
5
+ clusters related issues, identifies root causes, prioritises fixes, and flags
6
+ likely false positives.
7
+
8
+ The call is non-fatal: if the LLM is unavailable or returns unparseable output,
9
+ a warning is logged and ``None`` is returned so the rest of reporting continues.
10
+ """
11
+
12
+ import json
13
+ import logging
14
+
15
+ from .llm_client import LLMError, LLMProvider, create_llm_client
16
+ from .models import RootCauseCluster, SummaryResult, TestSession
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+ _SYSTEM_PROMPT = """You are a senior QA lead reviewing automated test results for a web application.
21
+
22
+ You will receive a JSON object describing a completed QA test session, including:
23
+ - Session metadata (pages tested, duration, URLs)
24
+ - Findings grouped by severity and category
25
+ - The full list of deduplicated findings with descriptions
26
+
27
+ Your job is to produce a concise, developer-facing summary of the results.
28
+
29
+ Return ONLY valid JSON matching this exact schema — no markdown, no commentary:
30
+
31
+ {
32
+ "executive_summary": "<2-3 sentence narrative: overall health, most important themes, what the developer should read first>",
33
+ "priority_recommendations": [
34
+ "<ordered list of specific, actionable fixes — most critical first, plain English>",
35
+ ...
36
+ ],
37
+ "root_cause_clusters": [
38
+ {
39
+ "label": "<short name for the cluster, e.g. 'Missing ARIA labels on icon buttons'>",
40
+ "finding_titles": ["<exact title from input>", ...],
41
+ "root_cause": "<why these are related — shared component, pattern, or missing practice>",
42
+ "suggested_fix": "<concrete engineering action to address the cluster>"
43
+ },
44
+ ...
45
+ ],
46
+ "false_positive_candidates": [
47
+ "<title of a finding that may be a test artifact rather than a real bug, with brief reason>",
48
+ ...
49
+ ]
50
+ }
51
+
52
+ Guidelines:
53
+ - executive_summary: be direct. If there are critical issues, lead with them.
54
+ - priority_recommendations: 3-6 items max. Focus on highest-impact fixes.
55
+ - root_cause_clusters: only create a cluster when 2+ findings genuinely share a root cause.
56
+ Skip this field (empty array) if all findings are independent.
57
+ - false_positive_candidates: conservative — only flag something if there is a clear signal
58
+ it is a test artifact (e.g. a navigation finding on a page that requires auth,
59
+ a console error that is a known third-party script, etc.). Empty array is fine.
60
+ - Keep language terse and actionable. Avoid padding and hedging."""
61
+
62
+
63
+ def _serialize_session(session: TestSession) -> str:
64
+ """Produce a compact JSON payload for the LLM from the completed session."""
65
+ findings = session.get_deduplicated_findings()
66
+ duration = None
67
+ if session.end_time:
68
+ duration = round((session.end_time - session.start_time).total_seconds(), 1)
69
+
70
+ payload = {
71
+ "pages_tested": len(session.pages_tested),
72
+ "duration_seconds": duration,
73
+ "urls": session.config_summary.get("urls", []),
74
+ "mode": session.config_summary.get("mode"),
75
+ "instructions": session.config_summary.get("instructions"),
76
+ "total_findings": session.total_findings,
77
+ "unique_findings": len(findings),
78
+ "findings_by_severity": session.findings_by_severity,
79
+ "findings_by_category": session.findings_by_category,
80
+ "findings": [
81
+ {
82
+ "title": f.title,
83
+ "severity": f.severity.value,
84
+ "category": f.category.value,
85
+ "description": f.description,
86
+ "url": f.url,
87
+ "affected_urls_count": len(f.affected_urls),
88
+ "element_selector": f.element_selector,
89
+ "expected_behavior": f.expected_behavior,
90
+ "actual_behavior": f.actual_behavior,
91
+ }
92
+ for f in findings
93
+ ],
94
+ }
95
+ return json.dumps(payload, default=str)
96
+
97
+
98
+ def _parse_summary(text: str) -> SummaryResult:
99
+ """Parse LLM JSON response into a SummaryResult."""
100
+ # Strip markdown fences if the model wrapped it despite instructions
101
+ stripped = text.strip()
102
+ if stripped.startswith("```"):
103
+ lines = stripped.splitlines()
104
+ stripped = "\n".join(lines[1:-1] if lines[-1].strip() == "```" else lines[1:])
105
+
106
+ data = json.loads(stripped)
107
+
108
+ clusters = [
109
+ RootCauseCluster(
110
+ label=c.get("label", ""),
111
+ finding_titles=c.get("finding_titles", []),
112
+ root_cause=c.get("root_cause", ""),
113
+ suggested_fix=c.get("suggested_fix", ""),
114
+ )
115
+ for c in data.get("root_cause_clusters", [])
116
+ ]
117
+
118
+ return SummaryResult(
119
+ executive_summary=data.get("executive_summary", ""),
120
+ priority_recommendations=data.get("priority_recommendations", []),
121
+ root_cause_clusters=clusters,
122
+ false_positive_candidates=data.get("false_positive_candidates", []),
123
+ )
124
+
125
+
126
+ def generate_summary(
127
+ session: TestSession,
128
+ provider: LLMProvider = LLMProvider.ANTHROPIC,
129
+ model: str | None = None,
130
+ api_key: str | None = None,
131
+ timeout: int = 60,
132
+ ) -> SummaryResult | None:
133
+ """Call the LLM to generate a summary of the completed session results.
134
+
135
+ Returns ``None`` on any failure so callers can treat summary generation as optional.
136
+ """
137
+ if not session.pages_tested:
138
+ return None
139
+
140
+ findings = session.get_deduplicated_findings()
141
+ if not findings:
142
+ return None
143
+
144
+ try:
145
+ client = create_llm_client(provider=provider, model=model, api_key=api_key)
146
+ user_message = (
147
+ "Here is the completed QA test session data:\n\n"
148
+ + _serialize_session(session)
149
+ + "\n\nProvide your summary as JSON."
150
+ )
151
+ response = client.complete(
152
+ system=_SYSTEM_PROMPT,
153
+ user=user_message,
154
+ max_tokens=2048,
155
+ timeout=timeout,
156
+ )
157
+ return _parse_summary(response.text)
158
+ except LLMError as e:
159
+ logger.warning("Result summary LLM call failed (%s): %s", e.status_code, e)
160
+ except (json.JSONDecodeError, KeyError, TypeError) as e:
161
+ logger.warning("Failed to parse summary response: %s", e)
162
+ except Exception as e:
163
+ logger.warning("Unexpected error during result summary generation: %s", e)
164
+
165
+ return None
@@ -1,6 +1,7 @@
1
1
  """Accessibility testing module."""
2
2
 
3
3
  import logging
4
+ from typing import Any
4
5
 
5
6
  from playwright.sync_api import Page
6
7
 
@@ -39,7 +40,7 @@ class AccessibilityTester(BaseTester):
39
40
  images = self.page.locator('img:visible')
40
41
  count = images.count()
41
42
 
42
- issues = {
43
+ issues: dict[str, Any] = {
43
44
  "missing_alt": [],
44
45
  "empty_decorative": 0,
45
46
  "suspicious_alt": [],
@@ -1,6 +1,7 @@
1
1
  """Error detection module for console and network errors."""
2
2
 
3
3
  from datetime import datetime
4
+ from typing import Any
4
5
 
5
6
  from playwright.sync_api import ConsoleMessage, Page, Request, Response
6
7
 
@@ -81,7 +82,7 @@ class ErrorDetector(BaseTester):
81
82
 
82
83
  if len(errors) > 0:
83
84
  # Group similar errors
84
- error_groups = {}
85
+ error_groups: dict[str, list[dict[str, Any]]] = {}
85
86
  for error in errors:
86
87
  key = error["text"][:100]
87
88
  if key not in error_groups:
@@ -145,7 +146,7 @@ class ErrorDetector(BaseTester):
145
146
  return
146
147
 
147
148
  # Group by status code
148
- status_groups = {}
149
+ status_groups: dict[Any, list[dict[str, Any]]] = {}
149
150
  for error in self.network_errors:
150
151
  status = error.get("status", "failed")
151
152
  if status not in status_groups:
@@ -1,6 +1,7 @@
1
1
  """Keyboard navigation and input testing."""
2
2
 
3
3
  import logging
4
+ from typing import Any
4
5
 
5
6
  from playwright.sync_api import Page
6
7
 
@@ -40,7 +41,7 @@ class KeyboardTester(BaseTester):
40
41
  self.page.evaluate("document.body.focus()")
41
42
  self.page.keyboard.press("Tab")
42
43
 
43
- visited_elements = []
44
+ visited_elements: list[dict[str, Any]] = []
44
45
  max_tabs = 100 # Prevent infinite loops
45
46
  tabs_pressed = 0
46
47
 
@@ -236,7 +237,8 @@ class KeyboardTester(BaseTester):
236
237
 
237
238
  if not is_focused:
238
239
  tag = element.evaluate("el => el.tagName.toLowerCase()")
239
- text = element.text_content()[:30] if element.text_content() else ""
240
+ content = element.text_content()
241
+ text = content[:30] if content else ""
240
242
  self.findings.append(Finding(
241
243
  title="Interactive element not focusable",
242
244
  description=f"{tag} element cannot receive focus",
@@ -191,7 +191,8 @@ class MouseTester(BaseTester):
191
191
  after_state = self.page.content()[:500]
192
192
 
193
193
  if initial_state == after_state:
194
- text = element.text_content()[:30] if element.text_content() else ""
194
+ content = element.text_content()
195
+ text = content[:30] if content else ""
195
196
  self.findings.append(Finding(
196
197
  title="Double-click handler has no effect",
197
198
  description="Element has ondblclick but double-clicking produces no visible change",