Add game import UI tests with page object and storage location seeding
- Create GamesPage page object with NavigateAsync, GetGameCountAsync,
IsGameVisibleAsync, ImportGameAsync, and OpenGameEditAsync methods
- Create GameImportTests with 5 tests covering empty state, import
button visibility, LCX file import, imported game visibility, and
game edit navigation
- Seed default storage locations (Archive, Save, Media) in
ConfiguredServerFixture to support import dialog initialization
- Handle hidden file input upload via Playwright SetInputFilesAsync
- Scope modal interactions to .ant-modal-wrap to avoid button
ambiguity with the page toolbar
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 16:41:36 +11:00
|
|
|
using LANCommander.SDK.Enums;
|
2026-02-28 15:13:04 +11:00
|
|
|
using LANCommander.Server.Data;
|
|
|
|
|
using LANCommander.Server.Data.Models;
|
|
|
|
|
using LANCommander.Server.Services;
|
|
|
|
|
using LANCommander.Server.Settings.Enums;
|
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;
|
2026-02-28 15:13:04 +11:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
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 Microsoft.Playwright;
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Server.UI.Tests;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-02-28 15:13:04 +11:00
|
|
|
/// Shared fixture that starts the server via WebApplicationFactory, programmatically creates
|
2026-06-23 17:51:34 -05:00
|
|
|
/// the admin user, and makes it available for all tests in the collection.
|
|
|
|
|
/// Shared across the "Server" collection via ICollectionFixture<ConfiguredServerFixture>.
|
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>
|
|
|
|
|
public class ConfiguredServerFixture : IAsyncLifetime
|
|
|
|
|
{
|
|
|
|
|
public PlaywrightFixture Playwright { get; private set; } = null!;
|
2026-02-28 15:13:04 +11:00
|
|
|
public UITestApplicationFactory Factory { get; private set; } = null!;
|
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 12:07:52 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// ID of a game created via the service layer for edit tests.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid TestGameId { get; private set; }
|
|
|
|
|
public const string TestGameTitle = "Test Game";
|
|
|
|
|
|
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 InitializeAsync()
|
|
|
|
|
{
|
|
|
|
|
Playwright = new PlaywrightFixture();
|
|
|
|
|
await Playwright.InitializeAsync();
|
|
|
|
|
|
2026-02-28 15:13:04 +11:00
|
|
|
Factory = new UITestApplicationFactory();
|
|
|
|
|
// Trigger the factory to start the Kestrel server
|
|
|
|
|
_ = Factory.Services;
|
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
|
|
|
// Create the admin user via the service layer (before setting Provider
|
|
|
|
|
// so OnConfiguring doesn't try to add a conflicting SQLite provider)
|
|
|
|
|
using var scope = Factory.RealServices.CreateScope();
|
|
|
|
|
var roleService = scope.ServiceProvider.GetRequiredService<RoleService>();
|
|
|
|
|
var userService = scope.ServiceProvider.GetRequiredService<UserService>();
|
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
|
|
|
await roleService.AddAsync(new Role { Name = RoleService.AdministratorRoleName });
|
|
|
|
|
var user = await userService.AddAsync(new User { UserName = TestConstants.AdminUserName });
|
|
|
|
|
await userService.ChangePassword(user.UserName, TestConstants.AdminPassword);
|
|
|
|
|
await userService.AddToRoleAsync(user.UserName, RoleService.AdministratorRoleName);
|
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
|
|
|
|
Add game import UI tests with page object and storage location seeding
- Create GamesPage page object with NavigateAsync, GetGameCountAsync,
IsGameVisibleAsync, ImportGameAsync, and OpenGameEditAsync methods
- Create GameImportTests with 5 tests covering empty state, import
button visibility, LCX file import, imported game visibility, and
game edit navigation
- Seed default storage locations (Archive, Save, Media) in
ConfiguredServerFixture to support import dialog initialization
- Handle hidden file input upload via Playwright SetInputFilesAsync
- Scope modal interactions to .ant-modal-wrap to avoid button
ambiguity with the page toolbar
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-07 16:41:36 +11:00
|
|
|
// Seed default storage locations so the import dialog can initialize
|
|
|
|
|
var storageLocationService = scope.ServiceProvider.GetRequiredService<StorageLocationService>();
|
|
|
|
|
var archivePath = Path.Combine(Path.GetTempPath(), "LANCommander_UITest_Archives");
|
|
|
|
|
Directory.CreateDirectory(archivePath);
|
|
|
|
|
await storageLocationService.AddAsync(new StorageLocation
|
|
|
|
|
{
|
|
|
|
|
Path = archivePath,
|
|
|
|
|
Type = StorageLocationType.Archive,
|
|
|
|
|
Default = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var savePath = Path.Combine(Path.GetTempPath(), "LANCommander_UITest_Saves");
|
|
|
|
|
Directory.CreateDirectory(savePath);
|
|
|
|
|
await storageLocationService.AddAsync(new StorageLocation
|
|
|
|
|
{
|
|
|
|
|
Path = savePath,
|
|
|
|
|
Type = StorageLocationType.Save,
|
|
|
|
|
Default = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var mediaPath = Path.Combine(Path.GetTempPath(), "LANCommander_UITest_Media");
|
|
|
|
|
Directory.CreateDirectory(mediaPath);
|
|
|
|
|
await storageLocationService.AddAsync(new StorageLocation
|
|
|
|
|
{
|
|
|
|
|
Path = mediaPath,
|
|
|
|
|
Type = StorageLocationType.Media,
|
|
|
|
|
Default = true
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-08 12:07:52 +11:00
|
|
|
// Seed a test game via the service layer for edit tests
|
|
|
|
|
var gameService = scope.ServiceProvider.GetRequiredService<GameService>();
|
|
|
|
|
var game = await gameService.AddAsync(new Game
|
|
|
|
|
{
|
|
|
|
|
Title = TestGameTitle,
|
|
|
|
|
Type = GameType.MainGame,
|
|
|
|
|
Singleplayer = true
|
|
|
|
|
});
|
|
|
|
|
TestGameId = game.Id;
|
|
|
|
|
|
2026-02-28 15:13:04 +11:00
|
|
|
// Now set the database provider so the server doesn't redirect to /FirstTimeSetup
|
|
|
|
|
DatabaseContext.Provider = DatabaseProvider.SQLite;
|
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-02-28 15:13:04 +11:00
|
|
|
// Reset the static provider so other tests can use a fresh state
|
|
|
|
|
DatabaseContext.Provider = DatabaseProvider.Unknown;
|
|
|
|
|
|
|
|
|
|
await Factory.DisposeAsync();
|
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
|
|
|
await Playwright.DisposeAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new browser context and page, already logged in as admin.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<(IBrowserContext Context, IPage Page)> CreateLoggedInPageAsync()
|
|
|
|
|
{
|
2026-02-28 15:13:04 +11:00
|
|
|
var context = await Playwright.NewContextAsync(Factory.BaseAddress);
|
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
|
|
|
var page = await context.NewPageAsync();
|
|
|
|
|
|
|
|
|
|
var loginPage = new LoginPage(page);
|
|
|
|
|
await loginPage.NavigateAsync();
|
|
|
|
|
await loginPage.LoginAsync(TestConstants.AdminUserName, TestConstants.AdminPassword);
|
|
|
|
|
await page.WaitForSelectorAsync("text=Dashboard", new() { Timeout = 15000 });
|
|
|
|
|
|
|
|
|
|
return (context, page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new browser context and page (not logged in).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<(IBrowserContext Context, IPage Page)> CreateAnonymousPageAsync()
|
|
|
|
|
{
|
2026-02-28 15:13:04 +11:00
|
|
|
var context = await Playwright.NewContextAsync(Factory.BaseAddress);
|
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
|
|
|
var page = await context.NewPageAsync();
|
|
|
|
|
return (context, page);
|
|
|
|
|
}
|
|
|
|
|
}
|