import sys
from pathlib import Path

import pytest

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))


@pytest.fixture(autouse=True)
def isolate_dispatch_rate_limit(monkeypatch, tmp_path):
    """Faked browser tests must never wait on, or write to, the real account gate."""
    import chat
    import registry
    monkeypatch.setenv("ASKGPT_DISPATCH_GAP", "0")
    monkeypatch.setattr(chat, "STATE", tmp_path / "gptbridge")
    monkeypatch.setattr(registry, "STATE", tmp_path / "gptbridge")
    monkeypatch.setattr(registry, "PATH", tmp_path / "gptbridge" / "conversations.jsonl")
    monkeypatch.setattr(registry, "LOCK", tmp_path / "gptbridge" / "conversations.lock")
