-
Notifications
You must be signed in to change notification settings - Fork 98
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
Windows/Linux "About" window #885
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
501eaf2
Open about box on menu click (on Windows and Linux)
mappum 74bf654
Merge branch 'develop' into matt/767-windows-about
mappum e016950
On windows and linux, 'About Voyager' menu item navigates to Preferen…
mappum 6f7525a
Updated changelog
mappum ade4a28
Merge branch 'develop' into matt/767-windows-about
faboweb aecb48d
Merge branch 'develop' into matt/767-windows-about
mappum b9aeb17
Added spec for native app menu
mappum da5d366
Added coverage to renderer 'open-about-menu' IPC message
mappum 150795b
Merge branch 'develop' into matt/767-windows-about
NodeGuy ab8a90e
Merge remote-tracking branch 'origin/develop' into matt/767-windows-a…
11d50bb
removed menu tests
d700de8
Merge branch 'develop' into matt/767-windows-about
faboweb 017fa16
added /about route
bde5bca
Merge branch 'develop' into matt/767-windows-about
faboweb 94b1de1
moving to about when clicking on about in menu
1992cbe
fixed tests
1f58128
Merge branch 'matt/767-windows-about' of https://github.com/cosmos/vo…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`App Menu should create the app menu 1`] = ` | ||
Array [ | ||
Array [ | ||
Array [ | ||
Object { | ||
"label": "Cosmos Voyager", | ||
"submenu": Array [ | ||
Object { | ||
"click": [Function], | ||
"label": "About Cosmos Voyager", | ||
"selector": "orderFrontStandardAboutPanel:", | ||
}, | ||
Object { | ||
"type": "separator", | ||
}, | ||
Object { | ||
"accelerator": "Command+Q", | ||
"click": [Function], | ||
"label": "Quit", | ||
}, | ||
], | ||
}, | ||
Object { | ||
"label": "Edit", | ||
"submenu": Array [ | ||
Object { | ||
"accelerator": "CmdOrCtrl+X", | ||
"label": "Cut", | ||
"selector": "cut:", | ||
}, | ||
Object { | ||
"accelerator": "CmdOrCtrl+C", | ||
"label": "Copy", | ||
"selector": "copy:", | ||
}, | ||
Object { | ||
"accelerator": "CmdOrCtrl+V", | ||
"label": "Paste", | ||
"selector": "paste:", | ||
}, | ||
], | ||
}, | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`App Menu should create the app menu 2`] = ` | ||
Array [ | ||
Array [ | ||
undefined, | ||
], | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const { join } = require("path") | ||
|
||
let mainWindow | ||
describe("App Menu", () => { | ||
beforeEach(() => { | ||
jest.resetModules() | ||
jest.unmock("electron") | ||
|
||
mainWindow = { | ||
webContents: { send: jest.fn() } | ||
} | ||
|
||
jest.mock("electron", () => ({ | ||
Menu: { | ||
buildFromTemplate: jest.fn(menu => { | ||
menu | ||
}), | ||
setApplicationMenu: jest.fn() | ||
}, | ||
app: { | ||
quit: jest.fn() | ||
} | ||
})) | ||
|
||
let createMenu = require("../../../app/src/main/menu.js") | ||
|
||
createMenu(mainWindow) | ||
}) | ||
|
||
it("should create the app menu", function() { | ||
expect( | ||
require("electron").Menu.buildFromTemplate.mock.calls | ||
).toMatchSnapshot() | ||
expect( | ||
require("electron").Menu.setApplicationMenu.mock.calls | ||
).toMatchSnapshot() | ||
}) | ||
|
||
it("should quit app when clicking Quit menu item", function() { | ||
let menu = require("electron").Menu.buildFromTemplate.mock.calls[0][0] | ||
let quitItem = menu | ||
.find(({ label }) => label === "Cosmos Voyager") | ||
.submenu.find(({ label }) => label === "Quit") | ||
|
||
expect(require("electron").app.quit.mock.calls.length).toBe(0) | ||
quitItem.click() | ||
expect(require("electron").app.quit.mock.calls.length).toBe(1) | ||
}) | ||
|
||
it("should send 'open-about-menu' when clicking 'About'", function() { | ||
process.platform = "linux" | ||
let menu = require("electron").Menu.buildFromTemplate.mock.calls[0][0] | ||
let aboutItem = menu | ||
.find(({ label }) => label === "Cosmos Voyager") | ||
.submenu.find(({ label }) => label === "About Cosmos Voyager") | ||
|
||
expect(mainWindow.webContents.send.mock.calls.length).toBe(0) | ||
aboutItem.click() | ||
expect(mainWindow.webContents.send.mock.calls.length).toBe(1) | ||
expect(mainWindow.webContents.send.mock.calls[0][0]).toBe("open-about-menu") | ||
}) | ||
|
||
it("should not send 'open-about-menu' when clicking 'About' on mac", function() { | ||
process.platform = "darwin" | ||
let menu = require("electron").Menu.buildFromTemplate.mock.calls[0][0] | ||
let aboutItem = menu | ||
.find(({ label }) => label === "Cosmos Voyager") | ||
.submenu.find(({ label }) => label === "About Cosmos Voyager") | ||
|
||
expect(mainWindow.webContents.send.mock.calls.length).toBe(0) | ||
aboutItem.click() | ||
expect(mainWindow.webContents.send.mock.calls.length).toBe(0) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You put in a lot of effort into this! Thank you!
I feel a little ambivalent about testing the menu function of electron. I just ignored the file: https://github.com/cosmos/voyager/pull/900/files#diff-50315a6edc0ec04526f1b8c64d3f1b24R24
I would like to get your opinion.