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 "strings"
7 "testing"
8
9 "amadan.net/oficina/equipo/internal/wire"
10)
11
12// The task page's spend follows an answer live: when a question about
13// the task is answered, the total and the Questions line show what the
14// answer used without a reload.
15func TestBrowserSpendFollowsAnswers(t *testing.T) {
16 r := newToolRig(t)
17 base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
18 id, _, _ := r.askableTask("b", base, cand)
19 p := openInner(t, r.inst.URL, r.inst.Cookie(), 1280, 900, false, "light", "no-preference")
20 p.open("/tasks/" + id)
21 p.check(`document.querySelector('[data-spend]')===null && document.querySelector('#task-spend')!==null`, "spend before any usage")
22 q, err := r.client.Ask(r.ctx, id, "What did you change?", "", "k1")
23 if err != nil {
24 t.Fatal(err)
25 }
26 r.expect(wire.FrameAsk)
27 r.answer("b-q-run", wire.AnswerReport{TaskID: id, QuestionID: q.ID, Attempt: 1, State: wire.QuestionRunning})
28 used := []wire.Usage{{Provider: "codex", Connection: "codex-a", Model: "gpt-6-astra", Attempt: 1, Outcome: wire.OutcomeReplied, Complete: true, InputTokens: tokens(9000), CachedInputTokens: tokens(4000), OutputTokens: tokens(1000)}}
29 r.answer("b-q-done", wire.AnswerReport{TaskID: id, QuestionID: q.ID, Attempt: 1, State: wire.QuestionAnswered, Text: "I fixed the typo.", Usage: used})
30 p.wait(`document.querySelector('[data-spend]')?.textContent==='Used 10k tokens (4k cached)'`, "the total after the answer")
31 p.wait(`document.querySelector('[data-spend-step="questions"]')?.textContent==='Questions: 10k tokens (4k cached)'`, "the Questions line after the answer")
32}
33