Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
using LANCommander.Server.UI.Tests.Pages;
|
|
|
|
|
using Microsoft.Playwright;
|
2026-03-08 12:33:49 +11:00
|
|
|
using Xunit.Abstractions;
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
|
|
|
|
|
namespace LANCommander.Server.UI.Tests.Tests;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tests for the first-time setup wizard when the server has no existing configuration.
|
2026-03-07 17:12:12 +11:00
|
|
|
/// Runs in its own collection to avoid conflicts with ConfiguredServerFixture over
|
|
|
|
|
/// the static DatabaseContext.Provider.
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
/// </summary>
|
2026-03-07 17:12:12 +11:00
|
|
|
[Collection("FirstTimeSetup")]
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
public class FirstTimeSetupTests : IAsyncLifetime
|
|
|
|
|
{
|
2026-03-08 08:40:56 +11:00
|
|
|
private readonly FreshServerFixture _fixture;
|
2026-03-08 12:33:49 +11:00
|
|
|
private readonly ITestOutputHelper _output;
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
private IBrowserContext _context = null!;
|
|
|
|
|
private IPage _page = null!;
|
|
|
|
|
|
2026-03-08 12:33:49 +11:00
|
|
|
public FirstTimeSetupTests(FreshServerFixture fixture, ITestOutputHelper output)
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
{
|
2026-03-08 08:40:56 +11:00
|
|
|
_fixture = fixture;
|
2026-03-08 12:33:49 +11:00
|
|
|
_output = output;
|
2026-03-08 08:40:56 +11:00
|
|
|
}
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
|
2026-03-08 08:40:56 +11:00
|
|
|
public async Task InitializeAsync()
|
|
|
|
|
{
|
|
|
|
|
(_context, _page) = await _fixture.CreatePageAsync();
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task DisposeAsync()
|
|
|
|
|
{
|
2026-06-23 17:51:34 -05:00
|
|
|
await ScreenshotHelper.CaptureAsync(_page, _output);
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
if (_page != null) await _page.CloseAsync();
|
|
|
|
|
if (_context != null) await _context.DisposeAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task FreshServer_RedirectsToFirstTimeSetup()
|
|
|
|
|
{
|
|
|
|
|
await _page.GotoAsync("/");
|
|
|
|
|
|
|
|
|
|
// A fresh server should show the First Time Setup page
|
|
|
|
|
await _page.WaitForSelectorAsync("text=First Time Setup", new() { Timeout = 10000 });
|
|
|
|
|
|
|
|
|
|
var setupPage = new FirstTimeSetupPage(_page);
|
|
|
|
|
Assert.True(await setupPage.IsDisplayedAsync());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task FirstTimeSetup_ShowsFourSteps()
|
|
|
|
|
{
|
|
|
|
|
var setupPage = new FirstTimeSetupPage(_page);
|
|
|
|
|
await setupPage.NavigateAsync();
|
|
|
|
|
|
|
|
|
|
// Verify all 4 steps are visible in the wizard
|
2026-06-23 17:51:34 -05:00
|
|
|
await Assertions.Expect(_page.GetByText("Database").First).ToBeVisibleAsync();
|
|
|
|
|
await Assertions.Expect(_page.GetByText("Paths")).ToBeVisibleAsync();
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
// "Metadata" may be truncated in UI to "Metad" but the text node still exists
|
2026-06-23 17:51:34 -05:00
|
|
|
await Assertions.Expect(_page.Locator("text=/Metad/").First).ToBeVisibleAsync();
|
|
|
|
|
await Assertions.Expect(_page.GetByText("Administrator")).ToBeVisibleAsync();
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task FirstTimeSetup_DatabaseStep_ShowsProviderOptions()
|
|
|
|
|
{
|
|
|
|
|
var setupPage = new FirstTimeSetupPage(_page);
|
|
|
|
|
await setupPage.NavigateAsync();
|
|
|
|
|
|
|
|
|
|
// Open the database provider dropdown
|
|
|
|
|
await _page.GetByRole(AriaRole.Combobox).ClickAsync();
|
|
|
|
|
|
|
|
|
|
// Wait for the dropdown listbox to appear
|
|
|
|
|
await _page.WaitForSelectorAsync("[role='listbox']", new() { Timeout = 5000 });
|
|
|
|
|
|
|
|
|
|
// Verify all expected providers are shown
|
2026-06-23 17:51:34 -05:00
|
|
|
await Assertions.Expect(_page.GetByRole(AriaRole.Option, new() { Name = "SQLite" })).ToBeVisibleAsync();
|
|
|
|
|
await Assertions.Expect(_page.GetByRole(AriaRole.Option, new() { Name = "MySQL" })).ToBeVisibleAsync();
|
|
|
|
|
await Assertions.Expect(_page.GetByRole(AriaRole.Option, new() { Name = "PostgreSQL" })).ToBeVisibleAsync();
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
}
|
|
|
|
|
|
2026-02-28 15:13:04 +11:00
|
|
|
[Fact(Skip = "Requires real database and file I/O - not supported with in-memory WebApplicationFactory")]
|
Spike: Playwright UI automated tests for server application
Add LANCommander.Server.UI.Tests project with 19 Playwright-based UI tests
covering three key scenarios:
- First-time setup flow (4 tests): Fresh server redirect, setup wizard steps,
database provider selection, and complete wizard-to-login flow
- Login flow (5 tests): Unauthenticated redirect, page elements, valid/invalid
credentials, and empty credential handling
- Admin navigation (10 tests): Dashboard, sidebar menu, Games, Redistributables,
Tools, Servers, Issues, Files, Settings pages, and Settings submenu items
Infrastructure includes:
- ServerManager: Manages server process lifecycle with data directory backup/restore
- PlaywrightFixture: Browser lifecycle management (headless Chromium)
- ConfiguredServerFixture: Shared xUnit class fixture for tests needing a
configured server (avoids restarting server per test)
- Page objects: LoginPage, FirstTimeSetupPage, AdminDashboardPage
Key technical decisions:
- Uses IClassFixture<T> pattern to share server instances across test classes
- Disables parallel execution (tests share port 1337)
- Uses element-based waits instead of URL-based waits for Blazor SSR reliability
- Uses role-based selectors for AntDesign components (no standard label/for)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 14:16:01 +11:00
|
|
|
public async Task FirstTimeSetup_CompleteWizardAndLogin()
|
|
|
|
|
{
|
|
|
|
|
var setupPage = new FirstTimeSetupPage(_page);
|
|
|
|
|
await setupPage.NavigateAsync();
|
|
|
|
|
|
|
|
|
|
await setupPage.CompleteFullSetupAsync(
|
|
|
|
|
adminUsername: TestConstants.AdminUserName,
|
|
|
|
|
adminPassword: TestConstants.AdminPassword);
|
|
|
|
|
|
|
|
|
|
// After setup, we should be on the login page
|
|
|
|
|
Assert.Contains("/Login", _page.Url);
|
|
|
|
|
|
|
|
|
|
var loginPage = new LoginPage(_page);
|
|
|
|
|
Assert.True(await loginPage.IsDisplayedAsync());
|
|
|
|
|
|
|
|
|
|
// Now log in with the admin credentials that were just created
|
|
|
|
|
await loginPage.LoginAsync(TestConstants.AdminUserName, TestConstants.AdminPassword);
|
|
|
|
|
|
|
|
|
|
// Wait for the Blazor app to render the dashboard
|
|
|
|
|
await _page.WaitForSelectorAsync("text=Dashboard", new() { Timeout = 15000 });
|
|
|
|
|
|
|
|
|
|
var dashboard = new AdminDashboardPage(_page);
|
|
|
|
|
Assert.True(await dashboard.IsDisplayedAsync());
|
|
|
|
|
}
|
|
|
|
|
}
|