bowser/tests
Benedikt Willi 3838aa17af Add DOM Visualization Feature with Integrated Browser Support
- Introduced a new feature to visualize the Document Object Model (DOM) tree of the loaded web page.
- Implemented keyboard shortcut (Ctrl+Shift+D) for generating and displaying the DOM graph.
- Added core implementation files:
  - src/debug/dom_graph.py: Handles generation and rendering of graphs in DOT and SVG formats.
- Created templates and documentation for the new feature, including:
  - docs/DOM_VISUALIZATION.md: Overview and usage instructions.
  - docs/DOM_GRAPH_UX.md: User experience design documentation.
- Allowed the visualization to open in a new browser tab instead of an external viewer.
- Enhanced visual representation through color coding of different HTML elements.
- Implemented comprehensive tests for graph generation and page rendering.
- Updated README.md to include usage instructions for DOM visualization.
- Included test_holder.html as an example test page.
- Modified various components in the browser to integrate tab management and enhance the graphical rendering experience.
2026-01-10 00:19:21 +01:00
..
__init__.py Initial bowser project scaffold 2026-01-09 12:20:46 +01:00
conftest.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
README.md Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_browser.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_cookies.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_dom_graph.py Add DOM Visualization Feature with Integrated Browser Support 2026-01-10 00:19:21 +01:00
test_dom_graph_page.py Add DOM Visualization Feature with Integrated Browser Support 2026-01-10 00:19:21 +01:00
test_frame.py Implement HTTP redirect following 2026-01-09 14:11:46 +01:00
test_html_parsing.py Add DOM Visualization Feature with Integrated Browser Support 2026-01-10 00:19:21 +01:00
test_http.py Implement HTTP redirect following 2026-01-09 14:11:46 +01:00
test_layout.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_parser.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_render.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_templates.py Implement Jinja2 templates for startpage and error pages 2026-01-09 14:24:01 +01:00
test_url.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_url_normalization.py Add automatic HTTPS protocol assumption for URLs 2026-01-09 14:52:05 +01:00

Bowser Test Suite

This directory contains the test suite for the Bowser browser.

Running Tests

Run all tests:

uv run pytest

Run with verbose output:

uv run pytest -v

Run specific test file:

uv run pytest tests/test_browser.py

Run with coverage:

uv run pytest --cov=src --cov-report=html

View coverage report:

open htmlcov/index.html

Test Organization

  • test_url.py - URL parsing and resolution
  • test_parser.py - HTML/CSS parsing
  • test_browser.py - Browser and tab management
  • test_cookies.py - Cookie jar functionality
  • test_layout.py - Layout engine components
  • test_render.py - Rendering primitives
  • conftest.py - Shared fixtures and configuration

Writing Tests

Tests use pytest. Example:

def test_feature():
    # Arrange
    obj = MyClass()
    
    # Act
    result = obj.method()
    
    # Assert
    assert result == expected

Use mocks for GTK components:

@patch('src.browser.browser.Gtk')
def test_with_gtk(mock_gtk):
    browser = Browser()
    # test code