test: split modal import ui contract

This commit is contained in:
Saberlve 2026-04-15 12:12:12 +08:00
parent ff9f64675c
commit f7554b889a

View File

@ -2,7 +2,7 @@ from zotero_kb.api import create_app
from zotero_kb.config import AppConfig from zotero_kb.config import AppConfig
def test_index_contains_import_modal_controls(tmp_path) -> None: def _get_index_html(tmp_path) -> str:
app = create_app( app = create_app(
AppConfig( AppConfig(
workspace_dir=tmp_path / "workspace", workspace_dir=tmp_path / "workspace",
@ -13,12 +13,22 @@ def test_index_contains_import_modal_controls(tmp_path) -> None:
for route in app.routes: for route in app.routes:
if getattr(route, "path", None) == "/" and "GET" in getattr(route, "methods", set()): if getattr(route, "path", None) == "/" and "GET" in getattr(route, "methods", set()):
html = route.endpoint() return route.endpoint()
break
else: raise AssertionError("GET / route not found")
raise AssertionError("GET / route not found")
def test_index_contains_base_page_forms(tmp_path) -> None:
html = _get_index_html(tmp_path)
assert 'id="create-project-form"' in html assert 'id="create-project-form"' in html
assert 'id="recommend-form"' in html
assert 'id="plan-form"' in html
def test_index_contains_import_modal_controls(tmp_path) -> None:
html = _get_index_html(tmp_path)
assert 'id="open-import-modal-button"' in html assert 'id="open-import-modal-button"' in html
assert 'id="import-modal"' in html assert 'id="import-modal"' in html
assert 'id="close-import-modal-button"' in html assert 'id="close-import-modal-button"' in html
@ -31,5 +41,3 @@ def test_index_contains_import_modal_controls(tmp_path) -> None:
assert 'id="item-preview-popover"' in html assert 'id="item-preview-popover"' in html
assert 'const ABSTRACT_PREVIEW_DELAY_MS = 3000;' in html assert 'const ABSTRACT_PREVIEW_DELAY_MS = 3000;' in html
assert 'isImportModalOpen: false' in html assert 'isImportModalOpen: false' in html
assert 'id="recommend-form"' in html
assert 'id="plan-form"' in html