feat(tasks): deepening a task into a note keeps the task, linked to the note's first checkbox

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-11-01 11:32:42 +01:00
1 parent c851b8e3ba
commit 1a56be572c
5 files changed
+66 -3

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
package storage
import (
"path/filepath"
"testing"
"github.com/sandrodach/mindsift/internal/domain"
)
// "Als Notiz vertiefen": a task stays in its list, linked to the note's first checkbox; a thought from
// the inbox still turns into the note.
func TestDeepenTaskIntoNoteKeepsTheTask(t *testing.T) {
store, err := NewStore(filepath.Join(t.TempDir(), "deepen.db"))
if err != nil {
t.Fatalf("NewStore: %v", err)
}
defer store.Close()
anna, _ := store.CreateUser("anna@example.com", "hash", "Anna", "member")
tl, _ := store.CreateTaskList(anna.ID, "", "", "Homelab", "", "")
th, _ := store.CreateThoughtWithDetails(anna.ID, "Backup-Konzept", "high", "manual", "", tl.ID, "todo", "Restic oder Borg?")
if _, err := store.UpdateThoughtTriage(anna.ID, th.ID, "keep", "task", "", "", tl.ID); err != nil {
t.Fatal(err)
}
deepened, err := store.UpdateThoughtTriage(anna.ID, th.ID, "keep", "document", "", "", "")
if err != nil {
t.Fatal(err)
}
if deepened.Status != domain.StatusKept || deepened.ConvertedType != "document_block" || deepened.DocID == "" || deepened.TaskListID != tl.ID {
t.Fatalf("task should stay in its list, linked to the note: %+v", deepened)
}
tasks, _ := store.GetTasks(anna.ID, tl.ID)
if len(tasks) != 1 || tasks[0].ID != th.ID {
t.Fatalf("task missing from its list: %+v", tasks)
}
doc, err := store.GetDocumentByID(anna.ID, deepened.DocID)
if err != nil || doc == nil || len(doc.Blocks) == 0 || doc.Blocks[0].ID != deepened.BlockID || doc.Blocks[0].Type != "todo" {
t.Fatalf("first block should be the linked checkbox: %+v %v", doc, err)
}
// Completing the task ticks the checkbox in the note
if store.SyncDocBlockAndTask(anna.ID, th.ID, true) != deepened.DocID {
t.Fatal("completing the task should tick its block")
}
// A thought from the inbox becomes the note as before
inbox, _ := store.CreateThought(anna.ID, "Idee für Blogartikel", "normal", "manual", "")
asNote, err := store.UpdateThoughtTriage(anna.ID, inbox.ID, "keep", "document", "", "", "")
if err != nil || asNote.Status != domain.StatusConverted || asNote.ConvertedType != "document" {
t.Fatalf("inbox thought should turn into a note: %+v %v", asNote, err)
}
}