This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Start ui-tests
#167
Merged
Merged
Start ui-tests
#167
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
059735e
Start `ui-tests`
jtpio d50f481
Add workflows
jtpio 1273f02
Update gitignore
jtpio 5999f93
Update workflow
jtpio 94c6ac9
Add basic UI tests config
jtpio 63918d7
Add basic execute test
jtpio 9adb0c5
Install lab in workflow
jtpio 70971f8
setup conda env instead
jtpio d5865f4
Add defaults
jtpio 8e823be
Lint step
jtpio 59c1dbb
ignore ui-tests folder for now
jtpio 8d9b284
Fix linting later
jtpio 172558a
Remove duplicated lint step
jtpio aea94d4
Fix artifact name
jtpio cb031fc
Lint
jtpio cc7fea0
Fix ruff
jtpio 00e6ec7
Create notebook
jtpio 3933cce
Add workaround for firefox
jtpio be65005
Add launcher snapshot
jtpio 1f0af50
Add filesystem test
jtpio 35f4ef5
Update snapshots
jtpio cb46561
Increase test timeout
jtpio cc5e749
Only screenshot the launcher
jtpio 01f0617
update refs
jtpio 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ coverage | |
tests | ||
src/worker.ts | ||
src/web_worker_kernel.ts | ||
|
||
# TODO: remove | ||
ui-tests |
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,67 @@ | ||
name: Update Playwright Snapshots | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
update-snapshots: | ||
if: | ||
${{ github.event.issue.pull_request && contains(github.event.comment.body, 'update | ||
playwright snapshots') }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
browser: [firefox, chromium] | ||
|
||
steps: | ||
- name: React to the triggering comment | ||
run: | | ||
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Checkout the branch from the PR that triggered the job | ||
run: | | ||
# PR branch remote must be checked out using https URL | ||
git config --global hub.protocol https | ||
|
||
gh pr checkout ${{ github.event.issue.number }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Base Setup | ||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 | ||
|
||
- name: Build | ||
run: | | ||
# TODO: install addon | ||
|
||
# disable git hooks | ||
git config core.hooksPath no-hooks | ||
|
||
- name: Install the test dependencies | ||
run: | | ||
cd ui-tests | ||
jlpm | ||
jlpm build | ||
jlpm playwright install | ||
|
||
- name: Update snapshots | ||
uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
npm_client: jlpm | ||
test_folder: ui-tests | ||
start_server_script: 'null' | ||
update_script: test:update --browser ${{ matrix.browser }} | ||
env: | ||
DEBUG: pw:webserver |
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,107 @@ | ||
name: UI Tests | ||
|
||
on: [push, pull_request] | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Conda environment with Micromamba | ||
uses: mamba-org/setup-micromamba@v1 | ||
with: | ||
micromamba-version: '1.5.1-0' | ||
environment-file: environment.yml | ||
cache-environment: true | ||
|
||
- name: Install jupyterlite-xeus-python | ||
run: | | ||
jlpm | ||
jlpm run build | ||
python -m pip install -v . | ||
|
||
- name: Build UI tests | ||
run: | | ||
cd ui-tests | ||
jlpm | ||
# Build the JupyterLite website | ||
jlpm build | ||
|
||
- name: Upload the JupyterLite website | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: jupyterlite-xeus-python-ui-tests-app-${{ github.run_number }} | ||
path: ./ui-tests/ui-tests-app | ||
|
||
ui-tests: | ||
needs: [build] | ||
name: Visual Regression | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
browser: [firefox, chromium] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: jupyterlite-xeus-python-ui-tests-app-${{ github.run_number }} | ||
path: ./ui-tests/ui-tests-app | ||
|
||
- name: Base Setup | ||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 | ||
|
||
- name: Install dependencies and browser | ||
run: | | ||
# Install JupyterLab to get jlpm | ||
python -m pip install jupyterlab~=4.0 | ||
cd ui-tests | ||
jlpm | ||
jlpm playwright install ${{ matrix.browser }} --with-deps | ||
|
||
- name: Test | ||
run: | | ||
cd ui-tests | ||
jlpm run test --browser ${{ matrix.browser }} | ||
|
||
- name: Upload Playwright Test assets | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: jupyterlite-xeux-python-${{ matrix.browser }}-test-assets | ||
path: | | ||
ui-tests/test-results | ||
|
||
- name: Upload Playwright Test report | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: jupyterlite-xeus-python-${{ matrix.browser }}-test-report | ||
path: | | ||
ui-tests/playwright-report | ||
|
||
- name: Update snapshots | ||
if: failure() | ||
run: | | ||
cd ui-tests | ||
# remove previous snapshots from other browser | ||
jlpm run clean:snapshots | ||
# generate new snapshots | ||
jlpm run test:update --browser ${{ matrix.browser }} | ||
|
||
- name: Upload updated snapshots | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: jupyterlite-xeus-python-${{ matrix.browser }}-updated-snapshots | ||
path: ui-tests/test |
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,6 @@ | ||
enableImmutableInstalls: false | ||
enableInlineBuilds: false | ||
enableTelemetry: false | ||
httpTimeout: 60000 | ||
nodeLinker: node-modules | ||
npmRegistryServer: 'https://registry.yarnpkg.com' |
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 @@ | ||
""" | ||
Custom script to build the UI tests app and load the Galata extension | ||
""" | ||
|
||
from pathlib import Path | ||
from subprocess import run | ||
|
||
import jupyterlab | ||
|
||
extra_labextensions_path = str(Path(jupyterlab.__file__).parent / "galata") | ||
cmd = f"jupyter lite build --FederatedExtensionAddon.extra_labextensions_path={extra_labextensions_path}" | ||
|
||
run( | ||
cmd, | ||
check=True, | ||
shell=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,7 @@ | ||
{ | ||
"jupyter-lite-schema-version": 0, | ||
"jupyter-config-data": { | ||
"appName": "JupyterLite UI Tests", | ||
"exposeAppInBrowser": 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": "ui-tests-app" | ||
} | ||
} |
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,24 @@ | ||
{ | ||
"name": "@jupyterlite/jupyterlite-xeus-python-ui-tests", | ||
"private": true, | ||
"version": "0.1.0", | ||
"author": "JupyterLite Contributors", | ||
"license": "BSD-3-Clause", | ||
"description": "JupyterLite Xeus Python UI Tests", | ||
"scripts": { | ||
"build": "python build.py", | ||
"clean": "rimraf .jupyterlite.doit.db ui-tests-app", | ||
"clean:snapshots": "rimraf -g \"test/**/*-snapshots/*.png\"", | ||
"start": "cd ui-tests-app && python -m http.server -b 127.0.0.1 8000", | ||
"test": "playwright test", | ||
"test:report": "http-server ./playwright-report -a localhost -o", | ||
"test:update": "playwright test --update-snapshots" | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/galata": "~5.0.5", | ||
"@playwright/test": "^1.36.2" | ||
}, | ||
"devDependencies": { | ||
"rimraf": "^5" | ||
} | ||
} |
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,29 @@ | ||
const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
retries: 1, | ||
use: { | ||
acceptDownloads: true, | ||
appPath: '', | ||
autoGoto: false, | ||
baseURL: 'http://localhost:8000', | ||
trace: 'retain-on-failure', | ||
video: 'retain-on-failure', | ||
|
||
waitForApplication: async ({ baseURL }, use, testInfo) => { | ||
const waitIsReady = async page => { | ||
await page.waitForSelector('.jp-LauncherCard'); | ||
}; | ||
await use(waitIsReady); | ||
} | ||
}, | ||
webServer: [ | ||
{ | ||
command: 'jlpm run start', | ||
port: 8000, | ||
timeout: 120 * 1000, | ||
reuseExistingServer: 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,26 @@ | ||
// Copyright (c) JupyterLite Contributors | ||
// Distributed under the terms of the Modified BSD License. | ||
|
||
import { test } from '@jupyterlab/galata'; | ||
|
||
import { expect } from '@playwright/test'; | ||
|
||
import { firefoxWaitForApplication } from './utils'; | ||
|
||
test.use({ waitForApplication: firefoxWaitForApplication }); | ||
|
||
test.describe('Code execution', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('lab/index.html'); | ||
}); | ||
|
||
test('Basic code execution', async ({ page }) => { | ||
await page.notebook.createNew(); | ||
await page.notebook.setCell(0, 'code', '2 + 2'); | ||
await page.notebook.run(); | ||
const output = await page.notebook.getCellTextOutput(0); | ||
|
||
expect(output).toBeTruthy(); | ||
expect(output![0]).toBe('4'); | ||
}); | ||
}); |
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.
Ah I missed this one.
Happy to track it in a separate issue to not block this PR if that's fine.