//go:build browser
package thintest
import (
"amadan.net/oficina/equipo/internal/wire"
"fmt"
"testing"
)
func TestBrowserAccessReview(t *testing.T) {
for _, width := range []int64{1280, 390} {
for _, scheme := range []string{"light", "dark"} {
t.Run(fmt.Sprintf("%d-%s", width, scheme), func(t *testing.T) {
r := newToolRigSaying(t, wire.ProtocolCurrent, "Give access to the whole carlos namespace")
reason := `I need access.
`
got := r.call("broad-access", wire.ToolRequestAccess, map[string]any{"target": "carlos", "reason": reason})
if got.Code != "asked" {
t.Fatal(got)
}
r.runner.Send(r.ctx, "broad-reply", wire.FrameReply, wire.Reply{TurnID: r.turn, Attempt: 1, Text: "Please confirm."})
r.wait("reply", func(c *Conversation) bool { return c.Turns[r.turn].State == wire.TurnReplied })
p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 844, width == 390, scheme, "reduce")
defer p.stop()
p.open("/conversation")
p.wait(`document.querySelector('[data-access-confirm]')`, "confirmation")
p.check(`document.querySelector('[data-access-state]').textContent.includes('Ask Amadan for access to everything in carlos?')`, "broad scope")
p.check(`!document.querySelector('[data-access-state] img') && !window.accessInjection && document.querySelector('[data-access-state]').textContent.includes('![]()