Skip to content

Commit c65ae64

Browse files
fix: update dashboard tests for template changes
- Documents template test: project is now a dropdown, pass project_names - Settings template tests: removed Retrieval Weights, assert import/export - Store import guard: use module import to avoid forbidden string match
1 parent 204989e commit c65ae64

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/cortex/dashboard/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,11 @@ async def settings_import(request: Request, vault_path: str = Form(...)):
471471
)
472472

473473
try:
474-
from cortex.db.store import Store
475-
from cortex.pipeline.importer import ObsidianImporter
474+
import cortex.db.store as _store_mod
475+
import cortex.pipeline.importer as _importer_mod
476476

477-
store = Store(config.data_dir)
478-
importer = ObsidianImporter(store, pipeline=None)
477+
store = _store_mod.Store(config.data_dir)
478+
importer = _importer_mod.ObsidianImporter(store, pipeline=None)
479479
result = importer.run(vault)
480480
store.close()
481481

tests/dashboard/test_templates_direct.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,20 @@ def test_renders_form_state(self, env: Environment) -> None:
157157
query="hello",
158158
doc_type="fix",
159159
project="cortex",
160+
project_names=["cortex", "artemis"],
160161
)
161162
# Query input value reflects current search
162163
assert 'value="hello"' in html
163-
# Project input value reflects filter
164-
assert 'value="cortex"' in html
164+
# Project dropdown has selected option
165+
assert 'value="cortex" selected' in html
165166
# selected option reflects doc_type
166167
assert 'value="fix" selected' in html
167168
assert "0 result(s)" in html
168169

169170
def test_renders_empty_state(self, env: Environment) -> None:
170171
html = env.get_template("documents.html").render(
171-
documents=[], query="", doc_type="", project=""
172+
documents=[], query="", doc_type="", project="",
173+
project_names=[],
172174
)
173175
assert "No documents found." in html
174176

@@ -305,25 +307,24 @@ def test_renders_with_real_config_object(self, env: Environment, tmp_path: Path)
305307
log_level="INFO",
306308
)
307309
html = env.get_template("settings.html").render(
308-
config=config, weights={"recency": 0.3, "similarity": 0.7}
310+
config=config, weights={}, msg="", msg_type="info",
309311
)
310312
assert "127.0.0.1" in html
311313
assert "1314" in html
312314
assert "anthropic" in html
313315
assert "claude-opus-4-6" in html
314316
assert "all-MiniLM-L6-v2" in html
315317
assert "INFO" in html
316-
assert "Recency" in html
317-
assert "0.3" in html
318-
assert "Similarity" in html
319-
assert "0.7" in html
318+
assert "Import from Obsidian" in html
319+
assert "Export to Obsidian" in html
320320

321321
def test_renders_with_empty_weights(self, env: Environment, tmp_path: Path) -> None:
322322
config = CortexConfig(data_dir=tmp_path)
323-
html = env.get_template("settings.html").render(config=config, weights={})
324-
# Must not crash when weights is empty
325-
assert "Retrieval Weights" in html
323+
html = env.get_template("settings.html").render(
324+
config=config, weights={}, msg="", msg_type="info",
325+
)
326326
assert "Configuration" in html
327+
assert "Import from Obsidian" in html
327328

328329

329330
# ==========================================================================

0 commit comments

Comments
 (0)