fix cmdpal uitest

This commit is contained in:
Leilei Zhang
2025-08-21 17:25:35 +08:00
parent 44d34e45c0
commit add49a59ad
4 changed files with 14 additions and 17 deletions

View File

@@ -165,6 +165,7 @@
x:Name="PrimaryButton" x:Name="PrimaryButton"
Padding="6,4,4,4" Padding="6,4,4,4"
x:Load="{x:Bind IsLoaded, Mode=OneWay}" x:Load="{x:Bind IsLoaded, Mode=OneWay}"
AutomationProperties.AutomationId="PrimaryCommandButton"
AutomationProperties.Name="{x:Bind ViewModel.PrimaryCommand.Name, Mode=OneWay}" AutomationProperties.Name="{x:Bind ViewModel.PrimaryCommand.Name, Mode=OneWay}"
Background="Transparent" Background="Transparent"
Click="PrimaryButton_Clicked" Click="PrimaryButton_Clicked"
@@ -184,6 +185,7 @@
x:Name="SecondaryButton" x:Name="SecondaryButton"
Padding="6,4,4,4" Padding="6,4,4,4"
x:Load="{x:Bind IsLoaded, Mode=OneWay}" x:Load="{x:Bind IsLoaded, Mode=OneWay}"
AutomationProperties.AutomationId="SecondaryCommandButton"
AutomationProperties.Name="{x:Bind ViewModel.SecondaryCommand.Name, Mode=OneWay}" AutomationProperties.Name="{x:Bind ViewModel.SecondaryCommand.Name, Mode=OneWay}"
Click="SecondaryButton_Clicked" Click="SecondaryButton_Clicked"
Style="{StaticResource SubtleButtonStyle}" Style="{StaticResource SubtleButtonStyle}"
@@ -207,6 +209,7 @@
x:Name="MoreCommandsButton" x:Name="MoreCommandsButton"
x:Uid="MoreCommandsButton" x:Uid="MoreCommandsButton"
Padding="6,4,4,4" Padding="6,4,4,4"
AutomationProperties.AutomationId="MoreContextMenuButton"
Click="MoreCommandsButton_Clicked" Click="MoreCommandsButton_Clicked"
Style="{StaticResource SubtleButtonStyle}" Style="{StaticResource SubtleButtonStyle}"
ToolTipService.ToolTip="Ctrl+K" ToolTipService.ToolTip="Ctrl+K"

View File

@@ -22,6 +22,7 @@
MinHeight="32" MinHeight="32"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutomationProperties.AutomationId="MainSearchBox"
KeyDown="FilterBox_KeyDown" KeyDown="FilterBox_KeyDown"
PlaceholderText="{x:Bind CurrentPageViewModel.PlaceholderText, Converter={StaticResource PlaceholderTextConverter}, Mode=OneWay}" PlaceholderText="{x:Bind CurrentPageViewModel.PlaceholderText, Converter={StaticResource PlaceholderTextConverter}, Mode=OneWay}"
PreviewKeyDown="FilterBox_PreviewKeyDown" PreviewKeyDown="FilterBox_PreviewKeyDown"

View File

@@ -19,29 +19,22 @@ public class CommandPaletteTestBase : UITestBase
{ {
} }
protected void SetSearchBox(string text) protected void SetSearchBox(string text) => SetSearchBoxText(text);
{
Assert.AreEqual(this.Find<TextBox>("Type here to search...").SetText(text, true).Text, text);
}
protected void SetFilesExtensionSearchBox(string text) protected void SetFilesExtensionSearchBox(string text) => SetSearchBoxText(text);
{
Assert.AreEqual(this.Find<TextBox>("Search for files and folders...").SetText(text, true).Text, text);
}
protected void SetCalculatorExtensionSearchBox(string text) protected void SetCalculatorExtensionSearchBox(string text) => SetSearchBoxText(text);
{
Assert.AreEqual(this.Find<TextBox>("Type an equation...").SetText(text, true).Text, text);
}
protected void SetTimeAndDaterExtensionSearchBox(string text) protected void SetTimeAndDaterExtensionSearchBox(string text) => SetSearchBoxText(text);
private void SetSearchBoxText(string text)
{ {
Assert.AreEqual(this.Find<TextBox>("Search values or type a custom time stamp...").SetText(text, true).Text, text); Assert.AreEqual(this.Find<TextBox>(By.AccessibilityId("MainSearchBox")).SetText(text, true).Text, text);
} }
protected void OpenContextMenu() protected void OpenContextMenu()
{ {
var contextMenuButton = this.Find<Button>("More"); var contextMenuButton = this.Find<Button>(By.AccessibilityId("MoreContextMenuButton"));
Assert.IsNotNull(contextMenuButton, "Context menu button not found."); Assert.IsNotNull(contextMenuButton, "Context menu button not found.");
contextMenuButton.Click(); contextMenuButton.Click();
} }

View File

@@ -69,7 +69,7 @@ public class IndexerTests : CommandPaletteTestBase
searchItem.Click(); searchItem.Click();
var openButton = this.Find<Button>("Open with"); var openButton = this.Find<Button>(By.AccessibilityId("PrimaryCommandButton"));
Assert.IsNotNull(openButton); Assert.IsNotNull(openButton);
openButton.Click(); openButton.Click();
@@ -144,7 +144,7 @@ public class IndexerTests : CommandPaletteTestBase
Assert.IsNotNull(searchItem); Assert.IsNotNull(searchItem);
searchItem.Click(); searchItem.Click();
var openButton = this.Find<Button>("Browse"); var openButton = this.Find<Button>(By.AccessibilityId("SecondaryCommandButton"));
Assert.IsNotNull(openButton); Assert.IsNotNull(openButton);
openButton.Click(); openButton.Click();