Files
jdescopingtool/NEW/tests/JdeScoping.Ui.Tests/LoginPageTests.cs
T
Joseph Doherty 9bd5e340b0 Convert XML list markup to plain numbered text in UI test remarks
Replace <list type="number"><item>...</item></list> with plain numbered
lines in method-level <remarks> blocks across 23 UI test files to match
the codebase convention of using simple text in XML doc comments.
2026-02-10 08:05:42 -05:00

47 lines
2.0 KiB
C#

using System.Text.RegularExpressions;
using JdeScoping.Ui.Tests.Helpers;
using JdeScoping.Ui.Tests.Support;
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:
/// 1. Navigate to the login page.
/// 2. Assert the page title contains "Login - JDE Scoping Tool".
/// 3. Submit test credentials via UiAuthHelper.LoginAsync.
/// 4. Assert the user sees the Logout button or remains on the login view.
/// 5. Invoke UiAuthHelper.LogoutAsync.
/// 6. GET /api/auth/me and assert HTTP 401 (session revoked).
/// </remarks>
[Fact]
[Trait("Category", "RequiresDockerHost")]
public async Task LoginPage_AllowsLoginAndLogout()
{
await RunAsync(async page =>
{
await UiNavigationHelper.NavigateToLoginAsync(page);
await Assertions.Expect(page).ToHaveTitleAsync(new Regex("Login - JDE Scoping Tool"));
await UiAuthHelper.LoginAsync(page);
var loggedOutView = page.GetByText("Authentication Required");
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);
var meAfterLogout = await page.Context.APIRequest.GetAsync("/api/auth/me");
Assert.Equal(401, meAfterLogout.Status);
});
}
}