|
1 | | -import EventEmitter, { once } from 'events'; |
| 1 | +import EventEmitter from 'events'; |
2 | 2 | import type { MenuItemConstructorOptions } from 'electron'; |
3 | 3 | import { BrowserWindow, ipcMain, Menu, app, dialog } from 'electron'; |
4 | 4 | import { expect } from 'chai'; |
@@ -654,49 +654,22 @@ describe('CompassMenu', function () { |
654 | 654 | ]); |
655 | 655 | }); |
656 | 656 |
|
657 | | - // TODO(COMPASS-8505): Remove skipping on linux |
658 | | - const testIt = os.platform() === 'linux' ? it.skip : it; |
659 | | - testIt( |
660 | | - 'does not crash when rendering menu item with an accelerator', |
661 | | - async () => { |
662 | | - const menu = Menu.buildFromTemplate([ |
663 | | - { |
664 | | - label: 'Test Super', |
665 | | - accelerator: 'Super+Ctrl+T', |
666 | | - }, |
667 | | - { |
668 | | - label: 'Test Meta', |
669 | | - accelerator: 'Meta+Ctrl+T', |
670 | | - }, |
671 | | - { |
672 | | - label: 'Test CmdOrCtrl', |
673 | | - accelerator: 'CmdOrCtrl+Q', |
674 | | - }, |
675 | | - { |
676 | | - label: 'Test Command', |
677 | | - accelerator: 'Command+H', |
678 | | - }, |
679 | | - { |
680 | | - label: 'Test Command+Shift', |
681 | | - accelerator: 'Command+Shift+H', |
682 | | - }, |
683 | | - { |
684 | | - label: 'Test Atl+CmdOrCtrl', |
685 | | - accelerator: 'Alt+CmdOrCtrl+S', |
686 | | - }, |
687 | | - { |
688 | | - label: 'Test Shift+CmdOrCtrl', |
689 | | - accelerator: 'Shift+CmdOrCtrl+S', |
690 | | - }, |
691 | | - ]); |
692 | | - const menuWillClose = once(menu, 'menu-will-close'); |
693 | | - menu.popup({ |
694 | | - window: new BrowserWindow({ show: false }), |
695 | | - }); |
| 657 | + it('does not crash when rendering menu item with an accelerator', () => { |
| 658 | + const window = new BrowserWindow({ show: false }); |
| 659 | + const template = CompassMenu.getTemplate(window.id); |
| 660 | + |
| 661 | + // As the root menu items do not have accelerators, we test |
| 662 | + // against each item's submenu. |
| 663 | + for (const item of template) { |
| 664 | + // for TS. compass menu has submenus |
| 665 | + if (!Array.isArray(item.submenu)) { |
| 666 | + continue; |
| 667 | + } |
| 668 | + const menu = Menu.buildFromTemplate(item.submenu); |
| 669 | + menu.popup({ window }); |
696 | 670 | menu.closePopup(); |
697 | | - await menuWillClose; |
698 | 671 | } |
699 | | - ); |
| 672 | + }); |
700 | 673 |
|
701 | 674 | it('should generate a menu template without collection submenu if `showCollection` is `false`', function () { |
702 | 675 | expect( |
|
0 commit comments