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 "testing"
7
8 "amadan.net/oficina/equipo/internal/wire"
9)
10
11// TestBrowserDesignHandoffRenames: a task page open while Design works
12// names Design; once Design's work is handed to Engineering (its
13// specialist revoked, the recovery card answered), the open page names
14// Engineering, without a reload: the names its ask line and thread use
15// follow the refreshed thread, so a question never says Design while it
16// reaches Engineering.
17func TestBrowserDesignHandoffRenames(t *testing.T) {
18 r := newToolRigSaying(t, wire.ProtocolCurrent, overhaulWords)
19 r.designOn(rendererHealth(t, nil))
20 sp, id := r.designAdded(r.proposeDesign("d-propose"))
21 d := r.designStarted(sp, id)
22 p := openInner(t, r.inst.URL, r.inst.SessionFor(t, Owner), 1280, 900, false, "light", "reduce")
23 defer p.stop()
24 p.open("/tasks/" + id)
25 // Design's drawer, open in a second window.
26 drawer := openInner(t, r.inst.URL, r.inst.SessionFor(t, Owner), 1280, 900, false, "light", "reduce")
27 defer drawer.stop()
28 drawer.open("/tasks")
29 drawer.check(`(()=>{document.querySelector('#nav-`+sp.ID+`').click();return true})()`, "open Design's drawer")
30 drawer.wait(`document.querySelector('dialog[equipo-drawer][open] #team-title')?.textContent==='Design'`, "Design's drawer")
31 names := `document.querySelector('[data-chat-stream]').dataset.nameEngineering`
32 p.check(names+`==='Design'`, "Design's task page does not name Design")
33
34 if _, err := r.client.RevokeSpecialist(r.ctx, sp.ID, sp.Revision); err != nil {
35 t.Fatal(err)
36 }
37 r.expect(wire.FrameCancelStep)
38 r.step("hr-end", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepCancelled, Reason: "cancelled", BaseSHA: baseX, Termination: true})
39 var card wire.Card
40 r.wait("recovery card", func(c *Conversation) bool {
41 for _, k := range c.Cards {
42 if k.Kind == wire.CardMakerRemoved && k.TaskID == id && k.State == wire.CardOpen {
43 card = k
44 }
45 }
46 return card.ID != ""
47 })
48 if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceToEngineering, card.Revision); err != nil {
49 t.Fatal(err)
50 }
51 if e := r.nextDispatch(); e.TaskID != id || e.SpecialistID != "" {
52 t.Fatalf("handed to Engineering %+v", e)
53 }
54 p.wait(names+`==='Engineering'`, "the open page names Engineering")
55 p.check(`(()=>{const l=document.querySelector('[data-ask-line]');return !l || !l.textContent.includes('Design')})()`, "the ask line still says Design")
56 p.stayed("the handoff")
57 // Design is gone: its open drawer closes rather than keep an Ask form
58 // whose questions would reach Engineering.
59 drawer.wait(`!document.querySelector('dialog[equipo-drawer][open]')`, "Design's drawer to close")
60}
61