@@ -60,6 +60,56 @@ describe('card drafts', () => {
6060 } ) ;
6161 } ) ;
6262
63+ it ( 'adds Markdown notes to a bookmark that did not already have a body' , ( ) => {
64+ const bookmark : InboxItem = {
65+ id : 'bm-1' ,
66+ type : 'bookmark' ,
67+ title : 'Example' ,
68+ url : 'https://example.org' ,
69+ createdAt : note . createdAt ,
70+ } ;
71+ const draft = createCardDraft ( bookmark ) ;
72+ draft . body = '## Remember\n\nUseful reference.' ;
73+
74+ expect ( applyCardDraft ( bookmark , draft ) ) . toEqual ( {
75+ ...bookmark ,
76+ body : '## Remember\n\nUseful reference.' ,
77+ } ) ;
78+ } ) ;
79+
80+ it ( 'preserves bookmark notes when a recovered draft omits body' , ( ) => {
81+ const bookmark : InboxItem = {
82+ id : 'bm-1' ,
83+ type : 'bookmark' ,
84+ title : 'Example' ,
85+ url : 'https://example.org' ,
86+ body : 'Existing notes' ,
87+ createdAt : note . createdAt ,
88+ } ;
89+ const draft = createCardDraft ( bookmark ) ;
90+ delete draft . body ;
91+
92+ expect ( applyCardDraft ( bookmark , draft ) ) . toEqual ( bookmark ) ;
93+ } ) ;
94+
95+ it ( 'clears bookmark notes only when body is explicitly empty' , ( ) => {
96+ const bookmark : InboxItem = {
97+ id : 'bm-1' ,
98+ type : 'bookmark' ,
99+ title : 'Example' ,
100+ url : 'https://example.org' ,
101+ body : 'Existing notes' ,
102+ createdAt : note . createdAt ,
103+ } ;
104+ const draft = createCardDraft ( bookmark ) ;
105+ draft . body = '' ;
106+
107+ expect ( applyCardDraft ( bookmark , draft ) ) . toEqual ( {
108+ ...bookmark ,
109+ body : undefined ,
110+ } ) ;
111+ } ) ;
112+
63113 it ( 'merges external updates only into untouched draft fields' , ( ) => {
64114 const bookmark : InboxItem = {
65115 id : 'bm-1' ,
0 commit comments