Migrate Playwright suite to .NET UI tests and deprecate TS project
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using JdeScoping.Ui.Tests.Helpers;
|
||||
using JdeScoping.Ui.Tests.Support;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace JdeScoping.Ui.Tests;
|
||||
|
||||
public sealed class LoginPageTests(PlaywrightFixture fixture) : UiTestBase(fixture)
|
||||
{
|
||||
[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(Microsoft.Playwright.AriaRole.Button, new() { Name = "Logout" });
|
||||
var authenticated = await logoutButton.IsVisibleAsync();
|
||||
var 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user