From b14b28bb62a3ce1cc93d2ca86632e72bc4e563ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 18:41:57 +0000 Subject: [PATCH 1/3] Initial plan From 49a67037d7f7283e9d6cc81d4e9b711e3b80b3e3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 18:56:22 +0000 Subject: [PATCH 2/3] Implement startup argument support for Catalyst Test Runner Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com> --- .../tests/TestCases.HostApp/MauiProgram.cs | 18 +++++++++++++++ .../Tests/Issues/_IssuesUITest.cs | 23 +++++++++++++++++++ .../src/UITest.Appium/AppiumCatalystApp.cs | 6 +++++ 3 files changed, 47 insertions(+) diff --git a/src/Controls/tests/TestCases.HostApp/MauiProgram.cs b/src/Controls/tests/TestCases.HostApp/MauiProgram.cs index 479a765a29cb..fe95d305041b 100644 --- a/src/Controls/tests/TestCases.HostApp/MauiProgram.cs +++ b/src/Controls/tests/TestCases.HostApp/MauiProgram.cs @@ -64,6 +64,23 @@ public static Page CreateDefaultMainPage() { Page mainPage = null; OverrideMainPage(ref mainPage); + + // Check for startup test argument from environment variables (passed by test runner) + var testName = System.Environment.GetEnvironmentVariable("test"); + if (!string.IsNullOrEmpty(testName)) + { + App.StartupTestName = testName; + + // Try to navigate directly to the test + var testCaseScreen = new TestCases.TestCaseScreen(); + if (testCaseScreen.TryToNavigateTo(testName)) + { + // If navigation succeeded, the page was already set by the action + // Return a dummy page that will be replaced + return new ContentPage { Title = "Loading Test..." }; + } + } + return mainPage ?? new CoreNavigationPage(); } } @@ -78,6 +95,7 @@ public App() } public static bool PreloadTestCasesIssuesList { get; set; } = true; + public static string StartupTestName { get; set; } protected override void OnAppLinkRequestReceived(Uri uri) { diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs index 22c67e8e7d2e..f9cb74b85aa8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs @@ -17,8 +17,24 @@ public abstract class _IssuesUITest : UITest protected const string BackButtonAutomationId = "Navigate up"; #endif +#if MACCATALYST + protected override bool ResetAfterEachTest => true; +#endif + public _IssuesUITest(TestDevice device) : base(device) { } + public override IConfig GetTestConfig() + { + var config = base.GetTestConfig(); + +#if MACCATALYST + // For Catalyst, pass the test name as a startup argument + config.SetTestConfigurationArg("test", Issue); +#endif + + return config; + } + protected override void FixtureSetup() { int retries = 0; @@ -30,7 +46,14 @@ protected override void FixtureSetup() #if ANDROID || MACCATALYST App.ToggleSystemAnimations(false); #endif +#if !MACCATALYST + // For non-Catalyst platforms, navigate via UI NavigateToIssue(Issue); +#else + // For Catalyst, navigation is handled via startup arguments + // Just wait for the test to load + App.WaitForElement("*", timeout: TimeSpan.FromSeconds(10)); +#endif break; } catch (Exception e) diff --git a/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs b/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs index c6552ab90975..bdb4096c246b 100644 --- a/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs +++ b/src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs @@ -65,6 +65,12 @@ private static AppiumOptions GetOptions(IConfig config) options.AddAdditionalAppiumOption(IOSMobileCapabilityType.BundleId, appId); } + var args = config.GetProperty>("TestConfigurationArgs"); + options.AddAdditionalAppiumOption(IOSMobileCapabilityType.ProcessArguments, new Dictionary + { + { "env", args! } + }); + options.AddAdditionalAppiumOption("showServerLogs", true); return options; } From 55b0b9184f80710b3c7979e658a9ac7973d080c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 19:01:54 +0000 Subject: [PATCH 3/3] Apply code formatting fixes --- src/Controls/tests/TestCases.HostApp/MauiProgram.cs | 6 +++--- .../TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/MauiProgram.cs b/src/Controls/tests/TestCases.HostApp/MauiProgram.cs index fe95d305041b..b490a3bb69de 100644 --- a/src/Controls/tests/TestCases.HostApp/MauiProgram.cs +++ b/src/Controls/tests/TestCases.HostApp/MauiProgram.cs @@ -64,13 +64,13 @@ public static Page CreateDefaultMainPage() { Page mainPage = null; OverrideMainPage(ref mainPage); - + // Check for startup test argument from environment variables (passed by test runner) var testName = System.Environment.GetEnvironmentVariable("test"); if (!string.IsNullOrEmpty(testName)) { App.StartupTestName = testName; - + // Try to navigate directly to the test var testCaseScreen = new TestCases.TestCaseScreen(); if (testCaseScreen.TryToNavigateTo(testName)) @@ -80,7 +80,7 @@ public static Page CreateDefaultMainPage() return new ContentPage { Title = "Loading Test..." }; } } - + return mainPage ?? new CoreNavigationPage(); } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs index f9cb74b85aa8..b4cdf62a2b6f 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/_IssuesUITest.cs @@ -26,12 +26,12 @@ public _IssuesUITest(TestDevice device) : base(device) { } public override IConfig GetTestConfig() { var config = base.GetTestConfig(); - + #if MACCATALYST // For Catalyst, pass the test name as a startup argument config.SetTestConfigurationArg("test", Issue); #endif - + return config; }