MCPcopy Index your code
hub / github.com/github/copilot-sdk / TestSession_Capabilities

Function TestSession_Capabilities

go/session_test.go:697–912  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

695}
696
697func TestSession_Capabilities(t *testing.T) {
698 t.Run("defaults capabilities when not injected", func(t *testing.T) {
699 session, cleanup := newTestSession()
700 defer cleanup()
701
702 caps := session.Capabilities()
703 if caps.UI != nil {
704 t.Errorf("Expected UI to be nil by default, got %+v", caps.UI)
705 }
706 })
707
708 t.Run("setCapabilities stores and retrieves capabilities", func(t *testing.T) {
709 session, cleanup := newTestSession()
710 defer cleanup()
711
712 session.setCapabilities(&SessionCapabilities{
713 UI: &UICapabilities{Elicitation: true},
714 })
715 caps := session.Capabilities()
716 if caps.UI == nil || !caps.UI.Elicitation {
717 t.Errorf("Expected UI.Elicitation to be true")
718 }
719 })
720
721 t.Run("setCapabilities with nil resets to empty", func(t *testing.T) {
722 session, cleanup := newTestSession()
723 defer cleanup()
724
725 session.setCapabilities(&SessionCapabilities{
726 UI: &UICapabilities{Elicitation: true},
727 })
728 session.setCapabilities(nil)
729 caps := session.Capabilities()
730 if caps.UI != nil {
731 t.Errorf("Expected UI to be nil after reset, got %+v", caps.UI)
732 }
733 })
734
735 t.Run("capabilities.changed event updates session capabilities", func(t *testing.T) {
736 session, cleanup := newTestSession()
737 defer cleanup()
738
739 // Initially no capabilities
740 caps := session.Capabilities()
741 if caps.UI != nil {
742 t.Fatal("Expected UI to be nil initially")
743 }
744
745 // Dispatch a capabilities.changed event with elicitation=true
746 elicitTrue := true
747 session.dispatchEvent(SessionEvent{
748 Data: &CapabilitiesChangedData{
749 UI: &CapabilitiesChangedUI{Elicitation: &elicitTrue},
750 },
751 })
752
753 // Capabilities are updated by handleBroadcastEvent which runs in a goroutine.
754 // Poll instead of sleep so the test is bound by event processing, not arbitrary

Callers

nothing calls this directly

Calls 8

newTestSessionFunction · 0.85
waitForCapabilityFunction · 0.85
ptrFunction · 0.85
CapabilitiesMethod · 0.80
OpenCanvasesMethod · 0.80
setCapabilitiesMethod · 0.45
dispatchEventMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…