form-tester 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -78,27 +78,33 @@ Dokumenter verification (only when modal confirms storage):
|
|
|
78
78
|
1. Navigate to `/dokumenter?pnr={PNR}` and select the same person used during form fill.
|
|
79
79
|
2. The document list loads sorted newest first. The first entry should match the form title.
|
|
80
80
|
3. Click "Se detaljer" on the first document, then click "Åpne dokumentet".
|
|
81
|
-
4. After clicking "Åpne dokumentet", the document
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- If
|
|
86
|
-
- If
|
|
87
|
-
- If
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
4. After clicking "Åpne dokumentet", determine the document format:
|
|
82
|
+
|
|
83
|
+
How to detect format:
|
|
84
|
+
- Take a snapshot: `form-tester exec snapshot`
|
|
85
|
+
- If snapshot shows a link with href containing `/pdf/` or `blob:` → PDF
|
|
86
|
+
- If `--full-page` screenshot times out → PDF (do NOT retry, switch to download)
|
|
87
|
+
- If snapshot shows rendered HTML content (headings, paragraphs, form data) → HTML
|
|
88
|
+
|
|
89
|
+
PDF documents — DOWNLOAD, do NOT screenshot:
|
|
90
|
+
IMPORTANT: `run-code` does NOT have access to `require` or `fs`. Do NOT use `require('fs')`. Use Playwright's download API instead.
|
|
91
|
+
|
|
92
|
+
Find the PDF download link in the snapshot (look for `a[href*="/pdf/"]` or "Last ned" link), then download using the Playwright download event:
|
|
93
|
+
```
|
|
94
|
+
form-tester exec run-code "async page => { const link = page.locator('a[href*=\"/pdf/\"]').first(); const [download] = await Promise.all([ page.waitForEvent('download'), link.click() ]); await download.saveAs('$OUTPUT_DIR/document.pdf'); }"
|
|
95
|
+
```
|
|
96
|
+
If there is no direct PDF link but a "Last ned" button:
|
|
97
|
+
```
|
|
98
|
+
form-tester exec run-code "async page => { const [download] = await Promise.all([ page.waitForEvent('download'), page.getByRole('link', { name: 'Last ned' }).click() ]); await download.saveAs('$OUTPUT_DIR/document.pdf'); }"
|
|
99
|
+
```
|
|
100
|
+
Verify the download: check that document.pdf exists in the output folder.
|
|
101
|
+
|
|
102
|
+
HTML documents — SCREENSHOT full page:
|
|
103
|
+
```
|
|
104
|
+
form-tester exec screenshot --filename "$OUTPUT_DIR/document_screenshot.png" --full-page
|
|
105
|
+
```
|
|
100
106
|
Also save raw HTML: `form-tester exec eval "document.documentElement.outerHTML"` → save to document.html.
|
|
101
107
|
|
|
102
|
-
|
|
108
|
+
XML/other: Note type in test_results.txt, skip capture.
|
|
103
109
|
|
|
104
110
|
5. Include the document verification results in test_results.txt (document title, whether it matched the form h1, document type: HTML/PDF/XML).
|
|
@@ -87,13 +87,18 @@ After submission, read the modal text:
|
|
|
87
87
|
- If it mentions Dokumenter storage -> navigate to `/dokumenter?pnr={PNR}`, verify the document appears.
|
|
88
88
|
- If it does NOT mention Dokumenter -> skip verification, note in test_results.txt.
|
|
89
89
|
|
|
90
|
-
Document capture —
|
|
90
|
+
Document capture — detect format via `form-tester exec snapshot`:
|
|
91
91
|
|
|
92
|
-
**PDF documents** (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
**PDF documents** (link with href containing `/pdf/`, or screenshot times out):
|
|
93
|
+
Do NOT screenshot PDFs. Do NOT use `require('fs')` in run-code (it doesn't exist there).
|
|
94
|
+
Download using Playwright's download event:
|
|
95
|
+
```
|
|
96
|
+
form-tester exec run-code "async page => { const link = page.locator('a[href*=\"/pdf/\"]').first(); const [download] = await Promise.all([ page.waitForEvent('download'), link.click() ]); await download.saveAs('$OUTPUT_DIR/document.pdf'); }"
|
|
97
|
+
```
|
|
98
|
+
Or if there's a "Last ned" button:
|
|
99
|
+
```
|
|
100
|
+
form-tester exec run-code "async page => { const [download] = await Promise.all([ page.waitForEvent('download'), page.getByRole('link', { name: 'Last ned' }).click() ]); await download.saveAs('$OUTPUT_DIR/document.pdf'); }"
|
|
101
|
+
```
|
|
97
102
|
|
|
98
103
|
**HTML documents**: `form-tester exec screenshot --filename "..." --full-page`. Also save raw HTML.
|
|
99
104
|
|
package/form-tester.js
CHANGED
|
@@ -6,7 +6,7 @@ const { spawn, execSync } = require("child_process");
|
|
|
6
6
|
|
|
7
7
|
const CONFIG_PATH = path.join(process.cwd(), "form-tester.config.json");
|
|
8
8
|
const OUTPUT_BASE = path.resolve(process.cwd(), "output");
|
|
9
|
-
const LOCAL_VERSION = "0.8.
|
|
9
|
+
const LOCAL_VERSION = "0.8.3";
|
|
10
10
|
const RECOMMENDED_PERSON = "Uromantisk Direktør";
|
|
11
11
|
|
|
12
12
|
// Recording — persisted to disk so `form-tester exec` can append across processes
|
package/package.json
CHANGED