//go:build browser // The design-system floors on the examples: every state of every // non-layout example, each loaded as its own document, held to the // tap-target floor, the 16px text floor, the icon sizes and spacing, // a clean load, and the same controls with no script at all. The // seeded sizing fixture (sizing_browser_test.go) is the preservation // drive for the same floors; this is the coverage drive, which the // examples feed. The layouts are held with the shells, not here. package check import ( "context" "encoding/json" "fmt" "net/http" "sort" "strings" "sync" "testing" "time" "github.com/chromedp/chromedp" "amadan.net/rastrillo/fiesta" "amadan.net/rastrillo/fiesta/example" "amadan.net/rastrillo/fiesta/internal/harness" ) // floorState is one example state as the floors drive visits it: its // address, and the path of its document and of its no-script twin. type floorState struct { Name, State string Path, NoScript string } // floorServer serves the states and counts what it served, by path, // so the drive can show it visited every state of the manifest rather // than every state of its own list. type floorServer struct { http.Handler mu sync.Mutex served map[string]int } // snapshot returns how many times each path has been served so far, // as a copy, so a leg can subtract the count before it from the count // after it. func (s *floorServer) snapshot() map[string]int { s.mu.Lock() defer s.mu.Unlock() out := map[string]int{} for k, v := range s.served { out[k] = v } return out } // floorPages reads every state of every non-layout example through // the manifest and example.Document, and serves each at the depth the // tree keeps it, examples//.html, so the document's own // relative links (../../css/tokens.css, ../../js/, // ../assets/) resolve against the embedded tree beside it // and nothing in the document is rewritten. Beside each is its // no-script twin, the same document with every script tag stripped, // at examples//.noscript.html, the same depth. The rest // of the tree (css/, js/, examples/assets/) is served as it is. func floorPages(t *testing.T) ([]floorState, *floorServer) { t.Helper() m, err := example.Load(fiesta.FS()) if err != nil { t.Fatal(err) } var states []floorState pages := map[string]string{} for _, e := range m.Examples { if e.Document || e.Kind == "layout" { continue } for _, s := range e.States { doc, err := example.Document(fiesta.FS(), e.Name, s.ID) if err != nil { t.Fatal(err) } if !strings.Contains(doc, "