(t *testing.T)
| 695 | } |
| 696 | |
| 697 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…