-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6edb81
commit 8161829
Showing
13 changed files
with
4,464 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
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,17 @@ | ||
# Build jupyterlite deployment containing terminal extension for playwright tests. | ||
|
||
from pathlib import Path | ||
from subprocess import run | ||
|
||
import jupyterlab | ||
|
||
extra_labextensions_path = str(Path(jupyterlab.__file__).parent / "galata") | ||
cmd = [ | ||
"jupyter", | ||
"lite", | ||
"build", | ||
"--contents", | ||
"../demo/contents", | ||
f"--FederatedExtensionAddon.extra_labextensions_path={extra_labextensions_path}", | ||
] | ||
run(cmd, check=True) |
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,8 @@ | ||
{ | ||
"jupyter-lite-schema-version": 0, | ||
"jupyter-config-data": { | ||
"appName": "JupyterLite terminal UI Tests", | ||
"exposeAppInBrowser": true, | ||
"terminalsAvailable": true | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"LiteBuildConfig": { | ||
"output_dir": "dist" | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,24 +1,115 @@ | ||
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 }); | ||
|
||
// TODO: re-enable when testing with JupyterLite | ||
test.skip('should emit an activation console message', async ({ page }) => { | ||
const logs: string[] = []; | ||
|
||
page.on('console', message => { | ||
logs.push(message.text()); | ||
const TERMINAL_SELECTOR = '.jp-Terminal'; | ||
|
||
async function inputLine(page, text: string) { | ||
for (const char of text) { | ||
await page.keyboard.type(char); | ||
await page.waitForTimeout(10); | ||
} | ||
await page.keyboard.press('Enter'); | ||
} | ||
|
||
test.describe('Terminal extension', () => { | ||
test('should emit activation console messages', async ({ page }) => { | ||
const logs: string[] = []; | ||
page.on('console', message => { | ||
logs.push(message.text()); | ||
}); | ||
|
||
await page.goto(); | ||
|
||
expect( | ||
logs.filter(s => | ||
s.match(/^JupyterLite extension @jupyterlite\/terminal:.*is activated!/) | ||
) | ||
).toHaveLength(2); | ||
}); | ||
}); | ||
|
||
test.describe('Terminal', () => { | ||
test('should open via File menu', async ({ page }) => { | ||
await page.goto(); | ||
await page.menu.clickMenuItem('File>New>Terminal'); | ||
await page.locator(TERMINAL_SELECTOR).waitFor(); | ||
}); | ||
|
||
test('should appear in sidebar', async ({ page }) => { | ||
await page.goto(); | ||
await page.menu.clickMenuItem('File>New>Terminal'); | ||
await page.locator(TERMINAL_SELECTOR).waitFor(); | ||
await page.sidebar.openTab('jp-running-sessions'); | ||
await expect(page.locator('text=terminals/1')).toBeVisible(); | ||
}); | ||
|
||
test('should open via launcher', async ({ page }) => { | ||
await page.goto(); | ||
await page | ||
.locator('.jp-LauncherCard-label >> p:has-text("Terminal")') | ||
.click(); | ||
await page.locator(TERMINAL_SELECTOR).waitFor(); | ||
}); | ||
|
||
test('should create a new file', async ({ page }) => { | ||
await page.goto(); | ||
await page.menu.clickMenuItem('File>New>Terminal'); | ||
await page.locator(TERMINAL_SELECTOR).waitFor(); | ||
await page.locator('div.xterm-screen').click(); // sets focus for keyboard input | ||
|
||
await inputLine(page, 'echo Hello > out.txt'); | ||
await page.getByTitle('Name: out.txt').waitFor(); | ||
}); | ||
}); | ||
|
||
await page.goto(); | ||
test.describe('Images', () => { | ||
test('initial', async ({ page }) => { | ||
await page.goto(); | ||
await page.menu.clickMenuItem('File>New>Terminal'); | ||
await page.locator(TERMINAL_SELECTOR).waitFor(); | ||
await page.locator('div.xterm-screen').click(); // sets focus for keyboard input | ||
|
||
expect( | ||
logs.filter( | ||
s => s === 'JupyterLab extension @jupyterlite/terminal is activated!' | ||
) | ||
).toHaveLength(1); | ||
// Hide modification times. | ||
const modified = page.locator('span.jp-DirListing-itemModified'); | ||
await modified.evaluateAll(els => els.map(el => el.innerHTML = '')); | ||
|
||
const imageName = 'initial.png'; | ||
expect(await page.screenshot()).toMatchSnapshot(imageName.toLowerCase()); | ||
}); | ||
|
||
test('various commands', async ({ page }) => { | ||
await page.goto(); | ||
await page.menu.clickMenuItem('File>New>Terminal'); | ||
await page.locator(TERMINAL_SELECTOR).waitFor(); | ||
await page.locator('div.xterm-screen').click(); // sets focus for keyboard input | ||
|
||
const wait = 100; // milliseconds | ||
|
||
await inputLine(page, 'ls'); // avoid timestamps | ||
await page.waitForTimeout(wait); | ||
|
||
await inputLine(page, 'cp months.txt other.txt'); | ||
await page.waitForTimeout(wait); | ||
|
||
await inputLine(page, 'ls'); // avoid timestamps | ||
await page.waitForTimeout(wait); | ||
|
||
await inputLine(page, 'una\t'); // tab complete command name | ||
await page.waitForTimeout(wait); | ||
|
||
await inputLine(page, 'grep ember mon\t'); // tab complete filename | ||
await page.waitForTimeout(wait); | ||
|
||
await page.keyboard.press('Tab'); // list all commands | ||
await page.waitForTimeout(wait); | ||
|
||
await inputLine(page, 'abc'); // no such command | ||
await page.waitForTimeout(wait); | ||
|
||
// Hide modification times. | ||
const modified = page.locator('span.jp-DirListing-itemModified'); | ||
await modified.evaluateAll(els => els.map(el => el.innerHTML = '')); | ||
|
||
const imageName = 'various-commands.png'; | ||
expect(await page.screenshot()).toMatchSnapshot(imageName.toLowerCase()); | ||
}); | ||
}); |
Binary file added
BIN
+22.2 KB
ui-tests/tests/jupyterlite_terminal.spec.ts-snapshots/initial-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
+52 KB
ui-tests/tests/jupyterlite_terminal.spec.ts-snapshots/various-commands-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.