From fe1f72ae1bca151c7f032faec37ccbb04fb24b1f Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Mon, 24 Aug 2026 08:06:11 -0400 Subject: [PATCH] tests: the display-title tests still passed the argument that went away MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/test_notes.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/test_notes.py b/tests/test_notes.py index abb3d4a..464fa4e 100644 --- a/tests/test_notes.py +++ b/tests/test_notes.py @@ -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():