form-tester 0.11.1 → 0.11.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.
@@ -153,7 +153,7 @@ Step 9 — Dokumenter verification (only when modal confirms storage):
153
153
  ```
154
154
  form-tester documents
155
155
  ```
156
- This handles the full flow: navigate to Dokumenter, find latest doc, detect format, download PDF or screenshot HTML.
156
+ This handles the full flow: navigate to Dokumenter, select person if needed, find latest doc, detect format, download PDF or screenshot HTML.
157
157
 
158
158
  If `form-tester documents` fails (logged as issues), fall back to manual steps:
159
159
  1. Navigate to `/dokumenter?pnr={PNR}` and select the same person.
package/form-tester.js CHANGED
@@ -7,7 +7,7 @@ const { spawn, execSync } = require("child_process");
7
7
  const CONFIG_PATH = path.join(process.cwd(), "form-tester.config.json");
8
8
  const OUTPUT_BASE = path.resolve(process.cwd(), "output");
9
9
  const ISSUES_PATH = path.join(OUTPUT_BASE, "issues.jsonl");
10
- const LOCAL_VERSION = "0.11.1";
10
+ const LOCAL_VERSION = "0.11.3";
11
11
  const RECOMMENDED_PERSON = "Uromantisk Direktør";
12
12
 
13
13
  // Recording — persisted to disk so `form-tester exec` can append across processes
@@ -167,13 +167,47 @@ async function handleDocuments(config, flags = {}) {
167
167
  }
168
168
  await sleep(2000);
169
169
 
170
- // Step 2: Take snapshot of document list
170
+ // Step 2: Check if person selection is needed
171
+ const checkSnapshot = path.join(outputDir, "dokumenter_check.yml");
172
+ await runPlaywrightCli(["snapshot", "--filename", checkSnapshot]);
173
+ if (fs.existsSync(checkSnapshot)) {
174
+ const checkText = fs.readFileSync(checkSnapshot, "utf8");
175
+ if (checkText.includes("Hvem vil du bruke Helsenorge") || checkText.includes("personliste")) {
176
+ log("Person selection detected on Dokumenter page. Selecting person...");
177
+ // Use direct click approach — the person page has simple buttons with person names
178
+ const personName = config.lastPerson || config.person || RECOMMENDED_PERSON;
179
+ const clickScript = `() => {
180
+ const buttons = Array.from(document.querySelectorAll('button'));
181
+ const target = ${JSON.stringify(personName)};
182
+ for (const btn of buttons) {
183
+ const text = (btn.textContent || "").replace(/\\s+/g, " ").trim();
184
+ if (text.includes(target)) { btn.click(); return "clicked: " + text.substring(0, 60); }
185
+ }
186
+ // Fallback: click first person button (usually has class personliste__person)
187
+ const first = document.querySelector('button[class*="personliste"], button[class*="person"]');
188
+ if (first) { first.click(); return "clicked-first: " + (first.textContent || "").trim().substring(0, 60); }
189
+ return "not-found";
190
+ }`;
191
+ const personResult = await runPlaywrightCliCapture(["eval", clickScript]);
192
+ const personOutput = personResult.stdout.replace(/^### Result\s*/i, "").trim();
193
+ if (personOutput.startsWith("clicked")) {
194
+ log(`Person selected: ${personOutput}`);
195
+ } else {
196
+ log("Could not auto-select person. Trying select-person command...");
197
+ await handleSelectPerson(config, personName);
198
+ }
199
+ await sleep(2000);
200
+ }
201
+ try { fs.unlinkSync(checkSnapshot); } catch (e) {}
202
+ }
203
+
204
+ // Step 3: Take snapshot of document list
171
205
  const docListSnapshot = path.join(outputDir, "dokumenter.yml");
172
206
  await runPlaywrightCli(["snapshot", "--filename", docListSnapshot]);
173
207
  await runPlaywrightCli(["screenshot", "--filename", path.join(outputDir, "dokumenter.png"), "--full-page"]);
174
208
  log("Saved: dokumenter.yml + dokumenter.png");
175
209
 
176
- // Step 3: Click first document's "Se detaljer"
210
+ // Step 4: Click first document's "Se detaljer"
177
211
  log("Looking for first document...");
178
212
  const clickResult = await runPlaywrightCliCapture(["eval", '() => { const link = document.querySelector("a[href*=\\"detaljer\\"], button:has-text(\\"Se detaljer\\"), a:has-text(\\"Se detaljer\\")"); if (link) { link.click(); return "clicked"; } return "not-found"; }']);
179
213
  if (clickResult.stdout.includes("not-found")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-tester",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "AI-powered form testing skill for /skjemautfyller forms using Playwright CLI. Works with Claude Code and GitHub Copilot.",
5
5
  "main": "form-tester.js",
6
6
  "bin": {