Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Controls/tests/TestCases.HostApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ private static AppiumOptions GetOptions(IConfig config)
options.AddAdditionalAppiumOption(IOSMobileCapabilityType.BundleId, appId);
}

var args = config.GetProperty<Dictionary<string, string>>("TestConfigurationArgs");
options.AddAdditionalAppiumOption(IOSMobileCapabilityType.ProcessArguments, new Dictionary<string, object>
{
{ "env", args! }
});

options.AddAdditionalAppiumOption("showServerLogs", true);
return options;
}
Expand Down