Fix test assertions to fail when data is missing

- Add assertIsNotNone for accessibility_data to ensure test fails if no data generated
- Capture and report JSON decode errors in parse_dom_outlinks test
- Add assertIsNotNone for outlinks_data with error details
- Removes conditional checks that allowed tests to pass without verifying functionality

Addresses review comments from cubic-dev-ai

Co-authored-by: Nick Sweeting <pirate@users.noreply.github.com>
This commit is contained in:
claude[bot]
2025-12-31 19:00:30 +00:00
parent 263335dc6d
commit 1f84d1b467
2 changed files with 14 additions and 11 deletions

View File

@@ -105,10 +105,11 @@ class TestAccessibilityWithChrome(TestCase):
self.assertNotIn('Traceback', result.stderr)
# example.com has headings, so we should get accessibility data
if accessibility_data:
# Verify we got page outline data
self.assertIn('headings', accessibility_data, f"Missing headings: {accessibility_data}")
self.assertIn('url', accessibility_data, f"Missing url: {accessibility_data}")
self.assertIsNotNone(accessibility_data, "No accessibility data was generated")
# Verify we got page outline data
self.assertIn('headings', accessibility_data, f"Missing headings: {accessibility_data}")
self.assertIn('url', accessibility_data, f"Missing url: {accessibility_data}")
except RuntimeError as e:
if 'Chrome' in str(e) or 'CDP' in str(e):

View File

@@ -91,25 +91,27 @@ class TestParseDomOutlinksWithChrome(TestCase):
outlinks_output = snapshot_chrome_dir / 'outlinks.json'
outlinks_data = None
json_error = None
# Try parsing from file first
if outlinks_output.exists():
with open(outlinks_output) as f:
try:
outlinks_data = json.load(f)
except json.JSONDecodeError:
pass
except json.JSONDecodeError as e:
json_error = str(e)
# Verify hook ran successfully
self.assertEqual(result.returncode, 0, f"Hook failed: {result.stderr}")
self.assertNotIn('Traceback', result.stderr)
# Verify we got outlinks data with expected categories
if outlinks_data:
self.assertIn('url', outlinks_data, f"Missing url: {outlinks_data}")
self.assertIn('hrefs', outlinks_data, f"Missing hrefs: {outlinks_data}")
# example.com has at least one link (to iana.org)
self.assertIsInstance(outlinks_data['hrefs'], list)
self.assertIsNotNone(outlinks_data, f"No outlinks data found - file missing or invalid JSON: {json_error}")
self.assertIn('url', outlinks_data, f"Missing url: {outlinks_data}")
self.assertIn('hrefs', outlinks_data, f"Missing hrefs: {outlinks_data}")
# example.com has at least one link (to iana.org)
self.assertIsInstance(outlinks_data['hrefs'], list)
except RuntimeError as e:
if 'Chrome' in str(e) or 'CDP' in str(e):