Skip to content

Commit e84175a

Browse files
authored
test: Add notebooks UI tests (#6)
* Add ui-test setup * Add biome and nb strip * Edit slider test * Add nbconvert test * Add notebook tests in ci * Add .gitattributes
1 parent a190af9 commit e84175a

16 files changed

Lines changed: 7527 additions & 59 deletions

.Rprofile

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SCM syntax highlighting & preventing 3-way merges
2+
pixi.lock merge=binary linguist-language=YAML linguist-generated=true linguist-vendored -diff
3+
4+
yarn.lock text merge=union linguist-vendored linguist-generated
5+
package-lock.json text merge=union linguist-vendored linguist-generated

.github/workflows/test-ui.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Notebook Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
ui-tests:
15+
name: Playwright UI tests
16+
runs-on: ubuntu-latest
17+
env:
18+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/playwright/browsers
19+
PLAYWRIGHT_HTML_OUTPUT_DIR: ${{ github.workspace }}/playwright/report
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v6
23+
- name: Setup Pixi
24+
uses: prefix-dev/setup-pixi@v0.9.6
25+
with:
26+
pixi-version: v0.69.0
27+
cache: true
28+
environments: dev
29+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
30+
- name: Install UI test dependencies
31+
run: pixi run install-ui-tests-deps
32+
- name: Cache Playwright browsers
33+
id: playwright-cache
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
37+
key: playwright-${{ runner.os }}-${{ hashFiles('ui-tests/package-lock.json') }}
38+
- name: Install Playwright browsers
39+
if: steps.playwright-cache.outputs.cache-hit != 'true'
40+
run: pixi run install-browsers
41+
- name: Run UI tests
42+
run: pixi run test-ui --reporter=github,html
43+
- name: Upload Playwright report
44+
if: always()
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: playwright-report
48+
path: ${{ env.PLAYWRIGHT_HTML_OUTPUT_DIR }}
49+
retention-days: 30
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: Test and linters
22

33
on:
44
push:
@@ -11,6 +11,22 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14+
checks:
15+
name: Code checks and formatters
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v6
20+
- name: Setup Pixi
21+
uses: prefix-dev/setup-pixi@v0.9.6
22+
with:
23+
pixi-version: v0.69.0
24+
cache: true
25+
environments: dev
26+
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
27+
- name: Check linters and formatting
28+
run: pixi run pre-commit-all
29+
1430
test:
1531
name: R unit tests
1632
runs-on: ${{ matrix.os }}
@@ -28,18 +44,7 @@ jobs:
2844
cache: true
2945
environments: dev
3046
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
31-
- name: Check linters and formatting
32-
run: pixi run pre-commit-all
3347
- name: Run unit tests
3448
run: pixi run test
3549
- name: Run example notebook
36-
run: |
37-
pixi run serve-jupyter nbconvert \
38-
--to notebook \
39-
--execute \
40-
--ExecutePreprocessor.store_widget_state=False \
41-
--output "${PWD}/out.ipynb" \
42-
examples/widgets.ipynb
43-
44-
# Widgets did render successufully as mime bundle
45-
grep 'application/vnd.jupyter.ywidget-view+json' "${PWD}/out.ipynb"
50+
run: pixi run test-example

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ rsconnect/
5050

5151
# Pixi
5252
.pixi/
53+
54+
# Integration tests
55+
ui-tests/test-results/
56+
ui-tests/playwright-report/
57+
58+
# Web files
59+
node_modules/
60+
*.log
61+
.eslintcache
62+
.stylelintcache
63+
64+
# Jupyter assets
65+
.ipynb_checkpoints
66+
67+
# nbconvert tests
68+
examples/*.nbconvert.ipynb

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ repos:
88
- id: check-toml
99
- id: check-merge-conflict
1010
- id: mixed-line-ending
11+
- repo: https://github.com/kynan/nbstripout
12+
rev: 0.9.1
13+
hooks:
14+
- id: nbstripout
1115
- repo: local
1216
hooks:
1317
- id: pixi-doc
@@ -22,6 +26,12 @@ repos:
2226
language: system
2327
types_or: [r]
2428
pass_filenames: false
29+
- id: pixi-biome-format
30+
name: "Run Biome format through pixi"
31+
entry: pixi run fmt-biome""
32+
language: system
33+
types_or: [javascript, jsx, ts, tsx, json, css]
34+
exclude: "(^|/)package\\.json$"
2535
- id: pixi-check-typos
2636
name: "Run typos through pixi"
2737
entry: pixi run check-typos

biome.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"files": {
3+
"includes": [
4+
"**",
5+
"!**/node_modules/**/*",
6+
"!**/package.json",
7+
"!.yarn/**/*",
8+
"!.pixi/**/*",
9+
"!.vscode/**/*",
10+
"!coverage/**/*"
11+
]
12+
},
13+
"assist": {
14+
"enabled": true,
15+
"actions": {
16+
"source": {
17+
"organizeImports": {
18+
"level": "on",
19+
"options": {
20+
"groups": [
21+
{
22+
"type": false,
23+
"source": ":PACKAGE:"
24+
},
25+
{
26+
"type": true,
27+
"source": ":PACKAGE:"
28+
},
29+
":BLANK_LINE:",
30+
{
31+
"type": false,
32+
"source": ":PATH:"
33+
},
34+
{
35+
"type": true,
36+
"source": ":PATH:"
37+
}
38+
]
39+
}
40+
}
41+
}
42+
}
43+
},
44+
"formatter": {
45+
"formatWithErrors": true,
46+
"indentStyle": "space",
47+
"indentWidth": 2,
48+
"lineWidth": 100
49+
},
50+
"linter": {
51+
"enabled": true,
52+
"rules": {
53+
"style": {
54+
"noDefaultExport": "off",
55+
"noNonNullAssertion": "off"
56+
},
57+
"suspicious": {
58+
"noConsole": "off"
59+
}
60+
}
61+
}
62+
}

dev/.Rprofile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dev startup profile: load the in-tree package with devtools.
2+
# Loaded via R_PROFILE_USER (see pixi tasks), so resolve the package root from
3+
# this file's own location.
4+
local({
5+
root <- dirname(dirname(normalizePath(Sys.getenv("R_PROFILE_USER")))) # dev/.Rprofile -> dev -> root
6+
7+
if (requireNamespace("devtools", quietly = TRUE)) {
8+
try(devtools::load_all(root, quiet = TRUE))
9+
}
10+
})

0 commit comments

Comments
 (0)