test(filter): add hierarchical tag_search matching coverage

Add regression test for tag_search hierarchical behavior: tag_search ==
"work" now also asserts it matches "work/project" sub-tags, not just
exact matches.

Signed-off-by: majiayu000 <1835304752@qq.com>
This commit is contained in:
majiayu000 2026-03-25 12:11:05 +08:00
parent 6c996016eb
commit 5f5e1bec14
No known key found for this signature in database
GPG Key ID: 29C2AE46ADC3B14B
1 changed files with 9 additions and 3 deletions

View File

@ -974,13 +974,19 @@ func TestMemoFilterTagSearchEquality(t *testing.T) {
defer tc.Close()
tc.CreateMemo(NewMemoBuilder("memo-work", tc.User.ID).Content("Work memo").Tags("work", "important"))
tc.CreateMemo(NewMemoBuilder("memo-work-child", tc.User.ID).Content("Nested work memo").Tags("work/project"))
tc.CreateMemo(NewMemoBuilder("memo-personal", tc.User.ID).Content("Personal memo").Tags("personal"))
tc.CreateMemo(NewMemoBuilder("memo-no-tags", tc.User.ID).Content("No tags"))
// Test: tag_search == "work" should behave like tag in ["work"]
// Test: tag_search == "work" should match both exact "work" and hierarchical "work/project"
memos := tc.ListWithFilter(`tag_search == "work"`)
require.Len(t, memos, 1)
require.Contains(t, memos[0].Payload.Tags, "work")
require.Len(t, memos, 2)
tags := []string{}
for _, m := range memos {
tags = append(tags, m.Payload.Tags...)
}
require.Contains(t, tags, "work")
require.Contains(t, tags, "work/project")
}
func TestMemoFilterPropertyHasIncompleteTasks(t *testing.T) {