oficina / estilo Public

chrome: assert the action icon for every kind, not only the toggle

Fable's P3.8 on estilo #34: dropping {{.Icon}} from the link kind of
estilo-bar-action survived, because only the toggle's icon was asserted.
The test now renders a link, a POST, a dialog and a toggle with an icon
and expects it before the label in each. Dropping {{.Icon}} from the
link, the POST or the dialog kind each fails it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 2f9e0de03038e3d832cbac6a0e9960f4b9b1167b parent 9684e44
1 file changed, +14 −3
  • chrome/stack_test.go +14 −3
diff --git a/chrome/stack_test.go b/chrome/stack_test.go
index 8c26921..60ccdb5 100644
--- a/chrome/stack_test.go
+++ b/chrome/stack_test.go
@@ -164,10 +164,21 @@ func TestAToggleActionIsDisabledUntilBound(t *testing.T) {
t.Errorf("got %s\nwant %s", got, c.want)
}
}
- // The icon is the app's own markup, drawn before the label in the bar.
+ // The icon is the app's own markup, drawn before the label in the bar,
+ // whatever kind the action is.
icon := template.HTML(`<svg aria-hidden="true"></svg>`)
- if got := render(t, "estilo-bar-action", Action{Item: menu.Item{Controls: "c", Label: "Format"}, Icon: icon}); !strings.HasSuffix(got, `data-estilo-toggle><svg aria-hidden="true"></svg>Format</button>`) {
- t.Errorf("the icon is not before the label: %s", got)
+ for kind, c := range map[string]struct {
+ item menu.Item
+ want string
+ }{
+ "toggle": {menu.Item{Controls: "c", Label: "Format"}, `data-estilo-toggle><svg aria-hidden="true"></svg>Format</button>`},
+ "link": {menu.Item{Href: "/s", Label: "Format"}, `<a rst-btn href="/s"><svg aria-hidden="true"></svg>Format</a>`},
+ "post": {menu.Item{Action: "/p", Label: "Format"}, `type="submit"><svg aria-hidden="true"></svg>Format</button></form>`},
+ "dialog": {menu.Item{Dialog: "d", Label: "Format"}, `command="show-modal"><svg aria-hidden="true"></svg>Format</button>`},
+ } {
+ if got := render(t, "estilo-bar-action", Action{Item: c.item, Icon: icon}); !strings.HasSuffix(got, c.want) {
+ t.Errorf("%s: the icon is not before the label: %s", kind, got)
+ }
}
}