form-tester 0.11.2 → 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.
- package/form-tester.js +37 -4
- 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.
|
|
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,14 +167,47 @@ 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.
|
|
177
|
-
|
|
176
|
+
log("Person selection detected on Dokumenter page.");
|
|
177
|
+
const personName = config.lastPerson || config.person || RECOMMENDED_PERSON;
|
|
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;
|
|
187
|
+
}
|
|
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.");
|
|
207
|
+
} else {
|
|
208
|
+
log("Could not find person button in snapshot. Trying select-person...");
|
|
209
|
+
await handleSelectPerson(config, personName);
|
|
210
|
+
}
|
|
178
211
|
await sleep(2000);
|
|
179
212
|
}
|
|
180
213
|
try { fs.unlinkSync(checkSnapshot); } catch (e) {}
|
package/package.json
CHANGED