@@ -3,6 +3,7 @@ import type { MenuItemConstructorOptions } from 'electron';
3
3
import { BrowserWindow , ipcMain , Menu , app , dialog } from 'electron' ;
4
4
import { expect } from 'chai' ;
5
5
import sinon from 'sinon' ;
6
+ import os from 'os' ;
6
7
import { createSandboxFromDefaultPreferences } from 'compass-preferences-model' ;
7
8
8
9
import type { CompassApplication } from './application' ;
@@ -457,7 +458,8 @@ describe('CompassMenu', function () {
457
458
] ) ;
458
459
} ) ;
459
460
460
- [ 'linux' , 'win32' ] . forEach ( ( platform ) => {
461
+ // TODO(COMPASS-8505): Add `linux` back to this list
462
+ [ 'win32' ] . forEach ( ( platform ) => {
461
463
// TODO(COMPASS-7906): remove
462
464
it . skip ( `[single-connection] should generate a menu template for ${ platform } ` , function ( ) {
463
465
sinon . stub ( process , 'platform' ) . value ( platform ) ;
@@ -588,6 +590,87 @@ describe('CompassMenu', function () {
588
590
} ) ;
589
591
} ) ;
590
592
593
+ // TODO(COMPASS-8505): Remove this test
594
+ it ( 'should generate a menu template for linux' , async function ( ) {
595
+ await App . preferences . savePreferences ( {
596
+ enableMultipleConnectionSystem : true ,
597
+ } ) ;
598
+ sinon . stub ( process , 'platform' ) . value ( 'linux' ) ;
599
+
600
+ expect ( serializable ( CompassMenu . getTemplate ( 0 ) ) ) . to . deep . equal ( [
601
+ {
602
+ label : '&Connections' ,
603
+ submenu : [
604
+ { label : '&Import Saved Connections' } ,
605
+ { label : '&Export Saved Connections' } ,
606
+ { type : 'separator' } ,
607
+ { label : 'E&xit' } ,
608
+ ] ,
609
+ } ,
610
+ {
611
+ label : 'Edit' ,
612
+ submenu : [
613
+ { label : 'Undo' , role : 'undo' } ,
614
+ { label : 'Redo' , role : 'redo' } ,
615
+ { type : 'separator' } ,
616
+ { label : 'Cut' , role : 'cut' } ,
617
+ { label : 'Copy' , role : 'copy' } ,
618
+ { label : 'Paste' , role : 'paste' } ,
619
+ {
620
+ label : 'Select All' ,
621
+ role : 'selectAll' ,
622
+ } ,
623
+ { type : 'separator' } ,
624
+ { label : 'Find' } ,
625
+ { type : 'separator' } ,
626
+ { label : '&Settings' } ,
627
+ ] ,
628
+ } ,
629
+ {
630
+ label : '&View' ,
631
+ submenu : [
632
+ { label : '&Reload' } ,
633
+ { label : '&Reload Data' } ,
634
+ { type : 'separator' } ,
635
+ { label : 'Actual Size' } ,
636
+ { label : 'Zoom In' } ,
637
+ { label : 'Zoom Out' } ,
638
+ ] ,
639
+ } ,
640
+ {
641
+ label : '&Help' ,
642
+ submenu : [
643
+ { label : `&Online ${ app . getName ( ) } Help` } ,
644
+ { label : '&License' } ,
645
+ { label : `&View Source Code on GitHub` } ,
646
+ { label : `&Suggest a Feature` } ,
647
+ { label : `&Report a Bug` } ,
648
+ { label : '&Open Log File' } ,
649
+ { type : 'separator' } ,
650
+ { label : `&About ${ app . getName ( ) } ` } ,
651
+ { label : 'Check for updates…' } ,
652
+ ] ,
653
+ } ,
654
+ ] ) ;
655
+ } ) ;
656
+
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 } ) ;
670
+ menu . closePopup ( ) ;
671
+ }
672
+ } ) ;
673
+
591
674
it ( 'should generate a menu template without collection submenu if `showCollection` is `false`' , function ( ) {
592
675
expect (
593
676
CompassMenu . getTemplate ( 0 ) . find ( ( item ) => item . label === '&Collection' )
@@ -612,7 +695,12 @@ describe('CompassMenu', function () {
612
695
label : '&Collection' ,
613
696
submenu : [
614
697
{
615
- accelerator : 'Alt+CmdOrCtrl+S' ,
698
+ // TODO(COMPASS-8505): Add `accelerator` back to this
699
+ ...( os . platform ( ) === 'linux'
700
+ ? { }
701
+ : {
702
+ accelerator : 'Alt+CmdOrCtrl+S' ,
703
+ } ) ,
616
704
label : '&Share Schema as JSON' ,
617
705
} ,
618
706
{
@@ -646,7 +734,12 @@ describe('CompassMenu', function () {
646
734
label : '&Collection' ,
647
735
submenu : [
648
736
{
649
- accelerator : 'Alt+CmdOrCtrl+S' ,
737
+ // TODO(COMPASS-8505): Add `accelerator` back to this
738
+ ...( os . platform ( ) === 'linux'
739
+ ? { }
740
+ : {
741
+ accelerator : 'Alt+CmdOrCtrl+S' ,
742
+ } ) ,
650
743
label : '&Share Schema as JSON' ,
651
744
} ,
652
745
{
@@ -670,7 +763,12 @@ describe('CompassMenu', function () {
670
763
expect (
671
764
menu . find ( ( item : any ) => item . label === '&Toggle DevTools' )
672
765
) . to . deep . eq ( {
673
- accelerator : 'Alt+CmdOrCtrl+I' ,
766
+ // TODO(COMPASS-8505): Add `accelerator` back to this
767
+ ...( os . platform ( ) === 'linux'
768
+ ? { }
769
+ : {
770
+ accelerator : 'Alt+CmdOrCtrl+I' ,
771
+ } ) ,
674
772
label : '&Toggle DevTools' ,
675
773
} ) ;
676
774
} ) ;
0 commit comments