"""A visible browser window requires the owner's explicit opt-in."""

from __future__ import annotations

import browser


def test_show_is_coerced_to_virtual_without_opt_in(monkeypatch, capsys):
    monkeypatch.delenv(browser.Session.SHOW_ENV, raising=False)
    session = browser.Session(port=1, mode="show")
    assert session.mode == "virtual"
    assert browser.Session.SHOW_ENV in capsys.readouterr().err


def test_show_survives_with_opt_in(monkeypatch):
    monkeypatch.setenv(browser.Session.SHOW_ENV, "1")
    assert browser.Session(port=1, mode="show").mode == "show"


def test_virtual_is_the_default():
    assert browser.Session(port=1).mode == "virtual"
