-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add some playwright ui tests #33
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8161829
Add some playwright ui tests
invalid-email-address 3e46a34
Linting
ianthomas23 2cbb2cc
Install jupyterlite-core in integration-tests
ianthomas23 e82d5f2
Pin jupyterlite-core
invalid-email-address fa38ba0
Use separate directory to deploy
invalid-email-address 40a4db2
Install micromamba for ui-tests deployment
ianthomas23 8ab5827
Fix update-snapshots github action
ianthomas23 d2c6894
Manually update ui-test images
invalid-email-address 3a8c7ae
Allow retries for ui-tests
invalid-email-address 9f6c350
Fix deploy.yml
invalid-email-address 86610fb
Correct vercel settings
invalid-email-address 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
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.
Oops, something went wrong.
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.
Maybe there could be a pin on
jupyterlite-core
here, as new versions may bring some visual changes that would make the UI tests fail?For example
jupyterlite-core==0.5.0
will be based on JupyterLab 4.3 and Notebook 7.3, which may have some CSS changes compared tojupyterlite-core==0.4.x
.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.
Yes, I'll do that.