from __future__ import annotations import unittest from pathlib import Path from streamlit.testing.v1 import AppTest ROOT = Path(__file__).resolve().parents[1] class StreamlitSmokeTests(unittest.TestCase): def test_default_demo_renders_without_exception(self) -> None: app = AppTest.from_file(str(ROOT / "app.py"), default_timeout=30).run() self.assertEqual(len(app.exception), 0) self.assertGreaterEqual(len(app.button), 8) self.assertGreaterEqual(len(app.selectbox), 2) self.assertEqual(app.radio[0].value, "Dane demonstracyjne") def test_upload_mode_has_safe_empty_state(self) -> None: app = AppTest.from_file(str(ROOT / "app.py"), default_timeout=30).run() app.radio[0].set_value("Wgraj plik CSV").run() self.assertEqual(len(app.exception), 0) self.assertGreaterEqual(len(app.info), 1) def test_cylinder_grid_and_detail_selector_share_state(self) -> None: app = AppTest.from_file(str(ROOT / "app.py"), default_timeout=30).run() target = next(button for button in app.button if "C03" in button.label) target.click().run() detail_selector = next( selector for selector in app.selectbox if selector.label == "Cylinder do analizy" ) self.assertEqual(detail_selector.value, 3) rendered = "\n".join(markdown.value for markdown in app.markdown) self.assertIn("CYLINDER 03", rendered)