refactor: integration tests use Imprint pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5acf63cb4b
commit
2fab89ea46
1 changed files with 23 additions and 26 deletions
|
|
@ -1,11 +1,9 @@
|
|||
package html
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
i18n "forge.lthn.ai/core/go-i18n"
|
||||
"forge.lthn.ai/core/go-i18n/reversal"
|
||||
)
|
||||
|
||||
func TestIntegration_RenderThenReverse(t *testing.T) {
|
||||
|
|
@ -18,12 +16,7 @@ func TestIntegration_RenderThenReverse(t *testing.T) {
|
|||
C(El("p", Text("Files deleted successfully"))).
|
||||
F(El("small", Text("Completed")))
|
||||
|
||||
rendered := page.Render(ctx)
|
||||
text := stripTags(rendered)
|
||||
|
||||
tok := reversal.NewTokeniser()
|
||||
tokens := tok.Tokenise(text)
|
||||
imp := reversal.NewImprint(tokens)
|
||||
imp := Imprint(page, ctx)
|
||||
|
||||
if imp.UniqueVerbs == 0 {
|
||||
t.Error("reversal found no verbs in rendered page")
|
||||
|
|
@ -33,23 +26,27 @@ func TestIntegration_RenderThenReverse(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// stripTags removes HTML tags for plain text extraction.
|
||||
func stripTags(html string) string {
|
||||
var b strings.Builder
|
||||
inTag := false
|
||||
for _, r := range html {
|
||||
if r == '<' {
|
||||
inTag = true
|
||||
b.WriteByte(' ')
|
||||
continue
|
||||
func TestIntegration_ResponsiveImprint(t *testing.T) {
|
||||
svc, _ := i18n.New()
|
||||
i18n.SetDefault(svc)
|
||||
ctx := NewContext()
|
||||
|
||||
r := NewResponsive().
|
||||
Variant("desktop", NewLayout("HLCRF").
|
||||
H(El("h1", Text("Building project"))).
|
||||
L(El("nav", Text("Deleted files"))).
|
||||
C(El("p", Text("Files deleted successfully"))).
|
||||
R(El("aside", Text("Completed"))).
|
||||
F(El("small", Text("Completed")))).
|
||||
Variant("mobile", NewLayout("C").
|
||||
C(El("p", Text("Files deleted successfully"))))
|
||||
|
||||
imp := Imprint(r, ctx)
|
||||
|
||||
if imp.TokenCount == 0 {
|
||||
t.Error("responsive imprint produced zero tokens")
|
||||
}
|
||||
if r == '>' {
|
||||
inTag = false
|
||||
continue
|
||||
if imp.UniqueVerbs == 0 {
|
||||
t.Error("responsive imprint found no verbs")
|
||||
}
|
||||
if !inTag {
|
||||
b.WriteRune(r)
|
||||
}
|
||||
}
|
||||
return strings.TrimSpace(b.String())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue