diff --git a/src/Cody.VisualStudio.Tests/ChatLoggedBasicTests.cs b/src/Cody.VisualStudio.Tests/ChatLoggedBasicTests.cs index 5a9dc1fd..f9775d07 100644 --- a/src/Cody.VisualStudio.Tests/ChatLoggedBasicTests.cs +++ b/src/Cody.VisualStudio.Tests/ChatLoggedBasicTests.cs @@ -31,6 +31,8 @@ public async Task Active_File_Name_And_Line_Selection_Is_Showing_In_Chat_Input() { // given await WaitForPlaywrightAsync(); + await NewChat(); + await OpenSolution(SolutionsPaths.GetConsoleApp1File("ConsoleApp1.sln")); // when @@ -46,6 +48,28 @@ public async Task Active_File_Name_And_Line_Selection_Is_Showing_In_Chat_Input() Assert.Equal(endLine, secondTag.EndLine); } + [VsFact(Version = VsVersion.VS2022)] + public async Task Active_File_Match_Current_Chat_Context() + { + // given + await WaitForPlaywrightAsync(); + await NewChat(); + + await OpenSolution(SolutionsPaths.GetConsoleApp1File("ConsoleApp1.sln")); + + // when + const int startLine = 2; const int endLine = 3; + await OpenDocument(SolutionsPaths.GetConsoleApp1File(@"ConsoleApp1\Program.cs"), startLine, endLine); + var tags = await GetChatContextTags(); + + // then + var firstTagName = tags.First().Name; + var secondTag = tags.ElementAt(1); + Assert.Equal("Program.cs", firstTagName); + Assert.Equal(startLine, secondTag.StartLine); + Assert.Equal(endLine, secondTag.EndLine); + } + [VsFact(Version = VsVersion.VS2022)] public async Task Can_Chat_Tool_Window_Be_Closed_And_Opened_Again() { @@ -60,7 +84,7 @@ public async Task Can_Chat_Tool_Window_Be_Closed_And_Opened_Again() Assert.True(isOpen); } - //[VsFact(Version = VsVersion.VS2022)] + [VsFact(Version = VsVersion.VS2022)] public async Task Entered_Prompt_Show_Up_In_Today_History() { var num = new Random().Next(); @@ -69,14 +93,11 @@ public async Task Entered_Prompt_Show_Up_In_Today_History() await WaitForPlaywrightAsync(); await EnterChatTextAndSend(prompt); - await CloseCodyChatToolWindow(); - await OpenCodyChatToolWindow(); await ShowHistoryTab(); var chatHistoryEntries = await GetTodayChatHistory(); Assert.Contains(chatHistoryEntries, x => x.Contains(prompt)); - } public void Dispose() diff --git a/src/Cody.VisualStudio.Tests/PlaywrightTestsBase.cs b/src/Cody.VisualStudio.Tests/PlaywrightTestsBase.cs index ee82108a..2652e5d2 100644 --- a/src/Cody.VisualStudio.Tests/PlaywrightTestsBase.cs +++ b/src/Cody.VisualStudio.Tests/PlaywrightTestsBase.cs @@ -142,7 +142,18 @@ protected async Task AssertTextIsPresent(string text) Assert.Equal(text, textContents.First()); } - protected async Task ShowChatTab() => await Page.GetByTestId("tab-chat").ClickAsync(); + protected async Task ShowChatTab() + { + await Page.GetByTestId("tab-chat").ClickAsync(); + await Task.Delay(500); + } + + protected async Task NewChat() + { + await Page.GetByRole(AriaRole.Button, new PageGetByRoleOptions {Name = "New Chat"}).ClickAsync(); + + await Task.Delay(500); + } protected async Task ShowHistoryTab() { @@ -158,15 +169,21 @@ protected async Task ShowHistoryTab() protected async Task EnterChatTextAndSend(string prompt) { - var entryArea = Page.Locator("[data-keep-toolbar-open=true]").Last; - - await entryArea.PressSequentiallyAsync(prompt); - await entryArea.PressAsync("Enter"); + var entryArea = Page.Locator("span[data-lexical-text='true']"); + var enterArea = Page.Locator("[data-keep-toolbar-open=true]").Last; - var button = await Page.WaitForSelectorAsync("menu button[type=submit][title=Stop]"); + await entryArea.FillAsync(prompt); + await enterArea.PressAsync("Enter"); - while (await button.GetAttributeAsync("title") == "Stop") await Task.Delay(500); + var isStopVisible = false; + while (!isStopVisible) + { + isStopVisible = await Page.Locator("vscode-button").First.IsVisibleAsync(); + await Task.Delay(500); + } await Task.Delay(500); + + await DismissStartWindow(); } protected async Task GetTodayChatHistory() @@ -182,6 +199,7 @@ protected async Task GetTodayChatHistory() protected async Task> GetChatContextTags() { var tagsList = new List(); + await ShowChatTab(); WriteLog("Searching for Chat ..."); var chatBox = await Page.QuerySelectorAsync("[aria-label='Chat message']"); diff --git a/src/Cody.VisualStudio/Services/ThemeService.cs b/src/Cody.VisualStudio/Services/ThemeService.cs index 2312e47e..1a7a9bef 100644 --- a/src/Cody.VisualStudio/Services/ThemeService.cs +++ b/src/Cody.VisualStudio/Services/ThemeService.cs @@ -130,10 +130,14 @@ public string GetThemingScript() // Generate the CSS variables for the fonts. var editorFont = GetEditorFont(); + _logger.Debug($"Detected editor font:{editorFont.FontName} size:{editorFont.Size}"); + sb.AppendLine($"rootStyle.setProperty('--visualstudio-editor-font-family', '{editorFont.FontName}');"); sb.AppendLine($"rootStyle.setProperty('--visualstudio-editor-font-size', '{editorFont.Size}pt');"); var uiFont = GetUIFont(); + _logger.Debug($"Detected UI font:{uiFont.FontName} size:{uiFont.Size}"); + sb.AppendLine($"rootStyle.setProperty('--visualstudio-ui-font-family', '{uiFont.FontName}');"); sb.AppendLine($"rootStyle.setProperty('--visualstudio-ui-font-size', '{uiFont.Size}pt');");