diff --git a/templates/snapshot_test.go b/templates/snapshot_test.go index 48b467fd..1b07aef5 100644 --- a/templates/snapshot_test.go +++ b/templates/snapshot_test.go @@ -2,12 +2,11 @@ package templates import ( "bytes" - "regexp" "strings" "testing" ) -func TestLoginTemplateTextSnapshot(t *testing.T) { +func TestLoginTemplateShowsCoreCopy(t *testing.T) { r, err := ProvideRenderer() if err != nil { t.Fatalf("ProvideRenderer: %v", err) @@ -18,25 +17,15 @@ func TestLoginTemplateTextSnapshot(t *testing.T) { t.Fatalf("ExecuteFragment: %v", err) } - got := visibleTextSnapshot(buf.String()) - const want = "Sign in to your account\nEmail address\nPassword\nSign In" - if got != want { - t.Fatalf("login text snapshot mismatch\n got: %q\nwant: %q", got, want) + body := buf.String() + for _, want := range []string{ + "Sign in to your account", + "Email address", + "Password", + "Sign In", + } { + if !strings.Contains(body, want) { + t.Fatalf("login template missing %q in output:\n%s", want, body) + } } } - -func visibleTextSnapshot(html string) string { - tags := regexp.MustCompile(`<[^>]+>`) - spaces := regexp.MustCompile(`[ \t]+`) - blankLines := regexp.MustCompile(`\n+`) - - text := tags.ReplaceAllString(html, "\n") - text = spaces.ReplaceAllString(text, " ") - lines := strings.Split(text, "\n") - for i, line := range lines { - lines[i] = strings.TrimSpace(line) - } - text = strings.Join(lines, "\n") - text = blankLines.ReplaceAllString(text, "\n") - return strings.TrimSpace(text) -}