-
Notifications
You must be signed in to change notification settings - Fork 245
fix(menu): remove accelerators for linux COMPASS-8494 #6485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
ae347bb
51c3de3
da546b7
2ef8483
2cafca0
796da35
17a8807
a212ad4
383ff25
2a9b3f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| import EventEmitter from 'events'; | ||
| import EventEmitter, { once } from 'events'; | ||
| import type { MenuItemConstructorOptions } from 'electron'; | ||
| import { BrowserWindow, ipcMain, Menu, app, dialog } from 'electron'; | ||
| import { expect } from 'chai'; | ||
| import sinon from 'sinon'; | ||
| import os from 'os'; | ||
| import { createSandboxFromDefaultPreferences } from 'compass-preferences-model'; | ||
|
|
||
| import type { CompassApplication } from './application'; | ||
|
|
@@ -457,7 +458,8 @@ describe('CompassMenu', function () { | |
| ]); | ||
| }); | ||
|
|
||
| ['linux', 'win32'].forEach((platform) => { | ||
| // TODO(COMPASS-8505): Add `linux` back to this list | ||
| ['win32'].forEach((platform) => { | ||
| // TODO(COMPASS-7906): remove | ||
| it.skip(`[single-connection] should generate a menu template for ${platform}`, function () { | ||
| sinon.stub(process, 'platform').value(platform); | ||
|
|
@@ -588,6 +590,89 @@ describe('CompassMenu', function () { | |
| }); | ||
| }); | ||
|
|
||
| // TODO(COMPASS-8505): Remove this test | ||
| it('should generate a menu template for linux', async function () { | ||
| await App.preferences.savePreferences({ | ||
| enableMultipleConnectionSystem: true, | ||
| }); | ||
| sinon.stub(process, 'platform').value('linux'); | ||
|
|
||
| expect(serializable(CompassMenu.getTemplate(0))).to.deep.equal([ | ||
| { | ||
| label: '&Connections', | ||
| submenu: [ | ||
| { label: '&Import Saved Connections' }, | ||
| { label: '&Export Saved Connections' }, | ||
| { type: 'separator' }, | ||
| { label: 'E&xit' }, | ||
| ], | ||
| }, | ||
| { | ||
| label: 'Edit', | ||
| submenu: [ | ||
| { label: 'Undo', role: 'undo' }, | ||
| { label: 'Redo', role: 'redo' }, | ||
| { type: 'separator' }, | ||
| { label: 'Cut', role: 'cut' }, | ||
| { label: 'Copy', role: 'copy' }, | ||
| { label: 'Paste', role: 'paste' }, | ||
| { | ||
| label: 'Select All', | ||
| role: 'selectAll', | ||
| }, | ||
| { type: 'separator' }, | ||
| { label: 'Find' }, | ||
| { type: 'separator' }, | ||
| { label: '&Settings' }, | ||
| ], | ||
| }, | ||
| { | ||
| label: '&View', | ||
| submenu: [ | ||
| { label: '&Reload' }, | ||
| { label: '&Reload Data' }, | ||
| { type: 'separator' }, | ||
| { label: 'Actual Size' }, | ||
| { label: 'Zoom In' }, | ||
| { label: 'Zoom Out' }, | ||
| ], | ||
| }, | ||
| { | ||
| label: '&Help', | ||
| submenu: [ | ||
| { label: `&Online ${app.getName()} Help` }, | ||
| { label: '&License' }, | ||
| { label: `&View Source Code on GitHub` }, | ||
| { label: `&Suggest a Feature` }, | ||
| { label: `&Report a Bug` }, | ||
| { label: '&Open Log File' }, | ||
| { type: 'separator' }, | ||
| { label: `&About ${app.getName()}` }, | ||
| { label: 'Check for updates…' }, | ||
| ], | ||
| }, | ||
| ]); | ||
| }); | ||
|
|
||
| it('does not crash when rendering menu item with an accelerator', async () => { | ||
| const menu = Menu.buildFromTemplate([ | ||
| { | ||
| label: 'Test Super', | ||
| accelerator: 'Super+Ctrl+T', | ||
| }, | ||
| { | ||
| label: 'Test Meta', | ||
| accelerator: 'Meta+Ctrl+T', | ||
| }, | ||
| ]); | ||
|
||
| const menuWillClose = once(menu, 'menu-will-close'); | ||
| menu.popup({ | ||
| window: new BrowserWindow({ show: false, width: 100, height: 100 }), | ||
| }); | ||
| menu.closePopup(); | ||
| await menuWillClose; | ||
| }); | ||
|
|
||
| it('should generate a menu template without collection submenu if `showCollection` is `false`', function () { | ||
| expect( | ||
| CompassMenu.getTemplate(0).find((item) => item.label === '&Collection') | ||
|
|
@@ -612,7 +697,12 @@ describe('CompassMenu', function () { | |
| label: '&Collection', | ||
| submenu: [ | ||
| { | ||
| accelerator: 'Alt+CmdOrCtrl+S', | ||
| // TODO(COMPASS-8505): Add `accelerator` back to this | ||
| ...(os.platform() === 'linux' | ||
| ? {} | ||
| : { | ||
| accelerator: 'Alt+CmdOrCtrl+S', | ||
| }), | ||
| label: '&Share Schema as JSON', | ||
| }, | ||
| { | ||
|
|
@@ -646,7 +736,12 @@ describe('CompassMenu', function () { | |
| label: '&Collection', | ||
| submenu: [ | ||
| { | ||
| accelerator: 'Alt+CmdOrCtrl+S', | ||
| // TODO(COMPASS-8505): Add `accelerator` back to this | ||
| ...(os.platform() === 'linux' | ||
| ? {} | ||
| : { | ||
| accelerator: 'Alt+CmdOrCtrl+S', | ||
| }), | ||
| label: '&Share Schema as JSON', | ||
| }, | ||
| { | ||
|
|
@@ -670,7 +765,12 @@ describe('CompassMenu', function () { | |
| expect( | ||
| menu.find((item: any) => item.label === '&Toggle DevTools') | ||
| ).to.deep.eq({ | ||
| accelerator: 'Alt+CmdOrCtrl+I', | ||
| // TODO(COMPASS-8505): Add `accelerator` back to this | ||
| ...(os.platform() === 'linux' | ||
| ? {} | ||
| : { | ||
| accelerator: 'Alt+CmdOrCtrl+I', | ||
| }), | ||
| label: '&Toggle DevTools', | ||
| }); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test, similar to the one that was added in the backport PR you opened, that checks that the menus we build are working on the platforms we're running these tests at?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in 2ef8483