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:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 11:45:11 +01:00
1 parent 5a76702dba
commit 8fe56546a0
3 files changed
+101 -22

No files matched your search

+32 -19
View File
@@ -1,16 +1,19 @@
package web
import (
"context"
"html"
"os/exec"
"path/filepath"
"regexp"
"strings"
"testing"
"time"
)
// TestMarkdownEditor runs testdata/editor.html, which drives the editor in
// assets/app.js and reports PASS or FAIL lines, in a headless browser.
func TestMarkdownEditor(t *testing.T) {
// TestScripts runs the pages in testdata, which drive assets/app.js and
// report PASS or FAIL lines, in a headless browser.
func TestScripts(t *testing.T) {
var browser string
for _, name := range []string{"chromium", "chromium-browser", "google-chrome"} {
if p, err := exec.LookPath(name); err == nil {
@@ -21,22 +24,32 @@ func TestMarkdownEditor(t *testing.T) {
if browser == "" {
t.Skip("no Chromium to run the editor in")
}
page, err := filepath.Abs("testdata/editor.html")
if err != nil {
t.Fatal(err)
pages, err := filepath.Glob("testdata/*.html")
if err != nil || len(pages) == 0 {
t.Fatalf("no test pages: %v", err)
}
out, err := exec.Command(browser, "--headless", "--disable-gpu", "--allow-file-access-from-files",
"--virtual-time-budget=3000", "--dump-dom", "file://"+page).Output()
if err != nil {
t.Fatalf("running %s: %v", browser, err)
}
m := regexp.MustCompile(`(?s)<pre id="out">(.*?)</pre>`).FindSubmatch(out)
if m == nil || len(m[1]) == 0 {
t.Fatal("the editor test page produced no results")
}
for _, line := range strings.Split(string(m[1]), "\n") {
if !strings.HasPrefix(line, "PASS ") {
t.Error(line)
}
for _, rel := range pages {
t.Run(filepath.Base(rel), func(t *testing.T) {
page, err := filepath.Abs(rel)
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
out, err := exec.CommandContext(ctx, browser, "--headless", "--disable-gpu", "--allow-file-access-from-files",
"--virtual-time-budget=3000", "--dump-dom", "file://"+page).Output()
if err != nil {
t.Fatalf("running %s: %v", browser, err)
}
m := regexp.MustCompile(`(?s)<pre id="out">(.*?)</pre>`).FindSubmatch(out)
if m == nil || len(m[1]) == 0 {
t.Fatal("the page produced no results")
}
for _, line := range strings.Split(string(m[1]), "\n") {
if !strings.HasPrefix(line, "PASS ") {
t.Error(html.UnescapeString(line))
}
}
})
}
}