From 7bb7d928a4838174757cb54ce172deaa89fda7a4 Mon Sep 17 00:00:00 2001 From: Jaylyn Barbee <51131738+Jaylyn-Barbee@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:07:23 -0500 Subject: [PATCH] UI Tests --- .../Tests/LightSwitch.UITests/TestHelper.cs | 40 +++++++++++-------- .../SettingsXAML/Views/LightSwitchPage.xaml | 30 +++++++------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/modules/LightSwitch/Tests/LightSwitch.UITests/TestHelper.cs b/src/modules/LightSwitch/Tests/LightSwitch.UITests/TestHelper.cs index 7b586301f6..37041b4b2d 100644 --- a/src/modules/LightSwitch/Tests/LightSwitch.UITests/TestHelper.cs +++ b/src/modules/LightSwitch/Tests/LightSwitch.UITests/TestHelper.cs @@ -152,16 +152,16 @@ namespace LightSwitch.UITests var neededTabs = 6; - if (modeCombobox.Text != "Manual") + if (modeCombobox.Text != "Fixed hours") { modeCombobox.Click(); var manualListItem = testBase.Session.Find(By.AccessibilityId("ManualCBItem_LightSwitch"), 5000); - Assert.IsNotNull(manualListItem, "Manual combobox item not found."); + Assert.IsNotNull(manualListItem, "Fixed Hours combobox item not found."); manualListItem.Click(); neededTabs = 1; } - Assert.AreEqual("Manual", modeCombobox.Text, "Mode combobox should be set to Manual."); + Assert.AreEqual("Fixed hours", modeCombobox.Text, "Mode combobox should be set to Fixed hours."); var timeline = testBase.Session.Find(By.AccessibilityId("Timeline_LightSwitch"), 5000); Assert.IsNotNull(timeline, "Timeline not found."); @@ -198,7 +198,7 @@ namespace LightSwitch.UITests } /// - /// Perform a update geolocation test operation + /// Perform a update manual location test operation /// public static void PerformUserSelectedLocationTest(UITestBase testBase) { @@ -216,19 +216,22 @@ namespace LightSwitch.UITests Assert.AreEqual("Sunset to sunrise", modeCombobox.Text, "Mode combobox should be set to Sunset to sunrise."); + // Click the select location button var setLocationButton = testBase.Session.Find(By.AccessibilityId("SetLocationButton_LightSwitch"), 5000); Assert.IsNotNull(setLocationButton, "Set location button not found."); - setLocationButton.Click(); + setLocationButton.Click(msPostAction: 1000); - var autoSuggestTextbox = testBase.Session.Find(By.AccessibilityId("CitySearchBox_LightSwitch"), 5000); - Assert.IsNotNull(autoSuggestTextbox, "City search box not found."); - autoSuggestTextbox.Click(); - autoSuggestTextbox.SendKeys("Seattle"); - autoSuggestTextbox.SendKeys(OpenQA.Selenium.Keys.Down); - autoSuggestTextbox.SendKeys(OpenQA.Selenium.Keys.Enter); + var latitudeBox = testBase.Session.Find(By.AccessibilityId("LatitudeBox_LightSwitch"), 5000); + Assert.IsNotNull(latitudeBox, "Latitude text box not found."); + latitudeBox.Click(); - var latLong = testBase.Session.Find(By.AccessibilityId("LocationResultText_LightSwitch"), 5000); - Assert.IsFalse(string.IsNullOrWhiteSpace(latLong.Text)); + testBase.Session.SendKeys(Key.Up); + + var longitudeBox = testBase.Session.Find(By.AccessibilityId("LongitudeBox_LightSwitch"), 5000); + Assert.IsNotNull(longitudeBox, "Longitude text box not found."); + longitudeBox.Click(); + + testBase.Session.SendKeys(Key.Down); var sunrise = testBase.Session.Find(By.AccessibilityId("SunriseText_LightSwitch"), 5000); Assert.IsFalse(string.IsNullOrWhiteSpace(sunrise.Text)); @@ -256,13 +259,14 @@ namespace LightSwitch.UITests Assert.AreEqual("Sunset to sunrise", modeCombobox.Text, "Mode combobox should be set to Sunset to sunrise."); - // Click the select city button + // Click the select location button var setLocationButton = testBase.Session.Find(By.AccessibilityId("SetLocationButton_LightSwitch"), 5000); Assert.IsNotNull(setLocationButton, "Set location button not found."); - setLocationButton.Click(msPostAction: 8000); + setLocationButton.Click(msPostAction: 1000); - var latLong = testBase.Session.Find(By.AccessibilityId("LocationResultText_LightSwitch"), 5000); - Assert.IsFalse(string.IsNullOrWhiteSpace(latLong.Text)); + var syncLocationButton = testBase.Session.Find(By.AccessibilityId("SyncLocationButton_LightSwitch"), 5000); + Assert.IsNotNull(syncLocationButton, "Sync location button not found."); + syncLocationButton.Click(msPostAction: 8000); var sunrise = testBase.Session.Find(By.AccessibilityId("SunriseText_LightSwitch"), 5000); Assert.IsFalse(string.IsNullOrWhiteSpace(sunrise.Text)); @@ -363,6 +367,7 @@ namespace LightSwitch.UITests var systemBeforeValue = GetSystemTheme(); var appsBeforeValue = GetAppsTheme(); + Task.Delay(1000).Wait(); testBase.Session.SendKeys(activationKeys); Task.Delay(5000).Wait(); @@ -389,6 +394,7 @@ namespace LightSwitch.UITests var noneSystemBeforeValue = GetSystemTheme(); var noneAppsBeforeValue = GetAppsTheme(); + Task.Delay(1000).Wait(); testBase.Session.SendKeys(activationKeys); Task.Delay(5000).Wait(); diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml index 079afab2e7..2b0544c241 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml @@ -1,21 +1,21 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls" + xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="using:Microsoft.PowerToys.Settings.UI.Helpers" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls" + xmlns:ui="using:CommunityToolkit.WinUI" + xmlns:viewModels="using:Microsoft.PowerToys.Settings.UI.ViewModels" + d:DataContext="{d:DesignInstance Type=viewModels:LightSwitchViewModel}" + AutomationProperties.LandmarkType="Main" + mc:Ignorable="d"> - + @@ -255,6 +255,7 @@ mc:Ignorable="d"> x:Name="LongitudeBox" x:Uid="LightSwitch_LongitudeBox" Grid.Column="1" + AutomationProperties.AutomationId="LongitudeBox_LightSwitch" Maximum="180" Minimum="-180" ValueChanged="LatLonBox_ValueChanged"