Skip to content

Commit

Permalink
Handle errors from top action menu commands (#1432)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Nov 5, 2024
1 parent 75ffab2 commit 16f2e56
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions browser_tests/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,31 @@ test.describe('Menu', () => {
})
expect(await exportTag.count()).toBe(1)
})

test('Can catch error when executing command', async ({ comfyPage }) => {
await comfyPage.page.evaluate(() => {
window['app'].registerExtension({
name: 'TestExtension1',
commands: [
{
id: 'foo',
label: 'foo-command',
function: () => {
throw new Error('foo!')
}
}
],
menuCommands: [
{
path: ['ext'],
commands: ['foo']
}
]
})
})
await comfyPage.menu.topbar.triggerTopbarCommand(['ext', 'foo-command'])
expect(await comfyPage.getVisibleToastCount()).toBe(1)
})
})

// Only test 'Top' to reduce test time.
Expand Down
2 changes: 1 addition & 1 deletion src/stores/menuItemStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const useMenuItemStore = defineStore('menuItem', () => {
.map(
(command) =>
({
command: command.function,
command: () => commandStore.execute(command.id),
label: command.menubarLabel,
icon: command.icon,
tooltip: command.tooltip,
Expand Down

0 comments on commit 16f2e56

Please sign in to comment.