form-tester 0.11.3 → 0.11.4

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 +32 -20
  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.3";
10
+ const LOCAL_VERSION = "0.11.4";
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,33 +167,45 @@ async function handleDocuments(config, flags = {}) {
167
167
  }
168
168
  await sleep(2000);
169
169
 
170
- // Step 2: Check if person selection is needed
170
+ // Step 2: Check if person selection is needed — parse snapshot for person buttons
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
- log("Person selection detected on Dokumenter page. Selecting person...");
177
- // Use direct click approach — the person page has simple buttons with person names
176
+ log("Person selection detected on Dokumenter page.");
178
177
  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); }
178
+ // Find the button ref directly from the snapshot text
179
+ let clickRef = null;
180
+ const lines = checkText.split(/\r?\n/);
181
+ for (const line of lines) {
182
+ const btnMatch = line.match(/button "([^"]*)" \[ref=(e\d+)\]/);
183
+ if (btnMatch && btnMatch[1].includes(personName)) {
184
+ clickRef = btnMatch[2];
185
+ log(`Found person button: "${btnMatch[1]}" (ref=${clickRef})`);
186
+ break;
185
187
  }
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}`);
188
+ }
189
+ // Fallback: find first button inside the person list region
190
+ if (!clickRef) {
191
+ let inRegion = false;
192
+ for (const line of lines) {
193
+ if (line.includes('region "Hvem vil du bruke Helsenorge')) inRegion = true;
194
+ if (inRegion) {
195
+ const btnMatch = line.match(/button "[^"]*" \[ref=(e\d+)\]/);
196
+ if (btnMatch) {
197
+ clickRef = btnMatch[1];
198
+ log(`Fallback: clicking first person button (ref=${clickRef})`);
199
+ break;
200
+ }
201
+ }
202
+ }
203
+ }
204
+ if (clickRef) {
205
+ await runPlaywrightCli(["click", clickRef]);
206
+ log("Person selected on Dokumenter page.");
195
207
  } else {
196
- log("Could not auto-select person. Trying select-person command...");
208
+ log("Could not find person button in snapshot. Trying select-person...");
197
209
  await handleSelectPerson(config, personName);
198
210
  }
199
211
  await sleep(2000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-tester",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
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": {