form-tester 0.11.2 → 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.
Files changed (2) hide show
  1. package/form-tester.js +24 -3
  2. package/package.json +1 -1
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.2";
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,14 +167,35 @@ async function handleDocuments(config, flags = {}) {
167
167
  }
168
168
  await sleep(2000);
169
169
 
170
- // Step 2: Check if person selection is needed (same page as form)
170
+ // Step 2: Check if person selection is needed
171
171
  const checkSnapshot = path.join(outputDir, "dokumenter_check.yml");
172
172
  await runPlaywrightCli(["snapshot", "--filename", checkSnapshot]);
173
173
  if (fs.existsSync(checkSnapshot)) {
174
174
  const checkText = fs.readFileSync(checkSnapshot, "utf8");
175
175
  if (checkText.includes("Hvem vil du bruke Helsenorge") || checkText.includes("personliste")) {
176
176
  log("Person selection detected on Dokumenter page. Selecting person...");
177
- await handleSelectPerson(config, config.lastPerson || config.person || null);
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
+ }
178
199
  await sleep(2000);
179
200
  }
180
201
  try { fs.unlinkSync(checkSnapshot); } catch (e) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-tester",
3
- "version": "0.11.2",
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": {