Skip to content

Commit cbaca77

Browse files
committed
Add preview test fixtures and update skill with testing learnings
Test fixtures for T1-T10: single-file Python, project website, keep-ipynb, plain qmd, and knitr. Project scaffolded via quarto create. Skill updated with: venv activation requirement, Windows SIGINT limitation for cleanup testing, simplified background process examples.
1 parent 5a4834c commit cbaca77

10 files changed

Lines changed: 95 additions & 11 deletions

File tree

.claude/commands/quarto-preview-test/SKILL.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,20 @@ Interactive testing of `quarto preview` with automated browser verification.
1818
## Prerequisites
1919

2020
- Quarto dev version built (`./configure.sh` or `./configure.cmd`)
21+
- Test environment configured (`tests/configure-test-env.sh` or `.ps1`)
2122
- `/agent-browser` CLI installed (preferred), OR Chrome + Chrome DevTools MCP connected
2223

2324
## Starting Preview
2425

26+
Preview needs the test venv for Jupyter tests. Activate it first (`tests/.venv`), matching how `run-tests.sh` / `run-tests.ps1` do it.
27+
2528
```bash
2629
# Linux/macOS
30+
source tests/.venv/bin/activate
2731
./package/dist/bin/quarto preview <file-or-dir> --no-browser --port 4444
2832

29-
# Windows
33+
# Windows (Git Bash)
34+
source tests/.venv/Scripts/activate
3035
./package/dist/bin/quarto.cmd preview <file-or-dir> --no-browser --port 4444
3136
```
3237

@@ -38,21 +43,20 @@ Use `--no-browser` to control browser connection. Use `--port` for a predictable
3843
./package/dist/bin/quarto preview <file> --no-browser --port 4444 --log-level debug 2>&1 | tee preview.log
3944
```
4045

41-
Filter log entries with `grep` or `jq` for structured output.
42-
4346
### In background
4447

4548
```bash
46-
# Linux/macOS
49+
# Linux/macOS (after venv activation)
4750
./package/dist/bin/quarto preview <file> --no-browser --port 4444 &
4851
PREVIEW_PID=$!
4952
# ... run verification ...
5053
kill $PREVIEW_PID
5154

52-
# Windows (PowerShell)
53-
$proc = Start-Process -PassThru -NoNewWindow ./package/dist/bin/quarto.cmd preview, <file>, --no-browser, --port, 4444
55+
# Windows (Git Bash, after venv activation)
56+
./package/dist/bin/quarto.cmd preview <file> --no-browser --port 4444 &
57+
PREVIEW_PID=$!
5458
# ... run verification ...
55-
Stop-Process $proc
59+
kill $PREVIEW_PID
5660
```
5761

5862
## Edit-Verify Cycle
@@ -64,7 +68,7 @@ The core test pattern:
6468
3. Edit source file, wait 3-5 seconds for re-render
6569
4. Verify content updated in browser
6670
5. Check filesystem for unexpected artifacts
67-
6. Stop preview (Ctrl+C or kill), verify cleanup
71+
6. Stop preview, verify cleanup
6872

6973
## What to Verify
7074

@@ -74,6 +78,10 @@ The core test pattern:
7478

7579
**On filesystem**: No orphaned temp files, cleanup happens on exit.
7680

81+
## Windows Limitations
82+
83+
On Windows, `kill` from Git Bash does not trigger Quarto's `onCleanup` handler (SIGINT doesn't propagate to Windows processes the same way). Cleanup-on-exit verification requires an interactive terminal with Ctrl+C. For automated testing, verify artifacts *during* preview instead.
84+
7785
## Context Types
7886

7987
Preview behaves differently depending on input:
@@ -92,9 +100,9 @@ See `llm-docs/preview-architecture.md` for the full architecture.
92100
- Testing render output only (no live preview needed) — use `quarto render`
93101
- CI environments without browser access
94102

95-
## Test Cases
103+
## Test Fixtures and Cases
96104

97-
Specific test matrices live in `tests/docs/manual/preview/README.md`. This skill covers the general workflow.
105+
Test fixtures live in `tests/docs/manual/preview/`. The full test matrix is in `tests/docs/manual/preview/README.md`.
98106

99107
## Baseline Comparison
100108

tests/docs/manual/preview/14281-quarto-ipynb-accumulation.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ with file-save events that cannot be triggered in automated smoke tests.
3636

3737
Edit the line below to trigger re-renders:
3838

39-
Current value: 8
39+
Current value: 11
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "Keep ipynb Test"
3+
execute:
4+
keep-ipynb: true
5+
---
6+
7+
## T7: keep-ipynb: true
8+
9+
File should persist after preview exit. No _1 variants during preview.
10+
11+
```{python}
12+
print("keep-ipynb test")
13+
```
14+
15+
Edit counter: 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "Knitr Test"
3+
engine: knitr
4+
---
5+
6+
## T10: R/knitr engine
7+
8+
No .quarto_ipynb should be created. Knitr does not use Jupyter.
9+
10+
```{r}
11+
print("Hello from R")
12+
```
13+
14+
Edit counter: 0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Plain QMD Test"
3+
---
4+
5+
## T9: No code cells
6+
7+
No .quarto_ipynb should ever be created.
8+
9+
Edit counter: 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
**/*.quarto_ipynb
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "Preview Test Project"
6+
navbar:
7+
left:
8+
- href: index.qmd
9+
text: Home
10+
- about.qmd
11+
12+
format:
13+
html:
14+
theme: cosmo
15+
css: styles.css
16+
toc: true
17+
18+
19+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "About"
3+
---
4+
5+
About this site
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Preview Test Project"
3+
---
4+
5+
## T3/T4: Project preview with Python cell
6+
7+
```{python}
8+
print("Hello from project preview")
9+
```
10+
11+
Edit counter: 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* css styles */

0 commit comments

Comments
 (0)