//go:build browser package thintest import ( "testing" "amadan.net/oficina/equipo/internal/wire" ) // TestBrowserDesignHandoffRenames: a task page open while Design works // names Design; once Design's work is handed to Engineering (its // specialist revoked, the recovery card answered), the open page names // Engineering, without a reload: the names its ask line and thread use // follow the refreshed thread, so a question never says Design while it // reaches Engineering. func TestBrowserDesignHandoffRenames(t *testing.T) { r := newToolRigSaying(t, wire.ProtocolCurrent, overhaulWords) r.designOn(rendererHealth(t, nil)) sp, id := r.designAdded(r.proposeDesign("d-propose")) d := r.designStarted(sp, id) p := openInner(t, r.inst.URL, r.inst.SessionFor(t, Owner), 1280, 900, false, "light", "reduce") defer p.stop() p.open("/tasks/" + id) // Design's drawer, open in a second window. drawer := openInner(t, r.inst.URL, r.inst.SessionFor(t, Owner), 1280, 900, false, "light", "reduce") defer drawer.stop() drawer.open("/tasks") drawer.check(`(()=>{document.querySelector('#nav-`+sp.ID+`').click();return true})()`, "open Design's drawer") drawer.wait(`document.querySelector('dialog[equipo-drawer][open] #team-title')?.textContent==='Design'`, "Design's drawer") names := `document.querySelector('[data-chat-stream]').dataset.nameEngineering` p.check(names+`==='Design'`, "Design's task page does not name Design") if _, err := r.client.RevokeSpecialist(r.ctx, sp.ID, sp.Revision); err != nil { t.Fatal(err) } r.expect(wire.FrameCancelStep) r.step("hr-end", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepCancelled, Reason: "cancelled", BaseSHA: baseX, Termination: true}) var card wire.Card r.wait("recovery card", func(c *Conversation) bool { for _, k := range c.Cards { if k.Kind == wire.CardMakerRemoved && k.TaskID == id && k.State == wire.CardOpen { card = k } } return card.ID != "" }) if _, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceToEngineering, card.Revision); err != nil { t.Fatal(err) } if e := r.nextDispatch(); e.TaskID != id || e.SpecialistID != "" { t.Fatalf("handed to Engineering %+v", e) } p.wait(names+`==='Engineering'`, "the open page names Engineering") p.check(`(()=>{const l=document.querySelector('[data-ask-line]');return !l || !l.textContent.includes('Design')})()`, "the ask line still says Design") p.stayed("the handoff") // Design is gone: its open drawer closes rather than keep an Ask form // whose questions would reach Engineering. drawer.wait(`!document.querySelector('dialog[equipo-drawer][open]')`, "Design's drawer to close") }