| 1 | using CascadeIDE.Features.Chat; |
| 2 | using CascadeIDE.Models.Intercom; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public sealed class MessageAnchorSlashCompletionProviderTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void GetMatches_returns_ordinals_for_selected_message_anchors() |
| 11 | { |
| 12 | var provider = new MessageAnchorSlashCompletionProvider(() => |
| 13 | [ |
| 14 | new AttachmentAnchor { Id = "abcd1234", DisplayLabel = "Foo" }, |
| 15 | new AttachmentAnchor { Id = "ef005678", DisplayLabel = "Bar" }, |
| 16 | ]); |
| 17 | |
| 18 | var matches = provider.GetMatches("", limit: 10); |
| 19 | Assert.Equal(2, matches.Count); |
| 20 | Assert.Equal("1", matches[0].InsertArg); |
| 21 | Assert.Contains("Foo", matches[0].Label, StringComparison.Ordinal); |
| 22 | Assert.Equal("2", matches[1].InsertArg); |
| 23 | } |
| 24 | |
| 25 | [Fact] |
| 26 | public void Autocomplete_anchor_peek_offers_ordinals_after_message_select() |
| 27 | { |
| 28 | var provider = new MessageAnchorSlashCompletionProvider(() => |
| 29 | [ |
| 30 | new AttachmentAnchor { Id = "abcd1234", DisplayLabel = "Method" }, |
| 31 | ]); |
| 32 | |
| 33 | var suggestions = ChatSlashAutocomplete.GetSuggestions( |
| 34 | "/anchor peek ", |
| 35 | messageAnchors: provider); |
| 36 | |
| 37 | Assert.Single(suggestions); |
| 38 | Assert.Equal("/anchor peek 1", suggestions[0].InsertText); |
| 39 | } |
| 40 | } |
| 41 | |