tests: the display-title tests still passed the argument that went away
CI & Build / Build now, or wait for Android? (push) Successful in 2s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 6s
CI & Build / Python tests (push) Successful in 9s
CI & Build / integration (push) Successful in 18s
CI & Build / Build & push image (push) Successful in 30s

Three of them called derive_display_title(body, first_item). I updated the call
sites in src/ and not these — the integration lane and the linter both passed,
because a stale keyword argument is only a TypeError at the moment it runs.

Rewritten rather than deleted. The property the fallback existed to protect is
still real — a note that is only a checklist has to have a name — it is just
reached differently now: an item IS a body line, so the first one is simply the
first line with its marker stripped. The new cases pin the two edges that rule
introduces: an empty item must not name a note "", and a list of nothing but empty
items still has no name.
This commit is contained in:
2026-08-24 08:06:11 -04:00
parent 761c3b5e82
commit fe1f72ae1b
+18 -16
View File
@@ -139,27 +139,32 @@ def test_derive_display_title_is_the_first_body_line():
assert derive_display_title("\n \nreal line\nmore") == "real line"
def test_derive_display_title_falls_back_to_the_first_item():
# What step 2 bought: a note that is only a checklist still has a name. Without
# this it would have none at all, which is why the title could not go first.
assert derive_display_title("", "milk") == "milk"
assert derive_display_title(" \n ", " eggs ") == "eggs"
# The body still wins when it has anything to say.
assert derive_display_title("shopping", "milk") == "shopping"
def test_derive_display_title_names_a_list_only_note():
# The same property the old `first_item` fallback protected — a note that is only
# a checklist still has a name — reached a different way. Items ARE body lines now
# (M304), so the first one is simply the first line, with its marker stripped:
# calling the note "- [ ] milk" would show someone the storage instead of the note.
assert derive_display_title("- [ ] milk\n- [ ] eggs") == "milk"
assert derive_display_title(" * [x] eggs ") == "eggs"
# Prose still wins when it comes first, because it IS the first line.
assert derive_display_title("shopping\n\n- [ ] milk") == "shopping"
# An EMPTY item does not name the note "" — a half-typed list still has a name.
assert derive_display_title("- [ ]\n- [ ] eggs") == "eggs"
def test_derive_display_title_empty():
assert derive_display_title(None) == ""
assert derive_display_title("") == ""
assert derive_display_title(" \n ", None) == ""
assert derive_display_title(" \n ", " ") == ""
assert derive_display_title(" \n ") == ""
# A list of nothing but empty items is still a note with no name.
assert derive_display_title("- [ ]\n- [ ]") == ""
def test_derive_display_title_caps_length():
long = "x" * 300
assert derive_display_title(long) == "x" * 200
# the item fallback is capped on the same rule
assert derive_display_title("", long) == "x" * 200
# A first line that happens to be an item is capped on the same rule.
assert derive_display_title(f"- [ ] {long}") == "x" * 200
def test_parse_tags():
@@ -502,13 +507,10 @@ def test_append_item_spacing():
assert append_item("", "done", True) == "- [x] done"
def test_strip_marker_and_display_title():
def test_strip_marker():
assert strip_marker("- [x] milk") == "milk"
assert strip_marker("just prose") == "just prose"
# A list-only note is named by its first item, without the marker.
assert derive_display_title("- [ ] milk\n- [ ] eggs") == "milk"
# An EMPTY item does not name the note "" — a half-typed list still has a name.
assert derive_display_title("- [ ]\n- [ ] eggs") == "eggs"
assert strip_marker("- [ ]") == ""
def test_the_migration_folds_exactly_like_the_app():