forked from jupyter-server/jupyter_server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File Radar Extension (jupyter-server#158)
* add file radar extension * add extension to plugin list * explicitly calculate coverage from all files * jest config point at ts * working tests * remove unnecessary testing logic * add yarn.lock back in and remove unused imports in test/utils * bump test coverage threshold
- Loading branch information
Showing
5 changed files
with
107 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { IMainMenu } from '@jupyterlab/mainmenu'; | ||
|
||
import { | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
|
||
/** | ||
* Build an external links menu item. | ||
*/ | ||
export const FileRadarPlugin: JupyterFrontEndPlugin<void> = { | ||
id: 'data_studio:file_radar_plugin', | ||
autoStart: true, | ||
requires: [IMainMenu], | ||
activate: (app: JupyterFrontEnd, mainMenu: IMainMenu) => { | ||
console.log('JupyterLab extension "File Radar" is activated!'); | ||
|
||
const radarUrl = | ||
'rdar://new/problem/component=ACI%20Data%20Studio&version=Support'; | ||
const commandID = 'help:file-radar'; | ||
|
||
app.commands.addCommand(commandID, { | ||
label: 'File a Radar', | ||
isEnabled: () => true, | ||
isVisible: () => true, | ||
execute: () => { | ||
window.open(radarUrl); | ||
} | ||
}); | ||
|
||
mainMenu.helpMenu.addGroup([ | ||
{ | ||
command: commandID | ||
} | ||
]); | ||
} | ||
}; |
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,65 @@ | ||
// import { CommandRegistry } from '@lumino/commands'; | ||
|
||
import { JupyterLab } from '@jupyterlab/application'; | ||
|
||
import { MainMenu } from '@jupyterlab/mainmenu'; | ||
import { CommandRegistry } from '@lumino/commands'; | ||
import { JupyterServer } from '@jupyterlab/testutils'; | ||
|
||
import { FileRadarPlugin } from '../src/fileradar'; | ||
|
||
jest.useFakeTimers(); // Keep at the Top of the file | ||
const server = new JupyterServer(); | ||
|
||
beforeAll(async () => { | ||
jest.setTimeout(20000); | ||
await server.start(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await server.shutdown(); | ||
}); | ||
|
||
describe('status', () => { | ||
let app: JupyterLab; | ||
let registry: CommandRegistry; | ||
let mainMenu: MainMenu; | ||
|
||
beforeEach(async () => { | ||
// Wait for the server to start before creating the application | ||
// so we pick up the page config (base url, etc.) | ||
app = new JupyterLab(); | ||
registry = app.commands; | ||
mainMenu = new MainMenu(registry); | ||
}); | ||
|
||
it('should handle file radar link', () => { | ||
FileRadarPlugin.activate(app, mainMenu); | ||
const registry = app.commands; | ||
const helpMenu = mainMenu.helpMenu; | ||
const commandID = 'help:file-radar'; | ||
|
||
// Assert that the command is registered when the | ||
// extension is activated. | ||
expect(registry.hasCommand(commandID)).toEqual(true); | ||
// Assert that the helpmenu includes the new item. | ||
expect(helpMenu.items).toEqual( | ||
expect.arrayContaining([expect.objectContaining({ command: commandID })]) | ||
); | ||
|
||
// Set up a spy to see if the window opens | ||
// a radar. | ||
const closeSpy = jest.fn(); | ||
window.open = jest.fn().mockReturnValue({ close: closeSpy }); | ||
window.close = jest.fn(); | ||
|
||
// Execute the command and assert that a radar is opened. | ||
registry.execute(commandID); | ||
expect(window.open).toHaveBeenCalled(); | ||
expect(window.open).toHaveBeenCalledWith( | ||
'rdar://new/problem/component=ACI%20Data%20Studio&version=Support' | ||
); | ||
|
||
jest.runAllTimers(); | ||
}); | ||
}); |
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