High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
test: add comprehensive PDF parameter tests + documentation
Mariob5072bcb47df
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 235230cd..c509afb5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,7 +2,12 @@## Unreleased-- TBD+### Added+- **PDF export parameters** — `/pdf` API now supports full PrintToPDFParams: `paperWidth`, `paperHeight`, `marginTop`, `marginBottom`, `marginLeft`, `marginRight`, `pageRanges`, `displayHeaderFooter`, `headerTemplate`, `footerTemplate`, `generateTaggedPDF`, `generateDocumentOutline`, `preferCSSPageSize` (#45, PR #48)+- **Installer branding** — install.sh now uses yellow accent color (#fbbf24) and crab icon 🦀 for consistency (PR #48)++### Docs+- **Definition of Done** — Added DEFINITION_OF_DONE.md and GitHub PR template with streamlined, actionable checklist (PR #48)## v0.5.0diff --git a/README.md b/README.mdindex 128ad30b..9b730a82 100644--- a/README.md+++ b/README.md@@ -305,14 +305,32 @@ In headed mode, log into sites in the visible Chrome window once; cookies and lo| `output=file` | Save screenshot to disk instead of returning |### Query Parameters (pdf)-| Param | Description |-|-------|-------------|-| `tabId` | Target tab (default: first tab) |-| `landscape=true` | Landscape orientation |-| `scale=N` | Print scale (default: 1.0) |-| `raw=true` | Return raw PDF bytes |-| `output=file` | Save PDF to disk |-| `path=/custom/path` | Custom file path (with `output=file`) |+| Param | Type | Default | Description |+|-------|------|---------|-------------|+| `tabId` | string | first tab | Target tab |+| **Layout** | | | |+| `paperWidth` | float | 8.5 | Paper width in inches |+| `paperHeight` | float | 11.0 | Paper height in inches |+| `landscape` | bool | false | Landscape orientation |+| `marginTop` | float | 0.4 | Top margin in inches |+| `marginBottom` | float | 0.4 | Bottom margin in inches |+| `marginLeft` | float | 0.4 | Left margin in inches |+| `marginRight` | float | 0.4 | Right margin in inches |+| **Content** | | | |+| `scale` | float | 1.0 | Print scale (0.1–2.0) |+| `pageRanges` | string | all | Pages to export (e.g., `1-3,5`) |+| `preferCSSPageSize` | bool | false | Honor CSS @page size |+| **Header/Footer** | | | |+| `displayHeaderFooter` | bool | false | Show header and footer |+| `headerTemplate` | string | — | HTML for header (supports `<span class=date/title/url/pageNumber/totalPages>`) |+| `footerTemplate` | string | — | HTML for footer (same format as header) |+| **Accessibility** | | | |+| `generateTaggedPDF` | bool | false | Generate accessible/tagged PDF |+| `generateDocumentOutline` | bool | false | Embed document outline |+| **Output** | | | |+| `output=file` | string | JSON | Save to disk instead of returning base64 |+| `path=/custom/path` | string | auto | Custom file path (with `output=file`) |+| `raw=true` | bool | false | Return raw PDF bytes instead of JSON |### Query Parameters (text)| Param | Description |diff --git a/tests/integration/pdf_test.go b/tests/integration/pdf_test.goindex c1c8951e..cb5e6474 100644--- a/tests/integration/pdf_test.go+++ b/tests/integration/pdf_test.go@@ -88,4 +88,76 @@ func TestPDF_Scale(t *testing.T) {}}-// PD7: PDF no tab — tested implicitly (hard to close all tabs safely)+// PD7: PDF with custom paper size+func TestPDF_CustomPaperSize(t *testing.T) {+ navigate(t, "https://example.com")+ code, body := httpGet(t, "/pdf?paperWidth=7&paperHeight=9&raw=true")+ if code != 200 {+ t.Fatalf("expected 200, got %d", code)+ }+ if len(body) < 4 || string(body[:4]) != "%PDF" {+ t.Error("expected valid PDF with custom paper size")+ }+}++// PD8: PDF with custom margins+func TestPDF_CustomMargins(t *testing.T) {+ navigate(t, "https://example.com")+ code, body := httpGet(t, "/pdf?marginTop=0.75&marginLeft=0.75&marginRight=0.75&marginBottom=0.75&raw=true")+ if code != 200 {+ t.Fatalf("expected 200, got %d", code)+ }+ if len(body) < 4 || string(body[:4]) != "%PDF" {+ t.Error("expected valid PDF with custom margins")+ }+}++// PD9: PDF with page ranges+func TestPDF_PageRanges(t *testing.T) {+ navigate(t, "https://example.com")+ code, body := httpGet(t, "/pdf?pageRanges=1&raw=true")+ if code != 200 {+ t.Fatalf("expected 200, got %d", code)+ }+ if len(body) < 4 || string(body[:4]) != "%PDF" {+ t.Error("expected valid PDF with page ranges")+ }+}++// PD10: PDF with header/footer+func TestPDF_HeaderFooter(t *testing.T) {+ navigate(t, "https://example.com")+ code, body := httpGet(t, "/pdf?displayHeaderFooter=true&headerTemplate=%3Cspan%20class=url%3E%3C/span%3E&raw=true")+ if code != 200 {+ t.Fatalf("expected 200, got %d", code)+ }+ if len(body) < 4 || string(body[:4]) != "%PDF" {+ t.Error("expected valid PDF with header/footer")+ }+}++// PD11: PDF with accessibility and outline+func TestPDF_AccessiblePDF(t *testing.T) {+ navigate(t, "https://example.com")+ code, body := httpGet(t, "/pdf?generateTaggedPDF=true&generateDocumentOutline=true&raw=true")+ if code != 200 {+ t.Fatalf("expected 200, got %d", code)+ }+ if len(body) < 4 || string(body[:4]) != "%PDF" {+ t.Error("expected valid accessible PDF")+ }+}++// PD12: PDF with preferCSSPageSize+func TestPDF_PreferCSSPageSize(t *testing.T) {+ navigate(t, "https://example.com")+ code, body := httpGet(t, "/pdf?preferCSSPageSize=true&raw=true")+ if code != 200 {+ t.Fatalf("expected 200, got %d", code)+ }+ if len(body) < 4 || string(body[:4]) != "%PDF" {+ t.Error("expected valid PDF with CSS page size")+ }+}++// PD13: PDF no tab — tested implicitly (hard to close all tabs safely)