Skip to content

Commit

Permalink
[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 23 (
Browse files Browse the repository at this point in the history
…#26219)

* Enabled Shell Flyout Behavior UITests from XamarinUITest to Appium (#21)

* Migrate issue FlyoutBehaviourShell

* Updated migrated test cases

* Updated the comments

---------

Co-authored-by: NafeelaNazhir <[email protected]>

* Addressed the review changes

* Resolved build error

* Update HelperExtensions.cs

---------

Co-authored-by: NafeelaNazhir <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
  • Loading branch information
3 people authored Dec 5, 2024
1 parent b03cb7e commit afc0e2f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,90 @@
namespace Microsoft.Maui.TestCases.Tests.Issues;
public class FlyoutBehaviorShell : _IssuesUITest
{
const string title = "Basic Test";
const string FlyoutItem = "Flyout Item";
const string EnableFlyoutBehavior = "EnableFlyoutBehavior";
const string DisableFlyoutBehavior = "DisableFlyoutBehavior";
const string LockFlyoutBehavior = "LockFlyoutBehavior";
const string OpenFlyout = "OpenFlyout";
const string EnableBackButtonBehavior = "EnableBackButtonBehavior";
const string DisableBackButtonBehavior = "DisableBackButtonBehavior";
public FlyoutBehaviorShell(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Shell Flyout Behavior";

// [FailsOnAndroidWhenRunningOnXamarinUITest]
// [Test]
// [Category(UITestCategories.Shell)]
// public void FlyoutTests()
// {
// // Flyout is visible
// App.WaitForElement(EnableFlyoutBehavior);

// // Starting shell out as disabled correctly disables flyout
// App.WaitForNoElement(FlyoutIconAutomationId, "Flyout Icon Visible on Startup");
// ShowFlyout(usingSwipe: true, testForFlyoutIcon: false);
// App.WaitForNoElement(FlyoutItem, "Flyout Visible on Startup");

// // Enable Flyout Test
// App.Tap(EnableFlyoutBehavior);
// ShowFlyout(usingSwipe: true);
// App.WaitForElement(FlyoutItem, "Flyout Not Visible after Enabled");
// App.Tap(FlyoutItem);
[Test]
[Category(UITestCategories.Shell)]
public void FlyoutTests()
{
// Flyout is visible
App.WaitForElement(EnableFlyoutBehavior);
#if !MACCATALYST && !WINDOWS //Swipe Options for Shell are not applicable for Desktop Platforms.
// Starting shell out as disabled correctly disables flyout
App.WaitForNoElement(FlyoutIconAutomationId, "Flyout Icon Visible on Startup");
App.ShowFlyout(usingSwipe: true, waitForFlyoutIcon: false);
App.WaitForNoElement(FlyoutItem, "Flyout Visible on Startup");

// // Flyout Icon is not visible but you can still swipe open
// App.Tap(DisableFlyoutBehavior);
// App.WaitForNoElement(FlyoutIconAutomationId, "Flyout Icon Visible after being Disabled");
// ShowFlyout(usingSwipe: true, testForFlyoutIcon: false);
// App.WaitForNoElement(FlyoutItem, "Flyout Visible after being Disabled");
// Enable Flyout Test
App.Tap(EnableFlyoutBehavior);
App.ShowFlyout(usingSwipe: true);
App.WaitForElement(FlyoutItem, "Flyout Not Visible after Enabled");
App.Tap(FlyoutItem);

// Flyout Icon is not visible but you can still swipe open
App.Tap(DisableFlyoutBehavior);
App.WaitForNoElement(FlyoutIconAutomationId, "Flyout Icon Visible after being Disabled");
App.ShowFlyout(usingSwipe: true, waitForFlyoutIcon: false);
App.WaitForNoElement(FlyoutItem, "Flyout Visible after being Disabled");

// // enable flyout and make sure disabling back button behavior doesn't hide icon
// App.Tap(EnableFlyoutBehavior);
// App.WaitForElement(FlyoutIconAutomationId);
// App.Tap(DisableBackButtonBehavior);
// ShowFlyout(usingSwipe: true);
// App.WaitForElement(FlyoutItem, "Flyout swipe not working after Disabling Back Button Behavior");
// App.Tap(FlyoutItem);

// // make sure you can still open flyout via code
// App.Tap(EnableFlyoutBehavior);
// App.Tap(EnableBackButtonBehavior);
// App.Tap(OpenFlyout);
// App.WaitForElement(FlyoutItem, "Flyout not opening via code");
// App.Tap(FlyoutItem);
// enable flyout and make sure disabling back button behavior doesn't hide icon
App.Tap(EnableFlyoutBehavior);
App.WaitForFlyoutIcon();
App.Tap(DisableBackButtonBehavior);
App.ShowFlyout(usingSwipe: true);
App.WaitForElement(FlyoutItem, "Flyout swipe not working after Disabling Back Button Behavior");
App.Tap(FlyoutItem);
#endif
// // make sure you can still open flyout via code
App.Tap(EnableFlyoutBehavior);
App.Tap(EnableBackButtonBehavior);
App.Tap(OpenFlyout);
App.WaitForElement(FlyoutItem, "Flyout not opening via code");
App.Tap(FlyoutItem);

// // make sure you can still open flyout via code if flyout behavior is disabled
// App.Tap(DisableFlyoutBehavior);
// App.Tap(EnableBackButtonBehavior);
// App.Tap(OpenFlyout);
// App.WaitForElement(FlyoutItem, "Flyout not opening via code when flyout behavior disabled");
// App.Tap(FlyoutItem);
#if !IOS && !MACCATALYST // When DisableFlyoutBehavior is set, flyout items become inaccessible via inspection tools, leading to timeout exceptions on both iOS and Catalyst.

// make sure you can still open flyout via code if flyout behavior is disabled
App.Tap(DisableFlyoutBehavior);
App.Tap(EnableBackButtonBehavior);
App.Tap(OpenFlyout);
App.WaitForElement(FlyoutItem, "Flyout not opening via code when flyout behavior disabled");
App.Tap(FlyoutItem);
#endif

// // make sure you can still open flyout via code if back button behavior is disabled
// App.Tap(EnableFlyoutBehavior);
// App.Tap(DisableBackButtonBehavior);
// App.Tap(OpenFlyout);
// App.WaitForElement(FlyoutItem, "Flyout not opening via code when back button behavior is disabled");
// App.Tap(FlyoutItem);
// make sure you can still open flyout via code if back button behavior is disabled
App.Tap(EnableFlyoutBehavior);
App.Tap(DisableBackButtonBehavior);
App.Tap(OpenFlyout);
App.WaitForElement(FlyoutItem, "Flyout not opening via code when back button behavior is disabled");
App.Tap(FlyoutItem);

// }
}

// [Test]
// public void WhenFlyoutIsLockedButtonsAreStillVisible()
// {
// // FlyoutLocked ensure that the flyout and buttons are still visible
// App.Tap(EnableBackButtonBehavior);
// App.Tap(LockFlyoutBehavior);
// App.WaitForElement(title, "Flyout Locked hiding content");
// App.Tap(EnableFlyoutBehavior);
// App.WaitForNoElement(FlyoutItem);
// }
[Test]
[Category(UITestCategories.Shell)]
public void WhenFlyoutIsLockedButtonsAreStillVisible()
{
// FlyoutLocked ensure that the flyout and buttons are still visible
App.WaitForElement(EnableBackButtonBehavior);
App.Tap(EnableBackButtonBehavior);
App.Tap(LockFlyoutBehavior);
App.WaitForElement(title,"Flyout Locked hiding content");
App.Tap(EnableFlyoutBehavior);
App.WaitForNoElement(FlyoutItem);
}
}
1 change: 1 addition & 0 deletions src/TestUtils/src/UITest.Appium/HelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,7 @@ public static void TapInFlyoutPageFlyout(this IApp app, string flyoutItem)
app.TapInFlyout(flyoutItem, false);
}

/// <summary>
/// Taps the "More" button in the app, with platform-specific logic for Android and Windows.
/// This method does not currently support iOS and macOS platforms, where the "More" button is not shown.
/// </summary>
Expand Down

0 comments on commit afc0e2f

Please sign in to comment.