Skip to content

Commit b18eb94

Browse files
committed
Clean up message action tests
1 parent d14ba81 commit b18eb94

1 file changed

Lines changed: 38 additions & 24 deletions

File tree

tests/unit/message_actions_spec.lua

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,6 @@ describe('message_actions', function()
398398
assert.are.equal('Finish the active dialog first', notify_mock.get_notifications()[1].msg)
399399
end)
400400

401-
it('does not add an active-dialog registry or coordinator surface', function()
402-
local source = table.concat(vim.fn.readfile('lua/opencode/ui/message_actions.lua'), '\n')
403-
404-
assert.is_nil(source:find('registry', 1, true))
405-
assert.is_nil(source:find('allowlist', 1, true))
406-
assert.is_nil(source:find('coordinator', 1, true))
407-
assert.is_nil(source:find('wrapper', 1, true))
408-
end)
409-
410401
it('clear tears down the active dialog and requests synthetic display removal', function()
411402
render_message_at(user_message('msg_user'), 0, 0)
412403
set_output_cursor(1)
@@ -437,9 +428,13 @@ describe('message_actions', function()
437428
setreg_value = value
438429
end
439430

440-
render_message_at(user_message('msg_user', {
441-
{ id = 'part_text', type = 'text', text = 'copy me', messageID = 'msg_user', sessionID = 'ses_1' },
442-
}), 0, 0)
431+
render_message_at(
432+
user_message('msg_user', {
433+
{ id = 'part_text', type = 'text', text = 'copy me', messageID = 'msg_user', sessionID = 'ses_1' },
434+
}),
435+
0,
436+
0
437+
)
443438
set_output_cursor(1)
444439
message_actions.open_at_cursor()
445440
attach_rendered_actions_part(20)
@@ -592,11 +587,15 @@ describe('message_actions', function()
592587
setreg_value = value
593588
end
594589

595-
render_message_at(user_message('msg_user', {
596-
{ type = 'text', text = 'first' },
597-
{ type = 'text', text = 'synthetic', synthetic = true },
598-
{ type = 'text', text = 'second' },
599-
}), 0, 0)
590+
render_message_at(
591+
user_message('msg_user', {
592+
{ type = 'text', text = 'first' },
593+
{ type = 'text', text = 'synthetic', synthetic = true },
594+
{ type = 'text', text = 'second' },
595+
}),
596+
0,
597+
0
598+
)
600599
set_output_cursor(1)
601600
message_actions.open_at_cursor()
602601

@@ -616,10 +615,14 @@ describe('message_actions', function()
616615
setreg_called = true
617616
end
618617

619-
render_message_at(user_message('msg_user', {
620-
{ type = 'text', text = ' ' },
621-
{ type = 'text', text = 'synthetic', synthetic = true },
622-
}), 0, 0)
618+
render_message_at(
619+
user_message('msg_user', {
620+
{ type = 'text', text = ' ' },
621+
{ type = 'text', text = 'synthetic', synthetic = true },
622+
}),
623+
0,
624+
0
625+
)
623626
set_output_cursor(1)
624627
message_actions.open_at_cursor()
625628

@@ -730,9 +733,20 @@ describe('renderer.events message actions display', function()
730733
})
731734
end)
732735

733-
it('does not read message_actions state from renderer events', function()
734-
local source = table.concat(vim.fn.readfile('lua/opencode/ui/renderer/events.lua'), '\n')
736+
it('renders synthetic parts without loading message_actions', function()
737+
package.loaded['opencode.ui.message_actions'] = nil
738+
739+
events.render_message_actions_display('msg_user', 'message-actions-display-part:msg_user')
735740

736-
assert.is_nil(source:find("require('opencode.ui.message_actions')", 1, true))
741+
assert.is_nil(package.loaded['opencode.ui.message_actions'])
742+
assert.stub(part_stub).was_called_with({
743+
part = {
744+
id = 'message-actions-display-part:msg_user',
745+
messageID = 'msg_user',
746+
sessionID = 'ses_1',
747+
type = 'message-actions-display',
748+
synthetic = true,
749+
},
750+
})
737751
end)
738752
end)

0 commit comments

Comments
 (0)