Migrate UI tests to Playwright dotta
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using JdeScoping.Ui.Tests.Helpers;
|
||||
using JdeScoping.Ui.Tests.Support;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace JdeScoping.Ui.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Playwright UI tests for the Login page.
|
||||
/// Validates that the login form renders, credentials are accepted, and logout revokes the session.
|
||||
/// Requires a running Docker host (Category: RequiresDockerHost).
|
||||
/// </summary>
|
||||
public sealed class LoginPageTests(PlaywrightFixture fixture) : UiTestBase(fixture)
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies the login page renders, credentials authenticate the user, and logout revokes the session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Steps:
|
||||
/// <list type="number">
|
||||
/// <item>Navigate to the login page.</item>
|
||||
/// <item>Assert the page title contains "Login - JDE Scoping Tool".</item>
|
||||
/// <item>Submit test credentials via UiAuthHelper.LoginAsync.</item>
|
||||
/// <item>Assert the user sees the Logout button or remains on the login view.</item>
|
||||
/// <item>Invoke UiAuthHelper.LogoutAsync.</item>
|
||||
/// <item>GET /api/auth/me and assert HTTP 401 (session revoked).</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
[Trait("Category", "RequiresDockerHost")]
|
||||
public async Task LoginPage_AllowsLoginAndLogout()
|
||||
@@ -17,9 +36,9 @@ public sealed class LoginPageTests(PlaywrightFixture fixture) : UiTestBase(fixtu
|
||||
|
||||
await UiAuthHelper.LoginAsync(page);
|
||||
var loggedOutView = page.GetByText("Authentication Required");
|
||||
var logoutButton = page.GetByRole(Microsoft.Playwright.AriaRole.Button, new() { Name = "Logout" });
|
||||
var authenticated = await logoutButton.IsVisibleAsync();
|
||||
var stillOnLogin = await loggedOutView.IsVisibleAsync();
|
||||
var logoutButton = page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Logout" });
|
||||
bool authenticated = await logoutButton.IsVisibleAsync();
|
||||
bool stillOnLogin = await loggedOutView.IsVisibleAsync();
|
||||
Assert.True(authenticated || stillOnLogin);
|
||||
|
||||
await UiAuthHelper.LogoutAsync(page);
|
||||
@@ -27,4 +46,4 @@ public sealed class LoginPageTests(PlaywrightFixture fixture) : UiTestBase(fixtu
|
||||
Assert.Equal(401, meAfterLogout.Status);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user