/ src / modules / Workspaces / WorkspacesEditorUITest / WorkspacesLauncherTest.cs
WorkspacesLauncherTest.cs
  1  // Copyright (c) Microsoft Corporation
  2  // The Microsoft Corporation licenses this file to you under the MIT license.
  3  // See the LICENSE file in the project root for more information.
  4  
  5  using Microsoft.PowerToys.UITest;
  6  using Microsoft.VisualStudio.TestTools.UnitTesting;
  7  
  8  namespace WorkspacesEditorUITest;
  9  
 10  [TestClass]
 11  [Ignore("NOT STABLE")]
 12  public class WorkspacesLauncherTest : WorkspacesUiAutomationBase
 13  {
 14      public WorkspacesLauncherTest()
 15          : base()
 16      {
 17      }
 18  
 19      [TestMethod("WorkspacesEditor.Launcher.LaunchFromEditor")]
 20      [TestCategory("Workspaces UI")]
 21      public void TestLaunchWorkspaceFromEditor()
 22      {
 23          ClearWorkspaces();
 24          var uuid = Guid.NewGuid().ToString("N").Substring(0, 8);
 25          CreateTestWorkspace(uuid);
 26  
 27          CloseNotepad();
 28  
 29          var launchButton = Find<Button>(By.Name("Launch"));
 30          launchButton.Click();
 31  
 32          Task.Delay(2000).Wait();
 33  
 34          var processes = System.Diagnostics.Process.GetProcessesByName("notepad");
 35  
 36          Assert.IsTrue(processes?.Length > 0);
 37      }
 38  
 39      [TestMethod("WorkspacesEditor.Launcher.CancelLaunch")]
 40      [TestCategory("Workspaces UI")]
 41      public void TestCancelLaunch()
 42      {
 43          // Create workspace with multiple apps
 44          CreateWorkspaceWithApps();
 45  
 46          // Launch workspace
 47          var workspacesList = Find<Custom>("WorkspacesList");
 48          var workspaceItem = workspacesList.FindAll<Custom>(By.ClassName("WorkspaceItem"))[0];
 49          var launchButton = workspaceItem.Find<Button>("Launch");
 50          launchButton.Click();
 51          Thread.Sleep(1000);
 52  
 53          // Cancel launch
 54          if (Has<Button>("Cancel launch"))
 55          {
 56              Find<Button>("Cancel launch").Click();
 57              Thread.Sleep(1000);
 58  
 59              // Verify launcher closed
 60              Assert.IsFalse(Has<Window>("Workspaces Launcher"), "Launcher window should close after cancel");
 61          }
 62  
 63          // Close any apps that may have launched
 64          CloseTestApplications();
 65      }
 66  
 67      [TestMethod("WorkspacesEditor.Launcher.DismissKeepsLaunching")]
 68      [TestCategory("Workspaces UI")]
 69      public void TestDismissKeepsAppsLaunching()
 70      {
 71          // Create workspace with apps
 72          CreateWorkspaceWithApps();
 73  
 74          // Launch workspace
 75          var workspacesList = Find<Custom>("WorkspacesList");
 76          var workspaceItem = workspacesList.FindAll<Custom>(By.ClassName("WorkspaceItem"))[0];
 77          var launchButton = workspaceItem.Find<Button>("Launch");
 78          launchButton.Click();
 79          Thread.Sleep(1000);
 80  
 81          // Dismiss launcher
 82          if (Has<Button>("Dismiss"))
 83          {
 84              Find<Button>("Dismiss").Click();
 85              Thread.Sleep(1000);
 86  
 87              // Verify launcher closed but apps continue launching
 88              Assert.IsFalse(Has<Window>("Workspaces Launcher"), "Launcher window should close after dismiss");
 89  
 90              // Wait for apps to finish launching
 91              Thread.Sleep(3000);
 92  
 93              // Verify apps launched (notepad should be open)
 94              Assert.IsTrue(WindowHelper.IsWindowOpen("Notepad"), "Apps should continue launching after dismiss");
 95          }
 96  
 97          // Close launched apps
 98          CloseTestApplications();
 99      }
100  }