@@ -2,9 +2,7 @@ local gui = require('gui')
22local gui_notes = reqscript (' gui/notes' )
33local utils = require (' utils' )
44local guidm = require (' gui.dwarfmode' )
5-
6-
7- -- local guidm = require('gui.dwarfmode')
5+ local overlay = require (' plugins.overlay' )
86
97config = {
108 target = ' gui/notes' ,
@@ -49,7 +47,11 @@ local function arrange_gui_notes(options)
4947 gui_notes :updateLayout ()
5048 gui_notes :onRender ()
5149
52- return gui_notes
50+ -- for some reasons running tests remove all overlays,
51+ -- but there are need for gui/notes tests
52+ overlay .rescan ()
53+
54+ return gui_notes , gui_notes .subviews .notes_window
5355end
5456
5557local function cleanup (gui_notes )
@@ -214,6 +216,43 @@ function test.filter_notes()
214216 cleanup (gui_notes )
215217end
216218
219+ function test .edit_note ()
220+ local notes = {
221+ {name = ' green note 1' , comment = ' comment 1' , pos = {x = 1 , y = 1 , z = 1 }},
222+ {name = ' green note 2' , comment = ' comment 2' , pos = {x = 2 , y = 2 , z = 2 }},
223+ {name = ' blue note 3' , comment = ' comment 3' , pos = {x = 3 , y = 3 , z = 3 }},
224+ }
225+
226+ local gui_notes , gui_notes_window = arrange_gui_notes ({ notes = notes })
227+ local screen = dfhack .gui .getCurViewscreen (true )
228+
229+ gui .simulateInput (screen , ' KEYBOARD_CURSOR_DOWN' )
230+ gui .simulateInput (screen , ' CUSTOM_CTRL_E' )
231+
232+ local note_manager = gui_notes_window .note_manager
233+ expect .ne (note_manager , nil )
234+
235+ expect .eq (note_manager .subviews .name :getText (), ' green note 2' )
236+ expect .eq (note_manager .subviews .comment :getText (), ' comment 2' )
237+
238+ note_manager .subviews .name :setText (' updated green note 2' )
239+ note_manager .subviews .comment :setText (' updated comment 2' )
240+ local screen = dfhack .gui .getCurViewscreen (true )
241+ printall (screen .widgets )
242+ gui .simulateInput (dfhack .gui .getCurViewscreen (true ), ' CUSTOM_CTRL_ENTER' )
243+
244+ local note_list = gui_notes .subviews .note_list :getChoices ()
245+ expect .eq (# note_list , 3 )
246+
247+ local updated_note = note_list [2 ]
248+
249+ expect .eq (updated_note .text , ' updated green note 2' )
250+ expect .eq (updated_note .point .name , ' updated green note 2' )
251+ expect .eq (updated_note .point .comment , ' updated comment 2' )
252+
253+ cleanup (gui_notes )
254+ end
255+
217256function test .delete_note ()
218257 local notes = {
219258 {name = ' green note 1' , comment = ' comment 1' , pos = {x = 1 , y = 1 , z = 1 }},
0 commit comments