-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new deploy app command * update readme * Remove unnecessary notebook * Remove unnecessary snapshots * Update Playwright Snapshots * remove unnecesary junit file * Simplify icon logic * Update icon to work across Jupyter themes * Remove darwin files * Remove class from <svg> * Remove uneeded async * Simplify switch logic * Ensure kernel is in idle state * Update tests * Update Playwright Snapshots * Add PR suggestions * Change tests to hide kernel status indicator * lint * Update Playwright Snapshots * Tidy unneeded asyncs --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e2a2aa1
commit 0e0faf6
Showing
15 changed files
with
15,069 additions
and
44 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 |
---|---|---|
|
@@ -126,3 +126,6 @@ dmypy.json | |
|
||
# virtualenv | ||
.venv/ | ||
|
||
# JUnit test results | ||
junit.xml |
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,42 @@ | ||
{ | ||
"jupyter.lab.menus": { | ||
"main": [ | ||
{ | ||
"id": "jp-mainmenu-services", | ||
"label": "Services", | ||
"rank": 1000, | ||
"items": [ | ||
{ | ||
"command": "jhub-apps:deploy-app", | ||
"args": { | ||
"origin": "main-menu" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"context": [ | ||
{ | ||
"command": "jhub-apps:deploy-app", | ||
"args": { | ||
"origin": "context-menu" | ||
}, | ||
"selector": ".jp-DirListing-item[data-isdir=\"false\"]", | ||
"rank": 3 | ||
} | ||
] | ||
}, | ||
"jupyter.lab.toolbars": { | ||
"Notebook": [ | ||
{ | ||
"name": "deploy-app", | ||
"command": "jhub-apps:deploy-app" | ||
} | ||
] | ||
}, | ||
"title": "jupyterlab-jhub-apps", | ||
"description": "jupyterlab-jhub-apps custom command settings.", | ||
"type": "object", | ||
"properties": {}, | ||
"additionalProperties": false | ||
} |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import { LabIcon } from '@jupyterlab/ui-components'; | ||
import deployApp from '../style/icons/deploy-app.svg'; | ||
|
||
export const deployAppIcon = new LabIcon({ | ||
name: 'jhub-apps:deploy-app', | ||
svgstr: deployApp | ||
}); |
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,4 @@ | ||
declare module '*.svg' { | ||
const script: string; | ||
export default script; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,21 +1,139 @@ | ||
import { expect, test } from '@jupyterlab/galata'; | ||
|
||
/** | ||
* Don't load JupyterLab webpage before running the tests. | ||
* This is required to ensure we capture all log messages. | ||
*/ | ||
test.use({ autoGoto: false }); | ||
test('should have Deploy App entry in Services menu', async ({ page }) => { | ||
await page.click('text=Services'); | ||
|
||
test('should emit an activation console message', async ({ page }) => { | ||
const logs: string[] = []; | ||
const deployAppEntry = page.locator('.lm-Menu-item:has-text("Deploy App")'); | ||
await expect(deployAppEntry).toBeVisible(); | ||
|
||
page.on('console', message => { | ||
logs.push(message.text()); | ||
const servicesMenu = page.locator('.lm-Menu-content'); | ||
expect(await servicesMenu.screenshot()).toMatchSnapshot( | ||
'services-menu-with-deploy-app.png' | ||
); | ||
}); | ||
|
||
test('should have Deploy App icon in notebook toolbar', async ({ page }) => { | ||
await page.notebook.createNew(); | ||
|
||
await page.waitForSelector('.jp-NotebookPanel-toolbar'); | ||
|
||
const deployAppIcon = page.locator( | ||
'.jp-Toolbar-item[data-jp-item-name="deploy-app"]' | ||
); | ||
await expect(deployAppIcon).toBeVisible(); | ||
|
||
// hack to hide kernel status indicator - otherwise toggle between idle and busy on startup | ||
// and test will fail randomly | ||
await page.evaluate(() => { | ||
const kernelStatus = document.querySelector( | ||
'.jp-NotebookPanel-toolbar .jp-Notebook-ExecutionIndicator' | ||
) as HTMLElement; | ||
if (kernelStatus) { | ||
kernelStatus.style.display = 'none'; | ||
} | ||
}); | ||
|
||
const notebookToolbar = page.locator('.jp-NotebookPanel-toolbar'); | ||
expect(await notebookToolbar.screenshot()).toMatchSnapshot( | ||
'notebook-toolbar-before-click.png' | ||
); | ||
}); | ||
|
||
test('should show Deploy App option in context menu', async ({ page }) => { | ||
await page.click('text=Python 3'); | ||
await page.waitForSelector('.jp-NotebookPanel'); | ||
|
||
await page.waitForSelector('.jp-DirListing-item[data-isdir="false"]'); | ||
|
||
const notebookItem = page | ||
.locator('.jp-DirListing-item[data-isdir="false"]') | ||
.first(); | ||
await notebookItem.click({ button: 'right' }); | ||
|
||
const deployAppOption = page.locator('.lm-Menu-item:has-text("Deploy App")'); | ||
await expect(deployAppOption).toBeVisible(); | ||
|
||
const contextMenu = page.locator('.lm-Menu-content'); | ||
expect(await contextMenu.screenshot()).toMatchSnapshot( | ||
'notebook-context-menu-with-deploy-app.png' | ||
); | ||
}); | ||
|
||
test.describe('Deploy App with different notebook names to test URL encoding', () => { | ||
const testCases = [ | ||
{ name: 'My Notebook.ipynb', expected: 'My%20Notebook.ipynb' }, | ||
{ name: 'Untitled.ipynb', expected: 'Untitled.ipynb' }, | ||
{ | ||
name: 'special!@#$%^&*().ipynb', | ||
expected: 'special!%40%23%24%25%5E%26*().ipynb' | ||
} | ||
]; | ||
|
||
testCases.forEach(({ name, expected }) => { | ||
test(`should generate correct encoding for "${name}"`, async ({ | ||
page, | ||
context, | ||
tmpPath | ||
}) => { | ||
await page.notebook.createNew(name); | ||
|
||
const notebookItem = page | ||
.locator('.jp-DirListing-item[data-isdir="false"]') | ||
.first(); | ||
await notebookItem.click({ button: 'right' }); | ||
const deployAppOption = page.locator( | ||
'.lm-Menu-item:has-text("Deploy App")' | ||
); | ||
await deployAppOption.click(); | ||
|
||
const newPage = await context.waitForEvent('page'); | ||
await newPage.waitForLoadState('load'); | ||
|
||
const fullUrl = newPage.url(); | ||
const filepathParam = fullUrl.split('filepath=')[1]; | ||
expect(filepathParam).toBe(tmpPath + '%2F' + expected); | ||
|
||
await newPage.close(); | ||
}); | ||
}); | ||
}); | ||
|
||
test('check that the filepath parameter is not present in the URL when no notebook is open', async ({ | ||
page, | ||
context | ||
}) => { | ||
const newPagePromise = context.waitForEvent('page'); | ||
|
||
await page.evaluate(() => { | ||
window.jupyterapp.commands.execute('jhub-apps:deploy-app'); | ||
}); | ||
|
||
await page.goto(); | ||
const newPage = await newPagePromise; | ||
|
||
expect( | ||
logs.filter(s => s === 'JupyterLab extension jupyterlab-jhub-apps is activated!') | ||
).toHaveLength(1); | ||
await newPage.waitForLoadState('load'); | ||
|
||
const url = new URL(newPage.url()); | ||
expect(url.searchParams.has('filepath')).toBe(false); | ||
|
||
await newPage.close(); | ||
}); | ||
|
||
test.describe('should register custom commands', () => { | ||
test('jhub-apps:deploy-app command works', async ({ page }) => { | ||
const deployAppMainMenu = await page.evaluate(async () => { | ||
const registry = window.jupyterapp.commands; | ||
const id = 'jhub-apps:deploy-app'; | ||
const args = { origin: 'main-menu' }; | ||
|
||
return { | ||
id, | ||
label: registry.label(id, args), | ||
isEnabled: registry.isEnabled(id, args) | ||
}; | ||
}); | ||
|
||
expect(deployAppMainMenu.label).toBe('Deploy App'); | ||
|
||
expect(deployAppMainMenu.isEnabled).toBe(true); | ||
}); | ||
}); |
Binary file added
BIN
+17.8 KB
...lab_jhub_apps.spec.ts-snapshots/notebook-context-menu-with-deploy-app-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.07 KB
.../jupyterlab_jhub_apps.spec.ts-snapshots/notebook-toolbar-before-click-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+562 Bytes
.../jupyterlab_jhub_apps.spec.ts-snapshots/services-menu-with-deploy-app-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.