File size: 8,201 Bytes
cc036ff | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | """
Console error detection tests for browser bug discovery.
This module tests for JavaScript console errors, unhandled exceptions,
and runtime errors that indicate UI bugs and broken functionality.
Tests use console_monitor and assert_no_console_errors fixtures from conftest.py.
"""
import pytest
from tests.browser_discovery.conftest import (
authenticated_page,
console_monitor,
assert_no_console_errors,
)
pytestmark = pytest.mark.browser_discovery
class TestConsoleErrors:
"""Test suite for detecting JavaScript console errors on critical pages."""
@pytest.mark.browser_discovery
def test_no_console_errors_on_dashboard(
self, authenticated_page, console_monitor, assert_no_console_errors
):
"""Verify dashboard page loads without JavaScript console errors.
Navigates to /dashboard and checks for any console errors that
indicate broken JavaScript, missing dependencies, or runtime issues.
Args:
authenticated_page: Authenticated page fixture (API-first auth)
console_monitor: Console monitor fixture
assert_no_console_errors: Assertion helper fixture
"""
base_url = "http://localhost:3001"
dashboard_url = base_url + "/dashboard"
authenticated_page.goto(dashboard_url)
authenticated_page.wait_for_load_state("domcontentloaded")
assert_no_console_errors()
@pytest.mark.browser_discovery
def test_no_console_errors_on_agents_list(
self, authenticated_page, console_monitor, assert_no_console_errors
):
"""Verify agents list page loads without JavaScript console errors.
Navigates to /agents and checks for console errors that indicate
issues with agent listing, filtering, or rendering.
Args:
authenticated_page: Authenticated page fixture
console_monitor: Console monitor fixture
assert_no_console_errors: Assertion helper fixture
"""
base_url = "http://localhost:3001"
agents_url = base_url + "/agents"
authenticated_page.goto(agents_url)
authenticated_page.wait_for_load_state("domcontentloaded")
assert_no_console_errors()
@pytest.mark.browser_discovery
def test_no_console_errors_on_agent_creation(
self, authenticated_page, console_monitor, assert_no_console_errors
):
"""Verify agent creation page loads without JavaScript console errors.
Navigates to /agents/new and checks for console errors that indicate
issues with agent creation form, validation, or component rendering.
Args:
authenticated_page: Authenticated page fixture
console_monitor: Console monitor fixture
assert_no_console_errors: Assertion helper fixture
"""
base_url = "http://localhost:3001"
agent_creation_url = base_url + "/agents/new"
authenticated_page.goto(agent_creation_url)
authenticated_page.wait_for_load_state("domcontentloaded")
assert_no_console_errors()
@pytest.mark.browser_discovery
def test_no_console_errors_on_canvas_list(
self, authenticated_page, console_monitor, assert_no_console_errors
):
"""Verify canvas list page loads without JavaScript console errors.
Navigates to /canvas and checks for console errors that indicate
issues with canvas listing, rendering, or state management.
Args:
authenticated_page: Authenticated page fixture
console_monitor: Console monitor fixture
assert_no_console_errors: Assertion helper fixture
"""
base_url = "http://localhost:3001"
canvas_url = base_url + "/canvas"
authenticated_page.goto(canvas_url)
authenticated_page.wait_for_load_state("domcontentloaded")
assert_no_console_errors()
@pytest.mark.browser_discovery
def test_no_console_errors_on_workflows_list(
self, authenticated_page, console_monitor, assert_no_console_errors
):
"""Verify workflows list page loads without JavaScript console errors.
Navigates to /workflows and checks for console errors that indicate
issues with workflow listing, DAG rendering, or component initialization.
Args:
authenticated_page: Authenticated page fixture
console_monitor: Console monitor fixture
assert_no_console_errors: Assertion helper fixture
"""
base_url = "http://localhost:3001"
workflows_url = base_url + "/workflows"
authenticated_page.goto(workflows_url)
authenticated_page.wait_for_load_state("domcontentloaded")
assert_no_console_errors()
@pytest.mark.browser_discovery
def test_console_error_captures_metadata(
self, authenticated_page, console_monitor
):
"""Verify console errors include timestamp, URL, and location metadata.
Checks that console_monitor captures detailed error context including
timestamp, current URL, and source location (file, line, column)
for effective bug triaging and debugging.
Args:
authenticated_page: Authenticated page fixture
console_monitor: Console monitor fixture
"""
base_url = "http://localhost:3001"
dashboard_url = base_url + "/dashboard"
authenticated_page.goto(dashboard_url)
authenticated_page.wait_for_load_state("domcontentloaded")
# Verify console_monitor structure
assert isinstance(console_monitor, dict), "console_monitor should be a dict"
assert "error" in console_monitor, "console_monitor should have 'error' key"
assert "warning" in console_monitor, "console_monitor should have 'warning' key"
assert "info" in console_monitor, "console_monitor should have 'info' key"
assert "log" in console_monitor, "console_monitor should have 'log' key"
assert "debug" in console_monitor, "console_monitor should have 'debug' key"
# If errors exist, verify metadata structure
errors = console_monitor.get("error", [])
if errors:
for error in errors:
assert "timestamp" in error, "Error should have timestamp"
assert "url" in error, "Error should have URL"
assert isinstance(error["timestamp"], str), "Timestamp should be string"
assert isinstance(error["url"], str), "URL should be string"
# Location is optional but should be dict if present
if "location" in error:
assert isinstance(error["location"], dict), "Location should be dict"
assert "url" in error["location"], "Location should have url"
assert "line_number" in error["location"], "Location should have line_number"
@pytest.mark.browser_discovery
def test_console_warnings_logged_but_not_failed(
self, authenticated_page, console_monitor
):
"""Verify console warnings are captured but do not fail tests.
Console warnings should be logged for visibility but should not
cause test failures. Only errors should fail tests.
Args:
authenticated_page: Authenticated page fixture
console_monitor: Console monitor fixture
"""
base_url = "http://localhost:3001"
dashboard_url = base_url + "/dashboard"
authenticated_page.goto(dashboard_url)
authenticated_page.wait_for_load_state("domcontentloaded")
# Verify warnings are captured (even if empty list)
assert "warning" in console_monitor, "console_monitor should capture warnings"
# Verify warning structure if present
warnings = console_monitor.get("warning", [])
if warnings:
for warning in warnings:
assert "timestamp" in warning, "Warning should have timestamp"
assert "url" in warning, "Warning should have URL"
assert "text" in warning, "Warning should have text"
# Warnings should NOT fail test (no assertion on warning count)
|