"""
ShelfAI test suite.

Tests core functionality: shelf operations, index parsing,
transcript parsing, session management, and CLI commands.
"""



class TestCliUrlHandling:
    def test_add_url_html_goes_to_raw_resources(self, shelf_dir, monkeypatch):
        from typer.testing import CliRunner
        from shelfai.cli.main import app

        class DummyResponse:
            def __init__(self):
                self.headers = {"Content-Type": "text/html; charset=utf-8"}
            def read(self):
                return b"<html><body>hello</body></html>"

        def fake_urlopen(request):
            return DummyResponse()

        monkeypatch.setattr("urllib.request.urlopen", fake_urlopen)
        runner = CliRunner()
        result = runner.invoke(
            app,
            [
                "add",
                "https://example.com/page",
                "--shelf",
                str(shelf_dir),
            ],
        )
        assert result.exit_code == 0
        assert (shelf_dir / "resources" / "raw" / "page.html").exists()



