form-tester 0.10.1 → 0.10.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.
|
@@ -71,8 +71,9 @@ IMPORTANT: Each prompt below MUST be asked as a separate message to the user. Wa
|
|
|
71
71
|
4. Only after receiving answers to all prompts, proceed with the steps below.
|
|
72
72
|
|
|
73
73
|
Step 1 — Open and setup:
|
|
74
|
+
If the user gives a partial URL (e.g. `skjemautfyller/SLV-PasRapp-2020`), read `form-tester.config.json` to get `baseUrl` and `pnr`. Construct the full URL as `{baseUrl}/{path}?pnr={pnr}`. Do NOT guess the domain.
|
|
74
75
|
```
|
|
75
|
-
form-tester test <url> --auto --pnr <pnr> --persona <id> --scenario "<text>"
|
|
76
|
+
form-tester test <full-url> --auto --pnr <pnr> --persona <id> --scenario "<text>"
|
|
76
77
|
```
|
|
77
78
|
|
|
78
79
|
Step 2 — Dismiss cookies:
|
|
@@ -15,12 +15,15 @@ form-tester install
|
|
|
15
15
|
When the user gives you a form URL to test, execute ALL steps below in sequence WITHOUT stopping to ask. Do not ask "want me to continue?" — just do the entire flow.
|
|
16
16
|
|
|
17
17
|
### Step 1 — Start the test
|
|
18
|
+
|
|
19
|
+
If the user gives a partial URL (e.g. `skjemautfyller/SLV-PasRapp-2020`), read `form-tester.config.json` first to get `baseUrl` and `pnr`. Construct the full URL as `{baseUrl}/{partial-path}?pnr={pnr}`. Do NOT guess the domain — always use `baseUrl` from config.
|
|
20
|
+
|
|
18
21
|
```bash
|
|
19
|
-
form-tester test <url> --auto
|
|
22
|
+
form-tester test <full-url> --auto
|
|
20
23
|
```
|
|
21
24
|
Or with options:
|
|
22
25
|
```bash
|
|
23
|
-
form-tester test <url> --auto --pnr 12345 --persona ung-mann --scenario "test validation"
|
|
26
|
+
form-tester test <full-url> --auto --pnr 12345 --persona ung-mann --scenario "test validation"
|
|
24
27
|
```
|
|
25
28
|
|
|
26
29
|
### Step 2 — Dismiss cookies
|
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.10.
|
|
10
|
+
const LOCAL_VERSION = "0.10.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
|
|
@@ -300,6 +300,12 @@ async function handleSelectPerson(config, targetName) {
|
|
|
300
300
|
const v = "normal";
|
|
301
301
|
const log = (msg) => console.log(msg);
|
|
302
302
|
|
|
303
|
+
// Use config.person as default if no target specified
|
|
304
|
+
if (!targetName && config.person) {
|
|
305
|
+
targetName = config.person;
|
|
306
|
+
log(`Using configured person: ${targetName}`);
|
|
307
|
+
}
|
|
308
|
+
|
|
303
309
|
// Step 1: Try to find person list from current page snapshot
|
|
304
310
|
const tmpSnapshot = path.join(
|
|
305
311
|
config.lastRunDir || OUTPUT_BASE,
|
|
@@ -651,6 +657,8 @@ async function promptPersona(config) {
|
|
|
651
657
|
}
|
|
652
658
|
const DEFAULT_CONFIG = {
|
|
653
659
|
pnr: "",
|
|
660
|
+
person: "",
|
|
661
|
+
baseUrl: "",
|
|
654
662
|
dokumenterUrlTemplate: "/dokumenter?pnr={PNR}",
|
|
655
663
|
lastTestUrl: "",
|
|
656
664
|
lastRunDir: "",
|
|
@@ -673,11 +681,17 @@ function saveConfig(config) {
|
|
|
673
681
|
|
|
674
682
|
function resolveDokumenterUrl(config) {
|
|
675
683
|
if (!config.dokumenterUrlTemplate) return "";
|
|
676
|
-
|
|
684
|
+
let url = config.dokumenterUrlTemplate;
|
|
685
|
+
if (url.includes("{PNR}")) {
|
|
677
686
|
if (!config.pnr) return "";
|
|
678
|
-
|
|
687
|
+
url = url.replace("{PNR}", config.pnr);
|
|
688
|
+
}
|
|
689
|
+
// If the URL is a relative path, prepend the base URL
|
|
690
|
+
if (url.startsWith("/")) {
|
|
691
|
+
const base = config.baseUrl || (config.lastTestUrl ? (() => { try { return new URL(config.lastTestUrl).origin; } catch (e) { return ""; } })() : "");
|
|
692
|
+
if (base) url = `${base}${url}`;
|
|
679
693
|
}
|
|
680
|
-
return
|
|
694
|
+
return url;
|
|
681
695
|
}
|
|
682
696
|
|
|
683
697
|
function extractPnrFromUrl(url) {
|
|
@@ -1346,6 +1360,7 @@ async function handleTest(url, config) {
|
|
|
1346
1360
|
|
|
1347
1361
|
config.lastTestUrl = updated.url;
|
|
1348
1362
|
config.lastRunDir = outputDir;
|
|
1363
|
+
try { config.baseUrl = new URL(updated.url).origin; } catch (e) {}
|
|
1349
1364
|
saveConfig(config);
|
|
1350
1365
|
|
|
1351
1366
|
// Start recording and persist path to config for `exec`
|
|
@@ -1463,6 +1478,7 @@ async function handleTestAuto(url, config, flags) {
|
|
|
1463
1478
|
|
|
1464
1479
|
config.lastTestUrl = fullUrl;
|
|
1465
1480
|
config.lastRunDir = outputDir;
|
|
1481
|
+
try { config.baseUrl = new URL(fullUrl).origin; } catch (e) {}
|
|
1466
1482
|
saveConfig(config);
|
|
1467
1483
|
|
|
1468
1484
|
// Start recording and persist path to config for `exec`
|
package/package.json
CHANGED