form-tester 0.11.4 → 0.11.5
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 +73 -22
- 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.5";
|
|
11
11
|
const RECOMMENDED_PERSON = "Uromantisk Direktør";
|
|
12
12
|
|
|
13
13
|
// Recording — persisted to disk so `form-tester exec` can append across processes
|
|
@@ -175,40 +175,91 @@ async function handleDocuments(config, flags = {}) {
|
|
|
175
175
|
if (checkText.includes("Hvem vil du bruke Helsenorge") || checkText.includes("personliste")) {
|
|
176
176
|
log("Person selection detected on Dokumenter page.");
|
|
177
177
|
const personName = config.lastPerson || config.person || RECOMMENDED_PERSON;
|
|
178
|
-
// Find the button ref
|
|
178
|
+
// Find the button ref INSIDE the person list region (not the nav header)
|
|
179
179
|
let clickRef = null;
|
|
180
180
|
const lines = checkText.split(/\r?\n/);
|
|
181
|
+
let inRegion = false;
|
|
181
182
|
for (const line of lines) {
|
|
183
|
+
if (line.includes('region "Hvem vil du bruke Helsenorge')) inRegion = true;
|
|
184
|
+
if (!inRegion) continue;
|
|
182
185
|
const btnMatch = line.match(/button "([^"]*)" \[ref=(e\d+)\]/);
|
|
183
|
-
if (btnMatch
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
}
|
|
186
|
+
if (btnMatch) {
|
|
187
|
+
// First try to match person name
|
|
188
|
+
if (btnMatch[1].includes(personName)) {
|
|
189
|
+
clickRef = btnMatch[2];
|
|
190
|
+
log(`Found person button: "${btnMatch[1]}" (ref=${clickRef})`);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
// Or take first button in region as fallback
|
|
194
|
+
if (!clickRef) {
|
|
195
|
+
clickRef = btnMatch[2];
|
|
201
196
|
}
|
|
202
197
|
}
|
|
203
198
|
}
|
|
199
|
+
if (clickRef && !lines.some((l) => l.includes(personName) && l.includes(clickRef))) {
|
|
200
|
+
log(`Fallback: clicking first person button in region (ref=${clickRef})`);
|
|
201
|
+
}
|
|
204
202
|
if (clickRef) {
|
|
205
203
|
await runPlaywrightCli(["click", clickRef]);
|
|
206
|
-
log("Person
|
|
204
|
+
log("Person clicked on Dokumenter page. Waiting for navigation...");
|
|
205
|
+
await sleep(3000);
|
|
206
|
+
// Verify we left the person picker — take a new snapshot
|
|
207
|
+
const verifySnapshot = path.join(outputDir, "dokumenter_verify.yml");
|
|
208
|
+
await runPlaywrightCli(["snapshot", "--filename", verifySnapshot]);
|
|
209
|
+
if (fs.existsSync(verifySnapshot)) {
|
|
210
|
+
const verifyText = fs.readFileSync(verifySnapshot, "utf8");
|
|
211
|
+
if (verifyText.includes("Hvem vil du bruke Helsenorge")) {
|
|
212
|
+
// Still on person picker — the click might have opened the nav dropdown instead
|
|
213
|
+
// Try clicking the person button inside the full-page list (region), not the nav
|
|
214
|
+
log("Still on person picker. Looking for person in full-page list...");
|
|
215
|
+
const regionLines = verifyText.split(/\r?\n/);
|
|
216
|
+
let inFullPageRegion = false;
|
|
217
|
+
let retryRef = null;
|
|
218
|
+
for (const line of regionLines) {
|
|
219
|
+
if (line.includes('region "Hvem vil du bruke Helsenorge')) inFullPageRegion = true;
|
|
220
|
+
if (line.includes('listitem') && inFullPageRegion) {
|
|
221
|
+
const btnMatch = line.match(/button "[^"]*" \[ref=(e\d+)\]/);
|
|
222
|
+
// Also check next lines for button
|
|
223
|
+
if (btnMatch) {
|
|
224
|
+
retryRef = btnMatch[1];
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (inFullPageRegion) {
|
|
229
|
+
const btnMatch = line.match(/button "([^"]*)" \[ref=(e\d+)\]/);
|
|
230
|
+
if (btnMatch && btnMatch[1].includes(personName)) {
|
|
231
|
+
retryRef = btnMatch[2];
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// If region-based search didn't find it, just click first listitem button in region
|
|
237
|
+
if (!retryRef && inFullPageRegion) {
|
|
238
|
+
let inList = false;
|
|
239
|
+
for (const line of regionLines) {
|
|
240
|
+
if (line.includes('region "Hvem vil du bruke Helsenorge')) inList = true;
|
|
241
|
+
if (inList) {
|
|
242
|
+
const btnMatch = line.match(/button "[^"]*" \[ref=(e\d+)\].*\[cursor=pointer\]/);
|
|
243
|
+
if (btnMatch) {
|
|
244
|
+
retryRef = btnMatch[1];
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (retryRef) {
|
|
251
|
+
log(`Retrying with ref=${retryRef}...`);
|
|
252
|
+
await runPlaywrightCli(["click", retryRef]);
|
|
253
|
+
await sleep(3000);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
try { fs.unlinkSync(verifySnapshot); } catch (e) {}
|
|
257
|
+
}
|
|
207
258
|
} else {
|
|
208
259
|
log("Could not find person button in snapshot. Trying select-person...");
|
|
209
260
|
await handleSelectPerson(config, personName);
|
|
261
|
+
await sleep(3000);
|
|
210
262
|
}
|
|
211
|
-
await sleep(2000);
|
|
212
263
|
}
|
|
213
264
|
try { fs.unlinkSync(checkSnapshot); } catch (e) {}
|
|
214
265
|
}
|
package/package.json
CHANGED