"""Tests for CLI helpers — cold-start detection and onboarding artifacts.""" import pytest from storied.character import create_character from storied.cli import _is_cold_start from storied.paths import world_path @pytest.fixture def _minimal_character() -> None: """Create a minimal character so load_character finds one.""" create_character( player_id="default", name="Test", race="Human", char_class="Fighter", level=1, abilities={ "strength": 10, "dexterity": 10, "constitution": 10, "intelligence": 10, "wisdom": 10, "charisma": 10, }, hp_max=10, ac=10, ) @pytest.fixture def _world_style() -> None: """Write a non-empty style.md for the default world.""" world_dir = world_path("default") world_dir.mkdir(parents=True, exist_ok=True) (world_dir / "style.md").write_text("Grim. Slow-burn.\n") class TestColdStartDetection: def test_cold_start_when_nothing_exists(self): assert _is_cold_start("default", "default") is True @pytest.mark.usefixtures("_minimal_character") def test_cold_start_when_only_character_exists(self): assert _is_cold_start("default", "default") is True @pytest.mark.usefixtures("_world_style") def test_cold_start_when_only_style_exists(self): assert _is_cold_start("default", "default") is True @pytest.mark.usefixtures("_minimal_character", "_world_style") def test_not_cold_start_when_both_exist(self): assert _is_cold_start("default", "default") is False @pytest.mark.usefixtures("_minimal_character") def test_not_cold_start_ignores_other_worlds(self): # Style lives in a different world — doesn't count for this one. world_dir = world_path("other") world_dir.mkdir(parents=True, exist_ok=True) (world_dir / "style.md").write_text("A vibe.\n") assert _is_cold_start("default", "default") is True class TestOnboardingPromptExists: def test_new_game_prompt_file_exists(self): from storied.engine import load_prompt content = load_prompt("new-game") # Sanity check: the prompt mentions both onboarding deliverables. assert "tune" in content assert "create_character" in content assert "end_session" in content