oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3package thintest
4
5import (
6 "encoding/json"
7 "fmt"
8 "strings"
9 "testing"
10
11 "amadan.net/oficina/equipo/internal/wire"
12)
13
14func TestBrowserActivitySubjects(t *testing.T) {
15 r := newToolRig(t)
16 title := "Project threads with a long title " + strings.Repeat("é", 20)
17 id := taskID(t, r.call("record", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": title}))
18 words, _ := r.client.Thinking(r.ctx)
19 raw, _ := json.Marshal(words.Sets[0].Phrases["think"])
20 js := func(v string) string { b, _ := json.Marshal(v); return string(b) }
21 for _, width := range []int64{1280, 390} {
22 t.Run(fmt.Sprint(width), func(t *testing.T) {
23 p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 900, width == 390, "light", "no-preference")
24 defer p.stop()
25 p.open("/conversation")
26 line := `document.querySelector('[equipo-thinking][data-turn="` + r.turn + `"]')`
27 phrase := line + `?.querySelector('[equipo-phrase] [data-in]')?.textContent`
28 p.wait(string(raw)+`.includes(`+phrase+`)`, "set phrase during thinking")
29 r.call("read-"+fmt.Sprint(width), wire.ToolReadTask, map[string]string{"task": id})
30 short := "Checking ‘" + string([]rune(title)[:39]) + "…’…"
31 full := "Checking ‘" + title + "’…"
32 p.wait(phrase+`===`+js(short), "named activity, with a shortened title")
33 p.check(line+`.querySelector('[equipo-activity]').textContent===`+js(full)+` && `+line+`.querySelector('[equipo-activity-line]').title===`+js(full), "full label for screen readers and tooltip")
34 // The cycling timer must never replace tool activity with a set phrase.
35 elapsed := eval[string](p, line+`.querySelector('[equipo-elapsed]').textContent`)
36 p.check(`(()=>{const now=Date.now;Date.now=()=>now()+60000;return true})()`, "advance phrase clock")
37 p.wait(line+`.querySelector('[equipo-elapsed]').textContent!==`+js(elapsed), "elapsed timer advanced")
38 if width == 1280 {
39 p.check(`!`+line+`.querySelector('[equipo-phrase]').hasAttribute('data-cut')`, "desktop has room for the shortened label")
40 }
41 p.shot(fmt.Sprintf("activity-subject-%d", width))
42 p.check(phrase+`===`+js(short), "tool label stays visible")
43 if err := r.runner.Send(r.ctx, "think-"+fmt.Sprint(width), wire.FrameActivity, wire.ActivityReport{TurnID: r.turn, Attempt: 1, Kind: wire.ActivityThink}); err != nil {
44 t.Fatal(err)
45 }
46 p.wait(string(raw)+`.includes(`+phrase+`)`, "set phrase returns between tools")
47 p.check(line+`.querySelector('[equipo-activity]').textContent==='Thinking'`, "plain thinking label for screen readers")
48 })
49 }
50}
51