Skip to content

Commit f7fd416

Browse files
authored
Merge branch 'main' into feat/typst-annotation-filename
2 parents 12823b5 + 23bb687 commit f7fd416

123 files changed

Lines changed: 8646 additions & 9411 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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 `tests/configure-test-env.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.

.claude/rules/testing/typescript-tests.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,20 @@ const fixtureDir = docs("my-fixture"); // → tests/docs/my-fixture/
9292
- `tests/docs/<feature>/` - Test fixtures
9393

9494
**Details:** `llm-docs/testing-patterns.md` for comprehensive patterns and examples.
95+
96+
## Common Test Utilities
97+
98+
**Constructing `MappedString` values:**
99+
```typescript
100+
import { asMappedString } from "../../../src/core/lib/mapped-text.ts";
101+
102+
// Use asMappedString("") instead of casting or constructing MappedString manually
103+
const markdown = asMappedString("");
104+
const markdownWithContent = asMappedString("# Title\nSome content");
105+
```
106+
107+
**Mock ProjectContext:**
108+
```typescript
109+
import { createMockProjectContext } from "./utils.ts"; // tests/unit/project/utils.ts
110+
const project = createMockProjectContext(); // Creates temp dir + FileInformationCacheMap
111+
```

.github/workflows/actions/quarto-dev/action.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ runs:
1212
restore-keys: |
1313
${{ runner.os }}-deno_std-2-
1414
15-
- name: Cache Cargo dependencies
16-
uses: actions/cache@v5
17-
with:
18-
path: |
19-
~/.cargo/registry
20-
~/.cargo/git
21-
package/typst-gather/target
22-
key: ${{ runner.os }}-cargo-typst-gather-${{ hashFiles('package/typst-gather/Cargo.lock') }}
23-
restore-keys: |
24-
${{ runner.os }}-cargo-typst-gather-
25-
2615
- name: Configure Quarto (.sh)
2716
if: runner.os != 'Windows'
2817
shell: bash

.github/workflows/create-release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
run: |
9090
echo ${{ steps.read-version.outputs.version_full }} > version.txt
9191
92-
- uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5
92+
- uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321
9393
if: ${{ inputs.publish-release }}
9494
id: version_commit
9595
with:
@@ -677,9 +677,7 @@ jobs:
677677
678678
- name: Create Release
679679
id: create_release
680-
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
681-
env:
682-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
680+
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe
683681
with:
684682
tag_name: ${{needs.configure.outputs.tag_name}}
685683
target_commitish: ${{ needs.configure.outputs.version_commit }}

.github/workflows/test-ff-matrix.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020
- ".github/workflows/stale-needs-repro.yml"
2121
- ".github/workflows/test-bundle.yml"
2222
- ".github/workflows/test-smokes-parallel.yml"
23+
- ".github/workflows/test-install.yml"
2324
- ".github/workflows/test-quarto-latexmk.yml"
2425
- ".github/workflows/update-test-timing.yml"
2526
pull_request:
@@ -31,6 +32,7 @@ on:
3132
- ".github/workflows/performance-check.yml"
3233
- ".github/workflows/stale-needs-repro.yml"
3334
- ".github/workflows/test-bundle.yml"
35+
- ".github/workflows/test-install.yml"
3436
- ".github/workflows/test-smokes-parallel.yml"
3537
- ".github/workflows/test-quarto-latexmk.yml"
3638
- ".github/workflows/update-test-timing.yml"

.github/workflows/test-install.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Integration test for `quarto install` on platforms not covered by smoke tests.
2+
# Smoke tests (test-smokes.yml) cover x86_64 Linux and Windows.
3+
# This workflow fills the gap for arm64 Linux and macOS.
4+
name: Test Tool Install
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
- "v1.*"
11+
paths:
12+
- "src/tools/**"
13+
- ".github/workflows/test-install.yml"
14+
pull_request:
15+
paths:
16+
- "src/tools/**"
17+
- ".github/workflows/test-install.yml"
18+
schedule:
19+
# Weekly Monday 9am UTC — detect upstream CDN/API breakage
20+
- cron: "0 9 * * 1"
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
test-install:
27+
name: Install tools (${{ matrix.os }})
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os: [ubuntu-24.04-arm, macos-latest]
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- name: Checkout Repo
35+
uses: actions/checkout@v6
36+
37+
- uses: ./.github/workflows/actions/quarto-dev
38+
39+
- name: Install TinyTeX
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
quarto install tinytex
44+
45+
- name: Install Chrome Headless Shell
46+
run: |
47+
quarto install chrome-headless-shell --no-prompt
48+
49+
- name: Verify tools with quarto check
50+
run: |
51+
quarto check install
52+
53+
test-chromium-deprecation:
54+
name: Chromium deprecation redirect (${{ matrix.os }})
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
59+
runs-on: ${{ matrix.os }}
60+
steps:
61+
- name: Checkout Repo
62+
uses: actions/checkout@v6
63+
64+
- uses: ./.github/workflows/actions/quarto-dev
65+
66+
- name: Make quarto available in bash (Windows)
67+
if: runner.os == 'Windows'
68+
shell: bash
69+
run: |
70+
quarto_cmd=$(command -v quarto.cmd)
71+
dir=$(dirname "$quarto_cmd")
72+
printf '#!/bin/bash\nexec "%s" "$@"\n' "$quarto_cmd" > "$dir/quarto"
73+
chmod +x "$dir/quarto"
74+
75+
- name: Install chromium (should redirect to chrome-headless-shell)
76+
id: install-chromium
77+
shell: bash
78+
run: |
79+
set +e
80+
output=$(quarto install chromium --no-prompt 2>&1)
81+
exit_code=$?
82+
set -e
83+
echo "$output"
84+
if echo "$output" | grep -Fq "is deprecated"; then
85+
echo "deprecation-warning=true" >> "$GITHUB_OUTPUT"
86+
fi
87+
if [ "$exit_code" -eq 0 ]; then
88+
echo "install-successful=true" >> "$GITHUB_OUTPUT"
89+
fi
90+
91+
- name: Assert deprecation warning was shown
92+
shell: bash
93+
run: |
94+
if [ "${{ steps.install-chromium.outputs.deprecation-warning }}" != "true" ]; then
95+
echo "::error::Deprecation warning missing from 'quarto install chromium' output"
96+
exit 1
97+
fi
98+
echo "Install deprecation warning found"
99+
100+
- name: Assert installation succeeded (via redirect)
101+
shell: bash
102+
run: |
103+
if [ "${{ steps.install-chromium.outputs.install-successful }}" != "true" ]; then
104+
echo "::error::Installation did not succeed — redirect to chrome-headless-shell may have failed"
105+
exit 1
106+
fi
107+
echo "Installation succeeded via redirect"
108+
109+
- name: Verify quarto check shows Chrome Headless Shell
110+
shell: bash
111+
run: |
112+
output=$(quarto check install 2>&1)
113+
echo "$output"
114+
if ! echo "$output" | grep -Fq "Chrome Headless Shell"; then
115+
echo "::error::Chrome Headless Shell not detected by quarto check after redirect install"
116+
exit 1
117+
fi
118+
if echo "$output" | grep -Fq 'chrome-headless-shell" to replace'; then
119+
echo "::error::Legacy Chromium still installed — afterInstall should have removed it"
120+
exit 1
121+
fi
122+
123+
- name: Verify quarto list tools does not show chromium
124+
shell: bash
125+
env:
126+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
run: |
128+
set +e
129+
output=$(quarto list tools 2>&1)
130+
exit_code=$?
131+
set -e
132+
echo "$output"
133+
if [ "$exit_code" -ne 0 ]; then
134+
echo "::error::'quarto list tools' exited with code $exit_code (see output above)"
135+
exit 1
136+
fi
137+
if echo "$output" | grep -iq "chromium"; then
138+
echo "::error::Deprecated chromium should not appear in 'quarto list tools' when not installed"
139+
exit 1
140+
fi
141+
142+
- name: Update chromium (should redirect) and capture result
143+
id: update-chromium
144+
shell: bash
145+
run: |
146+
set +e
147+
output=$(quarto update tool chromium --no-prompt 2>&1)
148+
exit_code=$?
149+
set -e
150+
echo "$output"
151+
if echo "$output" | grep -Fq "is deprecated"; then
152+
echo "deprecation-warning=true" >> "$GITHUB_OUTPUT"
153+
fi
154+
if [ "$exit_code" -eq 0 ]; then
155+
echo "update-successful=true" >> "$GITHUB_OUTPUT"
156+
fi
157+
158+
- name: Assert update deprecation warning was shown and succeeded
159+
shell: bash
160+
run: |
161+
if [ "${{ steps.update-chromium.outputs.deprecation-warning }}" != "true" ]; then
162+
echo "::error::Deprecation warning missing from 'quarto update tool chromium' output"
163+
exit 1
164+
fi
165+
echo "Update deprecation warning found"
166+
if [ "${{ steps.update-chromium.outputs.update-successful }}" != "true" ]; then
167+
echo "::error::Update command failed — redirect to chrome-headless-shell may have failed"
168+
exit 1
169+
fi
170+
echo "Update succeeded via redirect"

.github/workflows/test-smokes-parallel.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929
- ".github/workflows/stale-needs-repro.yml"
3030
- ".github/workflows/test-bundle.yml"
3131
- ".github/workflows/test-ff-matrix.yml"
32+
- ".github/workflows/test-install.yml"
3233
- ".github/workflows/test-quarto-latexmk.yml"
3334
- ".github/workflows/update-test-timing.yml"
3435
push:

0 commit comments

Comments
 (0)