Skip to content

Commit 04c0b66

Browse files
authored
Merge branch 'v1.9' into backport/rstudio-inspect-standalone
2 parents 8a9611c + 448eea6 commit 04c0b66

File tree

8 files changed

+451
-14
lines changed

8 files changed

+451
-14
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
name: quarto-preview-test
3+
description: Use when testing preview functionality, verifying live reload, or validating preview fixes. Covers starting preview with port/logging, browser verification via /agent-browser, and checking logs/filesystem for artifacts.
4+
---
5+
6+
# Quarto Preview Test
7+
8+
Interactive testing of `quarto preview` with automated browser verification.
9+
10+
## Tools
11+
12+
| Tool | When to use |
13+
|------|-------------|
14+
| `/agent-browser` | **Preferred.** Token-efficient browser automation. Navigate, verify content, screenshot. |
15+
| Chrome DevTools MCP | Deep debugging: console messages, network requests, DOM inspection. |
16+
| `jq` / `grep` | Parse debug log output. |
17+
18+
## Prerequisites
19+
20+
- Quarto dev version built (`./configure.sh` or `./configure.cmd`)
21+
- Test environment configured (`tests/configure-test-env.sh` or `.ps1`)
22+
- `/agent-browser` CLI installed (preferred), OR Chrome + Chrome DevTools MCP connected
23+
24+
## Starting Preview
25+
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+
28+
```bash
29+
# Linux/macOS
30+
source tests/.venv/bin/activate
31+
./package/dist/bin/quarto preview <file-or-dir> --no-browser --port 4444
32+
33+
# Windows (Git Bash)
34+
source tests/.venv/Scripts/activate
35+
./package/dist/bin/quarto.cmd preview <file-or-dir> --no-browser --port 4444
36+
```
37+
38+
Use `--no-browser` to control browser connection. Use `--port` for a predictable URL.
39+
40+
### With debug logging
41+
42+
```bash
43+
./package/dist/bin/quarto preview <file> --no-browser --port 4444 --log-level debug 2>&1 | tee preview.log
44+
```
45+
46+
### In background
47+
48+
```bash
49+
# Linux/macOS (after venv activation)
50+
./package/dist/bin/quarto preview <file> --no-browser --port 4444 &
51+
PREVIEW_PID=$!
52+
# ... run verification ...
53+
kill $PREVIEW_PID
54+
55+
# Windows (Git Bash, after venv activation)
56+
./package/dist/bin/quarto.cmd preview <file> --no-browser --port 4444 &
57+
PREVIEW_PID=$!
58+
# ... run verification ...
59+
kill $PREVIEW_PID
60+
```
61+
62+
## Edit-Verify Cycle
63+
64+
The core test pattern:
65+
66+
1. Start preview with `--no-browser --port 4444`
67+
2. Use `/agent-browser` to navigate to `http://localhost:4444/` and verify content
68+
3. Edit source file, wait 3-5 seconds for re-render
69+
4. Verify content updated in browser
70+
5. Check filesystem for unexpected artifacts
71+
6. Stop preview, verify cleanup
72+
73+
## What to Verify
74+
75+
**In browser** (via `/agent-browser`): Page loads, content matches source, updates reflect edits.
76+
77+
**In terminal/logs**: No `BadResource` errors, no crashes, preview stays responsive.
78+
79+
**On filesystem**: No orphaned temp files, cleanup happens on exit.
80+
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+
85+
## Context Types
86+
87+
Preview behaves differently depending on input:
88+
89+
| Input | Code path |
90+
|-------|-----------|
91+
| Single file (no project) | `preview()` -> `renderForPreview()` |
92+
| File within a project | May redirect to project preview via `serveProject()` |
93+
| Project directory | `serveProject()` -> `watchProject()` |
94+
95+
See `llm-docs/preview-architecture.md` for the full architecture.
96+
97+
## When NOT to Use
98+
99+
- Automated smoke tests — use `tests/smoke/` instead
100+
- Testing render output only (no live preview needed) — use `quarto render`
101+
- CI environments without browser access
102+
103+
## Test Matrix
104+
105+
The full test matrix lives in `tests/docs/manual/preview/README.md`. Test fixtures live alongside it in `tests/docs/manual/preview/`.
106+
107+
### Running specific tests by ID
108+
109+
When invoked with test IDs (e.g., `/quarto-preview-test T17 T18`):
110+
111+
1. Read `tests/docs/manual/preview/README.md`
112+
2. Find each requested test by its ID (e.g., `#### T17:`)
113+
3. Parse the **Setup**, **Steps**, and **Expected** fields
114+
4. Execute each test following the steps, using the fixtures in `tests/docs/manual/preview/`
115+
5. Report PASS/FAIL for each test with the actual vs expected result
116+
117+
### Running tests by topic
118+
119+
When invoked with a topic description instead of IDs (e.g., `/quarto-preview-test root URL` or "run preview tests for single-file"):
120+
121+
1. Read `tests/docs/manual/preview/README.md`
122+
2. Search test titles and descriptions for matches (keywords, issue numbers, feature area)
123+
3. Present the matched tests to the user for confirmation before running:
124+
```
125+
Found these matching tests:
126+
- T17: Single-file preview — root URL accessible (#14298)
127+
- T18: Single-file preview — named output URL also accessible
128+
Run these? [Y/n]
129+
```
130+
4. Only execute after user confirms
131+
132+
### Running without arguments
133+
134+
When invoked without test IDs or topic (e.g., `/quarto-preview-test`), use the general Edit-Verify Cycle workflow described above for ad-hoc preview testing. The test matrix is for targeted regression testing.
135+
136+
## Baseline Comparison
137+
138+
Compare dev build against installed release to distinguish regressions:
139+
140+
```bash
141+
quarto --version # installed
142+
./package/dist/bin/quarto --version # dev
143+
```
144+
145+
If both show the same issue, it's pre-existing.

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- ([#14267](https://github.com/quarto-dev/quarto-cli/issues/14267)): Fix Windows paths with accented characters (e.g., `C:\Users\Sébastien\`) breaking dart-sass compilation.
66
- ([#14281](https://github.com/quarto-dev/quarto-cli/issues/14281)): Fix transient `.quarto_ipynb` files accumulating during `quarto preview` with Jupyter engine.
77
- ([rstudio/rstudio#17333](https://github.com/rstudio/rstudio/issues/17333)): Fix `quarto inspect` on standalone files emitting project metadata that breaks RStudio's publishing wizard.
8+
- ([#14298](https://github.com/quarto-dev/quarto-cli/issues/14298)): Fix `quarto preview` browse URL including output filename (e.g., `hello.html`) for single-file documents, breaking Posit Workbench proxied server access.
89

910
## In previous releases
1011

src/command/preview/preview.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ interface PreviewOptions {
143143
presentation: boolean;
144144
}
145145

146+
export function previewInitialPath(
147+
outputFile: string,
148+
project: ProjectContext | undefined,
149+
): string {
150+
if (isPdfContent(outputFile)) {
151+
return kPdfJsInitialPath;
152+
}
153+
if (project && !project.isSingleFile) {
154+
return pathWithForwardSlashes(
155+
relative(projectOutputDir(project), outputFile),
156+
);
157+
}
158+
return "";
159+
}
160+
146161
export async function preview(
147162
file: string,
148163
flags: RenderFlags,
@@ -230,7 +245,7 @@ export async function preview(
230245
changeHandler.render,
231246
project,
232247
)
233-
: project
248+
: project && !project.isSingleFile
234249
? projectHtmlFileRequestHandler(
235250
project,
236251
normalizePath(file),
@@ -250,13 +265,7 @@ export async function preview(
250265
);
251266

252267
// open browser if this is a browseable format
253-
const initialPath = isPdfContent(result.outputFile)
254-
? kPdfJsInitialPath
255-
: project
256-
? pathWithForwardSlashes(
257-
relative(projectOutputDir(project), result.outputFile),
258-
)
259-
: "";
268+
const initialPath = previewInitialPath(result.outputFile, project);
260269
if (
261270
options.browser &&
262271
!isServerSession() &&

tests/docs/manual/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Manual Tests
2+
3+
Tests that require interactive sessions, external services, or browser access that cannot run in automated CI.
4+
5+
## Test Suites
6+
7+
| Directory / File | Area | Skill | Description |
8+
|-----------------|------|-------|-------------|
9+
| `preview/` | `quarto preview` | `/quarto-preview-test` | Live preview server behavior: URL routing, file watching, live reload, transient file cleanup |
10+
| `publish-connect-cloud/` | `quarto publish` || Posit Connect Cloud publishing with OAuth flow |
11+
| `mermaid-svg-pdf-tooling.qmd` | `quarto render` || Mermaid SVG rendering to PDF with external tooling (rsvg-convert) |
12+
13+
## Running Tests
14+
15+
Each suite has its own README with test matrix and execution instructions. Test fixtures live alongside the README in each directory.
16+
17+
For preview tests, use the `/quarto-preview-test` skill which automates the start-verify-cleanup cycle.

0 commit comments

Comments
 (0)