Handle errors from top action menu commands (#1432)

This commit is contained in:
Chenlei Hu
2024-11-04 22:50:19 -05:00
committed by GitHub
parent 75ffab2160
commit 16f2e56d8e
2 changed files with 26 additions and 1 deletions

View File

@@ -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.

View File

@@ -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,