fix(web): skip fields of disabled fieldsets when submitting forms
The serializer checked the disabled property, which only reflects a field's own attribute, so settings of other monitor types were sent too and fields with the same name overwrote each other. Forms also gain arrays from numbered names and header lines. Browser tests now run every page in testdata, with a time limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
5a76702dba
commit
8fe56546a0
3 files changed
+101
-22
No files matched your search
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
<!doctype html><html><body data-msg-network="net">
|
||||
<form data-api="/org/monitors" data-next="#saved" id="f">
|
||||
<select name="type" data-type-select><option value="http">http</option><option value="json" selected>json</option><option value="heartbeat">heartbeat</option></select>
|
||||
<input name="name" value="Queue">
|
||||
<div data-hide-for="heartbeat"><input name="target" value="https://x" required></div>
|
||||
<fieldset data-type="json">
|
||||
<select name="config.method"><option value="POST" selected>POST</option></select>
|
||||
<textarea name="config.headers" data-headers>Authorization: Bearer a:b
|
||||
X-Empty:
|
||||
: nothing</textarea>
|
||||
<input name="config.assertions.0.path" value="status"><input name="config.assertions.0.op" value="==">
|
||||
<input name="config.assertions.1.path" value="queue.depth"><input name="config.assertions.1.op" value="<">
|
||||
</fieldset>
|
||||
<fieldset data-type="http" disabled hidden><select name="config.method"><option value="HEAD" selected>HEAD</option></select></fieldset>
|
||||
<fieldset data-hide-for="heartbeat"><input type="checkbox" name="regions" value="r1" data-multi checked></fieldset>
|
||||
<button type="submit">save</button>
|
||||
</form>
|
||||
<pre id="out"></pre>
|
||||
<script>
|
||||
const sent = [];
|
||||
window.axios = { create: () => ({ interceptors: { request: { use() {} } }, request: async (cfg) => { sent.push(cfg.data); return { data: {} }; }, post: async () => ({ data: {} }) }) };
|
||||
</script>
|
||||
<script src="../assets/app.js"></script>
|
||||
<script>
|
||||
(async () => {
|
||||
const out = [];
|
||||
const check = (name, got, want) => {
|
||||
const g = JSON.stringify(got), w = JSON.stringify(want);
|
||||
out.push((g === w ? "PASS " : "FAIL ") + name + (g === w ? "" : " got=" + g + " want=" + w));
|
||||
};
|
||||
const form = document.getElementById("f");
|
||||
const submit = async () => {
|
||||
form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
|
||||
await new Promise((r) => setTimeout(r, 20));
|
||||
return sent.at(-1);
|
||||
};
|
||||
let body = await submit();
|
||||
check("fields of a disabled fieldset are skipped", body.config.method, "POST");
|
||||
check("numbered names build arrays", body.config.assertions, [{ path: "status", op: "==" }, { path: "queue.depth", op: "<" }]);
|
||||
check("header lines become an object", body.config.headers, { Authorization: "Bearer a:b", "X-Empty": "" });
|
||||
check("regions sent", body.regions, ["r1"]);
|
||||
|
||||
const sel = form.querySelector("[data-type-select]");
|
||||
sel.value = "heartbeat";
|
||||
sel.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
check("target hidden for heartbeats", form.querySelector('[data-hide-for]').hidden, true);
|
||||
check("target not required for heartbeats", form.querySelector('[name="target"]').required, false);
|
||||
body = await submit();
|
||||
check("regions of a hidden fieldset are not sent", body.regions, []);
|
||||
sel.value = "json";
|
||||
sel.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
check("target required again", form.querySelector('[name="target"]').required, true);
|
||||
document.getElementById("out").textContent = out.join("\n");
|
||||
})();
|
||||
</script></body></html>
|
||||
Reference in new issue
Block a user