initit
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
commit
7798234edf
|
@ -0,0 +1,8 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
coverage
|
||||||
|
**/*.d.ts
|
||||||
|
tests
|
||||||
|
|
||||||
|
**/__tests__
|
||||||
|
ui-tests
|
|
@ -0,0 +1,39 @@
|
||||||
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended'
|
||||||
|
],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
sourceType: 'module'
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/naming-convention': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
selector: 'interface',
|
||||||
|
format: ['PascalCase'],
|
||||||
|
custom: {
|
||||||
|
regex: '^I[A-Z]',
|
||||||
|
match: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-namespace': 'off',
|
||||||
|
'@typescript-eslint/no-use-before-define': 'off',
|
||||||
|
'@typescript-eslint/quotes': [
|
||||||
|
'error',
|
||||||
|
'single',
|
||||||
|
{ avoidEscape: true, allowTemplateLiterals: false }
|
||||||
|
],
|
||||||
|
curly: ['error', 'all'],
|
||||||
|
eqeqeq: 'error',
|
||||||
|
'prefer-arrow-callback': 'error'
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,150 @@
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: main
|
||||||
|
pull_request:
|
||||||
|
branches: '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Base Setup
|
||||||
|
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: python -m pip install -U jupyterlab~=3.1
|
||||||
|
|
||||||
|
- name: Lint the extension
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
jlpm
|
||||||
|
jlpm run lint:check
|
||||||
|
|
||||||
|
- name: Test the extension
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
jlpm run test
|
||||||
|
|
||||||
|
- name: Build the extension
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
python -m pip install .[test]
|
||||||
|
|
||||||
|
jupyter labextension list
|
||||||
|
jupyter labextension list 2>&1 | grep -ie "jupyterlab-sandbox-announcement.*OK"
|
||||||
|
python -m jupyterlab.browser_check
|
||||||
|
|
||||||
|
- name: Package the extension
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
pip install build
|
||||||
|
python -m build
|
||||||
|
pip uninstall -y "jupyterlab-sandbox-announcement" jupyterlab
|
||||||
|
|
||||||
|
- name: Upload extension packages
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: extension-artifacts
|
||||||
|
path: dist/jupyterlab-sandbox-announcement*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
test_isolated:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Install Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.9'
|
||||||
|
architecture: 'x64'
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: extension-artifacts
|
||||||
|
- name: Install and Test
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
# Remove NodeJS, twice to take care of system and locally installed node versions.
|
||||||
|
sudo rm -rf $(which node)
|
||||||
|
sudo rm -rf $(which node)
|
||||||
|
|
||||||
|
pip install "jupyterlab~=3.1" jupyterlab-sandbox-announcement*.whl
|
||||||
|
|
||||||
|
|
||||||
|
jupyter labextension list
|
||||||
|
jupyter labextension list 2>&1 | grep -ie "jupyterlab-sandbox-announcement.*OK"
|
||||||
|
python -m jupyterlab.browser_check --no-chrome-test
|
||||||
|
|
||||||
|
integration-tests:
|
||||||
|
name: Integration tests
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
env:
|
||||||
|
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Base Setup
|
||||||
|
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||||
|
|
||||||
|
- name: Download extension package
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: extension-artifacts
|
||||||
|
|
||||||
|
- name: Install the extension
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
python -m pip install "jupyterlab~=3.1" jupyterlab-sandbox-announcement*.whl
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
working-directory: ui-tests
|
||||||
|
env:
|
||||||
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||||
|
run: jlpm install
|
||||||
|
|
||||||
|
- name: Set up browser cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ github.workspace }}/pw-browsers
|
||||||
|
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
|
||||||
|
|
||||||
|
- name: Install browser
|
||||||
|
run: jlpm playwright install chromium
|
||||||
|
working-directory: ui-tests
|
||||||
|
|
||||||
|
- name: Execute integration tests
|
||||||
|
working-directory: ui-tests
|
||||||
|
run: |
|
||||||
|
jlpm playwright test
|
||||||
|
|
||||||
|
- name: Upload Playwright Test report
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: jupyterlab-sandbox-announcement-playwright-tests
|
||||||
|
path: |
|
||||||
|
ui-tests/test-results
|
||||||
|
ui-tests/playwright-report
|
||||||
|
|
||||||
|
check_links:
|
||||||
|
name: Check Links
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||||
|
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
|
|
@ -0,0 +1,29 @@
|
||||||
|
name: Check Release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["*"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Base Setup
|
||||||
|
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
pip install -e .
|
||||||
|
- name: Check Release
|
||||||
|
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
|
||||||
|
with:
|
||||||
|
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Upload Distributions
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: jupyterlab-sandbox-announcement-releaser-dist-${{ github.run_number }}
|
||||||
|
path: .jupyter_releaser_checkout/dist
|
|
@ -0,0 +1,50 @@
|
||||||
|
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, 'please update playwright snapshots') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Configure git to use https
|
||||||
|
run: git config --global hub.protocol https
|
||||||
|
|
||||||
|
- name: Checkout the branch from the PR that triggered the job
|
||||||
|
run: hub 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: Install dependencies
|
||||||
|
run: python -m pip install -U jupyterlab~=3.1
|
||||||
|
|
||||||
|
- name: Install extension
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
jlpm
|
||||||
|
python -m pip install .
|
||||||
|
|
||||||
|
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# Playwright knows how to start JupyterLab server
|
||||||
|
start_server_script: 'null'
|
||||||
|
test_folder: ui-tests
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
*.bundle.*
|
||||||
|
lib/
|
||||||
|
node_modules/
|
||||||
|
*.log
|
||||||
|
.eslintcache
|
||||||
|
.stylelintcache
|
||||||
|
*.egg-info/
|
||||||
|
.ipynb_checkpoints
|
||||||
|
*.tsbuildinfo
|
||||||
|
jupyterlab-sandbox-announcement/labextension
|
||||||
|
# Version file is handled by hatchling
|
||||||
|
jupyterlab-sandbox-announcement/_version.py
|
||||||
|
|
||||||
|
# Integration tests
|
||||||
|
ui-tests/test-results/
|
||||||
|
ui-tests/playwright-report/
|
||||||
|
|
||||||
|
# Created by https://www.gitignore.io/api/python
|
||||||
|
# Edit at https://www.gitignore.io/?templates=python
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage/
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# Mr Developer
|
||||||
|
.mr.developer.cfg
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/python
|
||||||
|
|
||||||
|
# OSX files
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,6 @@
|
||||||
|
node_modules
|
||||||
|
**/node_modules
|
||||||
|
**/lib
|
||||||
|
**/package.json
|
||||||
|
!/package.json
|
||||||
|
jupyterlab-sandbox-announcement
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"endOfLine": "auto"
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"stylelint-config-recommended",
|
||||||
|
"stylelint-config-standard",
|
||||||
|
"stylelint-prettier/recommended"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"property-no-vendor-prefix": null,
|
||||||
|
"selector-no-vendor-prefix": null,
|
||||||
|
"value-no-vendor-prefix": null
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
pipeline:
|
||||||
|
build-package:
|
||||||
|
image: nikolaik/python-nodejs:python3.7-nodejs19
|
||||||
|
commands:
|
||||||
|
- apt update && apt install build-essential -y
|
||||||
|
- python -m pip install -U jupyterlab~=3.5.2 build twine
|
||||||
|
- python -m build -s
|
||||||
|
- python -m twine upload dist/* --repository-url=$TWINE_REPOSITORY_URL
|
||||||
|
secrets: [ TWINE_USERNAME, TWINE_PASSWORD, TWINE_REPOSITORY, TWINE_REPOSITORY_URL]
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
<!-- <START NEW CHANGELOG ENTRY> -->
|
||||||
|
|
||||||
|
<!-- <END NEW CHANGELOG ENTRY> -->
|
|
@ -0,0 +1,29 @@
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2023, Malte Grosse
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,96 @@
|
||||||
|
# jupyterlab-sandbox-announcement
|
||||||
|
|
||||||
|
[![Github Actions Status](https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab-sandbox-announcement/workflows/Build/badge.svg)](https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab-sandbox-announcement/actions/workflows/build.yml)
|
||||||
|
Sandbox announcements for Jupyterlab
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- JupyterLab >= 3.0
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
To install the extension, execute:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install jupyterlab-sandbox-announcement
|
||||||
|
```
|
||||||
|
|
||||||
|
## Uninstall
|
||||||
|
|
||||||
|
To remove the extension, execute:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip uninstall jupyterlab-sandbox-announcement
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
### Development install
|
||||||
|
|
||||||
|
Note: You will need NodeJS to build the extension package.
|
||||||
|
|
||||||
|
The `jlpm` command is JupyterLab's pinned version of
|
||||||
|
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
|
||||||
|
`yarn` or `npm` in lieu of `jlpm` below.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone the repo to your local environment
|
||||||
|
# Change directory to the jupyterlab-sandbox-announcement directory
|
||||||
|
# Install package in development mode
|
||||||
|
pip install -e "."
|
||||||
|
# Link your development version of the extension with JupyterLab
|
||||||
|
jupyter labextension develop . --overwrite
|
||||||
|
# Rebuild extension Typescript source after making changes
|
||||||
|
jlpm build
|
||||||
|
```
|
||||||
|
|
||||||
|
You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Watch the source directory in one terminal, automatically rebuilding when needed
|
||||||
|
jlpm watch
|
||||||
|
# Run JupyterLab in another terminal
|
||||||
|
jupyter lab
|
||||||
|
```
|
||||||
|
|
||||||
|
With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
|
||||||
|
|
||||||
|
By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
jupyter lab build --minimize=False
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development uninstall
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip uninstall jupyterlab-sandbox-announcement
|
||||||
|
```
|
||||||
|
|
||||||
|
In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
|
||||||
|
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
|
||||||
|
folder is located. Then you can remove the symlink named `jupyterlab-sandbox-announcement` within that folder.
|
||||||
|
|
||||||
|
### Testing the extension
|
||||||
|
|
||||||
|
#### Frontend tests
|
||||||
|
|
||||||
|
This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.
|
||||||
|
|
||||||
|
To execute them, execute:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
jlpm
|
||||||
|
jlpm test
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Integration tests
|
||||||
|
|
||||||
|
This extension uses [Playwright](https://playwright.dev/docs/intro/) for the integration tests (aka user level tests).
|
||||||
|
More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.
|
||||||
|
|
||||||
|
More information are provided within the [ui-tests](./ui-tests/README.md) README.
|
||||||
|
|
||||||
|
### Packaging the extension
|
||||||
|
|
||||||
|
See [RELEASE](RELEASE.md)
|
|
@ -0,0 +1,68 @@
|
||||||
|
# Making a new release of jupyterlab-sandbox-announcement
|
||||||
|
|
||||||
|
The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).
|
||||||
|
|
||||||
|
## Manual release
|
||||||
|
|
||||||
|
### Python package
|
||||||
|
|
||||||
|
This extension can be distributed as Python
|
||||||
|
packages. All of the Python
|
||||||
|
packaging instructions in the `pyproject.toml` file to wrap your extension in a
|
||||||
|
Python package. Before generating a package, we first need to install `build`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install build twine hatch
|
||||||
|
```
|
||||||
|
|
||||||
|
Bump the version using `hatch`. By default this will create a tag.
|
||||||
|
See the docs on [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version#semver) for details.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hatch version <new-version>
|
||||||
|
```
|
||||||
|
|
||||||
|
To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m build
|
||||||
|
```
|
||||||
|
|
||||||
|
> `python setup.py sdist bdist_wheel` is deprecated and will not work for this package.
|
||||||
|
|
||||||
|
Then to upload the package to PyPI, do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
twine upload dist/*
|
||||||
|
```
|
||||||
|
|
||||||
|
### NPM package
|
||||||
|
|
||||||
|
To publish the frontend part of the extension as a NPM package, do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm login
|
||||||
|
npm publish --access public
|
||||||
|
```
|
||||||
|
|
||||||
|
## Automated releases with the Jupyter Releaser
|
||||||
|
|
||||||
|
The extension repository should already be compatible with the Jupyter Releaser.
|
||||||
|
|
||||||
|
Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for more information.
|
||||||
|
|
||||||
|
Here is a summary of the steps to cut a new release:
|
||||||
|
|
||||||
|
- Fork the [`jupyter-releaser` repo](https://github.com/jupyter-server/jupyter_releaser)
|
||||||
|
- Add `ADMIN_GITHUB_TOKEN`, `PYPI_TOKEN` and `NPM_TOKEN` to the Github Secrets in the fork
|
||||||
|
- Go to the Actions panel
|
||||||
|
- Run the "Draft Changelog" workflow
|
||||||
|
- Merge the Changelog PR
|
||||||
|
- Run the "Draft Release" workflow
|
||||||
|
- Run the "Publish Release" workflow
|
||||||
|
|
||||||
|
## Publishing to `conda-forge`
|
||||||
|
|
||||||
|
If the package is not on conda forge yet, check the documentation to learn how to add it: https://conda-forge.org/docs/maintainer/adding_pkgs.html
|
||||||
|
|
||||||
|
Otherwise a bot should pick up the new version publish to PyPI, and open a new PR on the feedstock repository automatically.
|
|
@ -0,0 +1 @@
|
||||||
|
module.exports = require('@jupyterlab/testutils/lib/babel.config');
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"packageManager": "python",
|
||||||
|
"packageName": "jupyterlab-sandbox-announcement",
|
||||||
|
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab-sandbox-announcement"
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config');
|
||||||
|
|
||||||
|
const esModules = [
|
||||||
|
'@jupyterlab/',
|
||||||
|
'lib0',
|
||||||
|
'y\\-protocols',
|
||||||
|
'y\\-websocket',
|
||||||
|
'yjs'
|
||||||
|
].join('|');
|
||||||
|
|
||||||
|
const jlabConfig = jestJupyterLab(__dirname);
|
||||||
|
|
||||||
|
const {
|
||||||
|
moduleFileExtensions,
|
||||||
|
moduleNameMapper,
|
||||||
|
preset,
|
||||||
|
setupFilesAfterEnv,
|
||||||
|
setupFiles,
|
||||||
|
testPathIgnorePatterns,
|
||||||
|
transform
|
||||||
|
} = jlabConfig;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
moduleFileExtensions,
|
||||||
|
moduleNameMapper,
|
||||||
|
preset,
|
||||||
|
setupFilesAfterEnv,
|
||||||
|
setupFiles,
|
||||||
|
testPathIgnorePatterns,
|
||||||
|
transform,
|
||||||
|
automock: false,
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'src/**/*.{ts,tsx}',
|
||||||
|
'!src/**/*.d.ts',
|
||||||
|
'!src/**/.ipynb_checkpoints/*'
|
||||||
|
],
|
||||||
|
coverageDirectory: 'coverage',
|
||||||
|
coverageReporters: ['lcov', 'text'],
|
||||||
|
globals: {
|
||||||
|
'ts-jest': {
|
||||||
|
tsconfig: 'tsconfig.json'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
testRegex: 'src/.*/.*.spec.ts[x]?$',
|
||||||
|
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
from ._version import __version__
|
||||||
|
|
||||||
|
|
||||||
|
def _jupyter_labextension_paths():
|
||||||
|
return [{
|
||||||
|
"src": "labextension",
|
||||||
|
"dest": "jupyterlab-sandbox-announcement"
|
||||||
|
}]
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
{
|
||||||
|
"name": "jupyterlab-sandbox-announcement",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Sandbox announcements for Jupyterlab",
|
||||||
|
"keywords": [
|
||||||
|
"jupyter",
|
||||||
|
"jupyterlab",
|
||||||
|
"jupyterlab-extension"
|
||||||
|
],
|
||||||
|
"homepage": "https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab-sandbox-announcement",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab-sandbox-announcement/issues"
|
||||||
|
},
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"author": {
|
||||||
|
"name": "Malte Grosse",
|
||||||
|
"email": "grosse@hdm-stuttgart.de"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
|
||||||
|
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
|
||||||
|
],
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"types": "lib/index.d.ts",
|
||||||
|
"style": "style/index.css",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab-sandbox-announcement.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "jlpm build:lib && jlpm build:labextension:dev",
|
||||||
|
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
|
||||||
|
"build:labextension": "jupyter labextension build .",
|
||||||
|
"build:labextension:dev": "jupyter labextension build --development True .",
|
||||||
|
"build:lib": "tsc --sourceMap",
|
||||||
|
"build:lib:prod": "tsc",
|
||||||
|
"clean": "jlpm clean:lib",
|
||||||
|
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
||||||
|
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
|
||||||
|
"clean:labextension": "rimraf jupyterlab-sandbox-announcement/labextension jupyterlab-sandbox-announcement/_version.py",
|
||||||
|
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
|
||||||
|
"eslint": "jlpm eslint:check --fix",
|
||||||
|
"eslint:check": "eslint . --cache --ext .ts,.tsx",
|
||||||
|
"install:extension": "jlpm build",
|
||||||
|
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
|
||||||
|
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
|
||||||
|
"prettier": "jlpm prettier:base --write --list-different",
|
||||||
|
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
|
||||||
|
"prettier:check": "jlpm prettier:base --check",
|
||||||
|
"stylelint": "jlpm stylelint:check --fix",
|
||||||
|
"stylelint:check": "stylelint --cache \"style/**/*.css\"",
|
||||||
|
"test": "jest --coverage",
|
||||||
|
"watch": "run-p watch:src watch:labextension",
|
||||||
|
"watch:src": "tsc -w",
|
||||||
|
"watch:labextension": "jupyter labextension watch ."
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@jupyterlab/application": "^3.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.0.0",
|
||||||
|
"@babel/preset-env": "^7.0.0",
|
||||||
|
"@jupyterlab/builder": "^3.1.0",
|
||||||
|
"@jupyterlab/testutils": "^3.0.0",
|
||||||
|
"@types/jest": "^26.0.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.8.1",
|
||||||
|
"@typescript-eslint/parser": "^4.8.1",
|
||||||
|
"eslint": "^7.14.0",
|
||||||
|
"eslint-config-prettier": "^6.15.0",
|
||||||
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
|
"jest": "^26.0.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"prettier": "^2.1.1",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"stylelint": "^14.3.0",
|
||||||
|
"stylelint-config-prettier": "^9.0.4",
|
||||||
|
"stylelint-config-recommended": "^6.0.0",
|
||||||
|
"stylelint-config-standard": "~24.0.0",
|
||||||
|
"stylelint-prettier": "^2.0.0",
|
||||||
|
"typescript": "~4.1.3",
|
||||||
|
"ts-jest": "^26.0.0"
|
||||||
|
},
|
||||||
|
"sideEffects": [
|
||||||
|
"style/*.css",
|
||||||
|
"style/index.js"
|
||||||
|
],
|
||||||
|
"styleModule": "style/index.js",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"jupyterlab": {
|
||||||
|
"extension": true,
|
||||||
|
"outputDir": "jupyterlab-sandbox-announcement/labextension"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["hatchling>=1.4.0", "jupyterlab>=3.4.7,<4.0.0", "hatch-nodejs-version"]
|
||||||
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "jupyterlab-sandbox-announcement"
|
||||||
|
readme = "README.md"
|
||||||
|
license = { file = "LICENSE" }
|
||||||
|
requires-python = ">=3.7"
|
||||||
|
classifiers = [
|
||||||
|
"Framework :: Jupyter",
|
||||||
|
"Framework :: Jupyter :: JupyterLab",
|
||||||
|
"Framework :: Jupyter :: JupyterLab :: 3",
|
||||||
|
"Framework :: Jupyter :: JupyterLab :: Extensions",
|
||||||
|
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
|
||||||
|
"License :: OSI Approved :: BSD License",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.7",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
]
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
dynamic = ["version", "description", "authors", "urls", "keywords"]
|
||||||
|
|
||||||
|
[tool.hatch.version]
|
||||||
|
source = "nodejs"
|
||||||
|
|
||||||
|
[tool.hatch.metadata.hooks.nodejs]
|
||||||
|
fields = ["description", "authors", "urls"]
|
||||||
|
|
||||||
|
[tool.hatch.build.targets.sdist]
|
||||||
|
artifacts = ["jupyterlab-sandbox-announcement/labextension"]
|
||||||
|
exclude = [".github", "binder"]
|
||||||
|
|
||||||
|
[tool.hatch.build.targets.wheel.shared-data]
|
||||||
|
"jupyterlab-sandbox-announcement/labextension" = "share/jupyter/labextensions/jupyterlab-sandbox-announcement"
|
||||||
|
"install.json" = "share/jupyter/labextensions/jupyterlab-sandbox-announcement/install.json"
|
||||||
|
|
||||||
|
[tool.hatch.build.hooks.version]
|
||||||
|
path = "jupyterlab-sandbox-announcement/_version.py"
|
||||||
|
|
||||||
|
[tool.hatch.build.hooks.jupyter-builder]
|
||||||
|
dependencies = ["hatch-jupyter-builder>=0.5"]
|
||||||
|
build-function = "hatch_jupyter_builder.npm_builder"
|
||||||
|
ensured-targets = [
|
||||||
|
"jupyterlab-sandbox-announcement/labextension/static/style.js",
|
||||||
|
"jupyterlab-sandbox-announcement/labextension/package.json",
|
||||||
|
]
|
||||||
|
skip-if-exists = ["jupyterlab-sandbox-announcement/labextension/static/style.js"]
|
||||||
|
|
||||||
|
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
|
||||||
|
build_cmd = "build:prod"
|
||||||
|
npm = ["jlpm"]
|
||||||
|
|
||||||
|
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
|
||||||
|
build_cmd = "install:extension"
|
||||||
|
npm = ["jlpm"]
|
||||||
|
source_dir = "src"
|
||||||
|
build_dir = "jupyterlab-sandbox-announcement/labextension"
|
||||||
|
|
||||||
|
[tool.jupyter-releaser.options]
|
||||||
|
version_cmd = "hatch version"
|
||||||
|
|
||||||
|
[tool.jupyter-releaser.hooks]
|
||||||
|
before-build-npm = ["python -m pip install jupyterlab~=3.1", "jlpm", "jlpm build:prod"]
|
||||||
|
before-build-python = ["jlpm clean:all"]
|
||||||
|
|
||||||
|
[tool.check-wheel-contents]
|
||||||
|
ignore = ["W002"]
|
|
@ -0,0 +1,9 @@
|
||||||
|
/**
|
||||||
|
* Example of [Jest](https://jestjs.io/docs/getting-started) unit tests
|
||||||
|
*/
|
||||||
|
|
||||||
|
describe('jupyterlab-sandbox-announcement', () => {
|
||||||
|
it('should be tested', () => {
|
||||||
|
expect(1 + 1).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,76 @@
|
||||||
|
import {
|
||||||
|
JupyterFrontEnd,
|
||||||
|
JupyterFrontEndPlugin,
|
||||||
|
} from '@jupyterlab/application';
|
||||||
|
import { ICommandPalette } from '@jupyterlab/apputils';
|
||||||
|
import { Widget } from '@lumino/widgets';
|
||||||
|
import { MainAreaWidget } from '@jupyterlab/apputils';
|
||||||
|
import { LogoAnnounce} from './images';
|
||||||
|
/**
|
||||||
|
* Generate whatever content to render in `contentHeader`
|
||||||
|
*
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
function generateContent(): string {
|
||||||
|
return 'Welcome to Sandbox Playground';
|
||||||
|
}
|
||||||
|
function createNode(): HTMLElement {
|
||||||
|
let node = document.createElement('div');
|
||||||
|
node.className = "sandbox-announcement-container"
|
||||||
|
let content = document.createElement('div');
|
||||||
|
content.className = "sandbox-announcement-content"
|
||||||
|
let image = document.createElement('img');
|
||||||
|
image.src=LogoAnnounce;
|
||||||
|
image.className = "sandbox-announcement-icon"
|
||||||
|
content.appendChild(image);
|
||||||
|
let text = document.createElement('h2');
|
||||||
|
text.textContent = "Sandbox Playground"
|
||||||
|
text.className = "sandbox-announcement-text"
|
||||||
|
content.appendChild(text)
|
||||||
|
node.appendChild(content);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialization data for the contentheader extension.
|
||||||
|
*/
|
||||||
|
const plugin: JupyterFrontEndPlugin<void> = {
|
||||||
|
id: 'jupyterlab-sandbox-announcement:plugin',
|
||||||
|
autoStart: true,
|
||||||
|
optional: [ICommandPalette],
|
||||||
|
activate: (app: JupyterFrontEnd, pal?: ICommandPalette) => {
|
||||||
|
|
||||||
|
const widget = new Widget();
|
||||||
|
widget.id = "sandbox-announce"
|
||||||
|
widget.addClass('sandbox-announcement-contentheader-widget');
|
||||||
|
//widget.node.textContent = generateContent();
|
||||||
|
console.log(generateContent())
|
||||||
|
widget.node.appendChild(createNode())
|
||||||
|
setInterval(() => {
|
||||||
|
const main = app.shell.currentWidget;
|
||||||
|
if (main instanceof MainAreaWidget) {
|
||||||
|
|
||||||
|
// if (main.title.label == 'Launcher'){
|
||||||
|
// console.log(main.title.label);
|
||||||
|
// }
|
||||||
|
let add = true;
|
||||||
|
// and insert it into the header
|
||||||
|
main.contentHeader.widgets.forEach(function (w: Widget) {
|
||||||
|
if (w.id=="sandbox-announce"){
|
||||||
|
//w.dispose()
|
||||||
|
add = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (add){
|
||||||
|
main.contentHeader.addWidget(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 200);
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default plugin;
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
.sandbox-announcement-contentheader-widget {
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
margin-right: -2rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
min-height: 4.5rem;
|
||||||
|
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
color: black;
|
||||||
|
|
||||||
|
animation: fadeIn 2s;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
@keyframes fadeIn {
|
||||||
|
0% { opacity: 0; }
|
||||||
|
100% { opacity: 1; }
|
||||||
|
}
|
||||||
|
.sandbox-announcement-container{
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.sandbox-announcement-content{
|
||||||
|
display: inline-block;
|
||||||
|
display:table
|
||||||
|
}
|
||||||
|
.sandbox-announcement-icon{
|
||||||
|
max-height: 3rem;
|
||||||
|
float:left;
|
||||||
|
margin-right: 1rem;
|
||||||
|
vertical-align: middle;
|
||||||
|
display:table-cell
|
||||||
|
}
|
||||||
|
.sandbox-announcement-text{
|
||||||
|
display:table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
display: inline-block;
|
||||||
|
min-height: 4.5rem
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
@import url('base.css');
|
|
@ -0,0 +1 @@
|
||||||
|
import './base.css';
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"composite": true,
|
||||||
|
"declaration": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"incremental": true,
|
||||||
|
"jsx": "react",
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"noEmitOnError": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"preserveWatchOutput": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": "src",
|
||||||
|
"strict": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"target": "ES2018",
|
||||||
|
"types": ["jest"]
|
||||||
|
},
|
||||||
|
"include": ["src/*"]
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
# Integration Testing
|
||||||
|
|
||||||
|
This folder contains the integration tests of the extension.
|
||||||
|
|
||||||
|
They are defined using [Playwright](https://playwright.dev/docs/intro) test runner
|
||||||
|
and [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) helper.
|
||||||
|
|
||||||
|
The Playwright configuration is defined in [playwright.config.js](./playwright.config.js).
|
||||||
|
|
||||||
|
The JupyterLab server configuration to use for the integration test is defined
|
||||||
|
in [jupyter_server_test_config.py](./jupyter_server_test_config.py).
|
||||||
|
|
||||||
|
The default configuration will produce video for failing tests and an HTML report.
|
||||||
|
|
||||||
|
## Run the tests
|
||||||
|
|
||||||
|
> All commands are assumed to be executed from the root directory
|
||||||
|
|
||||||
|
To run the tests, you need to:
|
||||||
|
|
||||||
|
1. Compile the extension:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
jlpm install
|
||||||
|
jlpm build:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
> Check the extension is installed in JupyterLab.
|
||||||
|
|
||||||
|
2. Install test dependencies (needed only once):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm install
|
||||||
|
jlpm playwright install
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Execute the [Playwright](https://playwright.dev/docs/intro) tests:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm playwright test
|
||||||
|
```
|
||||||
|
|
||||||
|
Test results will be shown in the terminal. In case of any test failures, the test report
|
||||||
|
will be opened in your browser at the end of the tests execution; see
|
||||||
|
[Playwright documentation](https://playwright.dev/docs/test-reporters#html-reporter)
|
||||||
|
for configuring that behavior.
|
||||||
|
|
||||||
|
## Update the tests snapshots
|
||||||
|
|
||||||
|
> All commands are assumed to be executed from the root directory
|
||||||
|
|
||||||
|
If you are comparing snapshots to validate your tests, you may need to update
|
||||||
|
the reference snapshots stored in the repository. To do that, you need to:
|
||||||
|
|
||||||
|
1. Compile the extension:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
jlpm install
|
||||||
|
jlpm build:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
> Check the extension is installed in JupyterLab.
|
||||||
|
|
||||||
|
2. Install test dependencies (needed only once):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm install
|
||||||
|
jlpm playwright install
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Execute the [Playwright](https://playwright.dev/docs/intro) command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm playwright test -u
|
||||||
|
```
|
||||||
|
|
||||||
|
> Some discrepancy may occurs between the snapshots generated on your computer and
|
||||||
|
> the one generated on the CI. To ease updating the snapshots on a PR, you can
|
||||||
|
> type `please update playwright snapshots` to trigger the update by a bot on the CI.
|
||||||
|
> Once the bot has computed new snapshots, it will commit them to the PR branch.
|
||||||
|
|
||||||
|
## Create tests
|
||||||
|
|
||||||
|
> All commands are assumed to be executed from the root directory
|
||||||
|
|
||||||
|
To create tests, the easiest way is to use the code generator tool of playwright:
|
||||||
|
|
||||||
|
1. Compile the extension:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
jlpm install
|
||||||
|
jlpm build:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
> Check the extension is installed in JupyterLab.
|
||||||
|
|
||||||
|
2. Install test dependencies (needed only once):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm install
|
||||||
|
jlpm playwright install
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Execute the [Playwright code generator](https://playwright.dev/docs/codegen):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm playwright codegen localhost:8888
|
||||||
|
```
|
||||||
|
|
||||||
|
## Debug tests
|
||||||
|
|
||||||
|
> All commands are assumed to be executed from the root directory
|
||||||
|
|
||||||
|
To debug tests, a good way is to use the inspector tool of playwright:
|
||||||
|
|
||||||
|
1. Compile the extension:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
jlpm install
|
||||||
|
jlpm build:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
> Check the extension is installed in JupyterLab.
|
||||||
|
|
||||||
|
2. Install test dependencies (needed only once):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
jlpm install
|
||||||
|
jlpm playwright install
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Execute the Playwright tests in [debug mode](https://playwright.dev/docs/debug):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ./ui-tests
|
||||||
|
PWDEBUG=1 jlpm playwright test
|
||||||
|
```
|
|
@ -0,0 +1,20 @@
|
||||||
|
"""Server configuration for integration tests.
|
||||||
|
|
||||||
|
!! Never use this configuration in production because it
|
||||||
|
opens the server to the world and provide access to JupyterLab
|
||||||
|
JavaScript objects through the global window variable.
|
||||||
|
"""
|
||||||
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
|
c.ServerApp.port = 8888
|
||||||
|
c.ServerApp.port_retries = 0
|
||||||
|
c.ServerApp.open_browser = False
|
||||||
|
|
||||||
|
c.ServerApp.root_dir = mkdtemp(prefix='galata-test-')
|
||||||
|
c.ServerApp.token = ""
|
||||||
|
c.ServerApp.password = ""
|
||||||
|
c.ServerApp.disable_check_xsrf = True
|
||||||
|
c.LabApp.expose_app_in_browser = True
|
||||||
|
|
||||||
|
# Uncomment to set server log level to debug level
|
||||||
|
# c.ServerApp.log_level = "DEBUG"
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "jupyterlab-sandbox-announcement-ui-tests",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "JupyterLab jupyterlab-sandbox-announcement Integration Tests",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"start": "jupyter lab --config jupyter_server_test_config.py",
|
||||||
|
"test": "jlpm playwright test",
|
||||||
|
"test:update": "jlpm playwright test --update-snapshots"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@jupyterlab/galata": "^4.3.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
/**
|
||||||
|
* Configuration for Playwright using default from @jupyterlab/galata
|
||||||
|
*/
|
||||||
|
const baseConfig = require('@jupyterlab/galata/lib/playwright-config');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
...baseConfig,
|
||||||
|
webServer: {
|
||||||
|
command: 'jlpm start',
|
||||||
|
url: 'http://localhost:8888/lab',
|
||||||
|
timeout: 120 * 1000,
|
||||||
|
reuseExistingServer: !process.env.CI
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,21 @@
|
||||||
|
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 emit an activation console message', async ({ page }) => {
|
||||||
|
const logs: string[] = [];
|
||||||
|
|
||||||
|
page.on('console', message => {
|
||||||
|
logs.push(message.text());
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
logs.filter(s => s === 'JupyterLab extension jupyterlab-sandbox-announcement is activated!')
|
||||||
|
).toHaveLength(1);
|
||||||
|
});
|
Loading…
Reference in New Issue