Skip to content

Commit

Permalink
Merge pull request #26 from ninerealmlabs/features/tests
Browse files Browse the repository at this point in the history
Add Features/tests
  • Loading branch information
ahgraber authored Dec 30, 2022
2 parents 0b14312 + f949bf7 commit 6abafde
Show file tree
Hide file tree
Showing 22 changed files with 21,396 additions and 17,267 deletions.
69 changes: 65 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ name: Build

on: # yamllint disable-line rule:truthy
# use workflow_dispatch as manual trigger;
push:
branches: [main]
pull_request:
branches: ['*']
workflow_dispatch:
# push:
# branches: main
# pull_request:
# branches: '*'

jobs:
build:
Expand All @@ -31,6 +31,11 @@ jobs:
jlpm
jlpm run lint:check
- name: Test the extension
run: |
set -eux
jlpm run test
- name: Build the extension
run: |
set -eux
Expand Down Expand Up @@ -86,6 +91,62 @@ jobs:
jupyter labextension list 2>&1 | grep -ie "jupyterlab_material_night_eighties.*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_material_night_eighties*.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@v2
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_material_night_eighties-playwright-tests
path: |
ui-tests/test-results
ui-tests/playwright-report
check_links:
name: Check Links
runs-on: ubuntu-latest
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/update-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Update Playwright Snapshots

on: # yamllint disable-line rule:truthy
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@v2
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: Install dependencies
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jupyterlab_material_night_eighties/_version.py
# Integration tests
ui-tests/test-results/
ui-tests/playwright-report/
ui-tests/*lock*

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
Expand Down Expand Up @@ -58,6 +59,7 @@ pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
coverage/
htmlcov/
.tox/
.nox/
Expand Down
11 changes: 7 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ repos:
- --ignore-unknown
# - "--ignore-path '**/*.md'"
# - "--ignore-path '**/*.y*ml'"
exclude: |
(?x)^(
package-lock.json
)$
# exclude: |
# (?x)^(
# package-lock.json
# )$
# Lint: Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2 # v0.30.0
Expand Down Expand Up @@ -105,3 +105,6 @@ repos:
rev: 0.19.2
hooks:
- id: check-github-workflows
# files: ^\.github/workflows/[^/]+$
# types: [yaml]
# args: ['--schemafile', 'https://json.schemastore.org/github-workflow']
13 changes: 0 additions & 13 deletions .prettierignore copy

This file was deleted.

8 changes: 0 additions & 8 deletions .prettierrc.yaml

This file was deleted.

26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JupyterLab Material Night Eighties theme

[![Check](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/check-release.yml/badge.svg)](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/check-release.yml)[![Publish](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/publish-release.yml/badge.svg)](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/publish-release.yml)
[![Build](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/build.yaml/badge.svg)](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/build.yaml)[![Check](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/check-release.yaml/badge.svg)](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/check-release.yaml)[![Publish](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/publish-release.yaml/badge.svg)](https://github.com/ninerealmlabs/jupyterlab-theme-material-night-eighties/actions/workflows/publish-release.yaml)

Theme for jupyterlab based on [jupyterlab/theme-extension-cookiecutter-ts](https://github.com/jupyterlab/extension-cookiecutter-ts),
inspired by [oriolmirosa/jupyterlab_materialdarker](https://github.com/oriolmirosa/jupyterlab_materialdarker),
Expand All @@ -15,6 +15,9 @@ and [base16](https://github.com/chriskempson/base16)
- [Development install](#development-install)
- [Updating dependencies](#updating-dependencies)
- [Development uninstall](#development-uninstall)
- [Testing the extension](#testing-the-extension)
- [Frontend tests](#frontend-tests)
- [Integration tests](#integration-tests)
- [Packaging the extension](#packaging-the-extension)

## Requirements
Expand Down Expand Up @@ -123,6 +126,27 @@ In development mode, you will also need to remove the symlink created by `jupyte
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_material_night_eighties` 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)
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
42 changes: 42 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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'],
coverageDirectory: 'coverage',
coverageReporters: ['lcov', 'text'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json'
}
},
testRegex: 'src/.*/.*.spec.ts[x]?$',
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
};
3 changes: 3 additions & 0 deletions jupyterlab_material_night_eighties/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from ._version import __version__


def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": "jupyterlab_material_night_eighties"}]
Loading

0 comments on commit 6abafde

Please sign in to comment.