package web
import (
"regexp"
"strings"
"testing"
)
// The composer is the largest control on the page and states its focus
// with a caret. The global rule for text fields is THREE declarations —
// outline:none, an accent border-color, and a box-shadow halo — so a
// field opting out has to cancel the ones that can still draw. An
// earlier pass cancelled only the outline and left the halo, which is
// the ring that was still there.
func TestTheComposerCancelsEveryFocusRingItCanDraw(t *testing.T) {
rule := regexp.MustCompile(`\.composer-in:focus[^{]*\{([^}]*)\}`)
m := rule.FindStringSubmatch(sheetLiteral)
if m == nil {
t.Fatal("FAIL: the composer has no focus rule at all")
}
for _, want := range []string{"outline:none", "box-shadow:none"} {
if !strings.Contains(m[1], want) {
t.Errorf("FAIL: the composer's focus rule is missing %q — it draws %q", want, m[1])
} else {
t.Logf("ok: the composer cancels %s", want)
}
}
// Scoped to THIS field: every other input keeps the ring that says
// which of several it is.
if strings.Contains(sheetLiteral, "textarea:focus-visible{outline:none;box-shadow:none}") {
t.Error("FAIL: the opt-out is global, so no field on the forge shows focus")
} else {
t.Log("ok: every other field keeps its ring")
}
}