Commit graph

22 commits

Author SHA1 Message Date
Pat Hartl
2a64a621fc Tests for first time setup creation of administrator account 2026-06-25 01:51:42 -05:00
Pat Hartl
12d63c02a2 Stabilize Playwright smoke layer for CI
The remaining Playwright failures were all in interactions that depend on
the Blazor Server circuit being responsive in CI:

- Settings page access now navigates to /Settings/General directly instead
  of expanding the flaky nested Settings SubMenu flyout.
- Drop SettingsMenu_ShowsAllExpectedSubItems; the submenu-expansion is the
  unreliable interaction the bUnit migration exists to replace, and the
  Settings pages are now covered by bUnit component tests.
- Remove the GameImport UI tests (and unused GamesPage/OpenRCT2.lcx). The
  ChunkUploader modal never renders under the in-process test host, so they
  failed in every CI run; the Games list render is already covered by
  AdminNavigationTests.GamesPage_ShowsEmptyTable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-24 23:14:42 -05:00
Pat Hartl
004a254c37 Migrate flaky Playwright admin UI tests to bUnit
Replace the SignalR-circuit-race-prone Playwright component tests for
GameEdit, Settings, metadata, profile, roles and users with in-process
bUnit component tests. Keep a thin Playwright smoke layer for the true
E2E paths (login, admin navigation/routing, first-time setup, game
import) that bUnit cannot cover.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-24 20:45:21 -05:00
Pat Hartl
6a2b5177b0 Use SQLite instead of EF InMemory for UI tests
The DataTable component issues relational queries (AsSplitQuery, Include,
and a translated punctuation-stripping search expression) that the EF
InMemory provider cannot translate. On CI this surfaced as a native stack
overflow in CountAsync that crashed the in-process server and cascaded
into widespread timeouts. A file-based SQLite database supports these
queries and concurrent connections, stabilizing the test run.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-24 00:39:44 -05:00
Pat Hartl
f2a864b540 Update UI tests for post-merge changes from main
- Target net10.0 to match the now-net10 server project (and fix the
  Playwright browser-install path in the PR workflow accordingly).
- Dismiss the persistent "Import Ready" notification (added with main's
  background UploadTracker) before clicking Import; its Duration=0 toast
  overlays and intercepts the modal's Import button.
- Update General settings assertions: "Database Provider" moved to the new
  dedicated /Settings/Database page, so assert on "Use SSL" instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-23 22:11:05 -05:00
Pat Hartl
65c00fe9e1 Fix game import test: set file on InputFile directly
Replace the FileChooser approach with SetInputFilesAsync targeting the
ChunkUploader's hidden InputFile (matched by id prefix), which correctly
drives Blazor's OnChange and enables the Upload button. Also wait on the
actual Upload button's enabled state instead of the first primary button
(which matched the always-enabled "Browse" button and passed spuriously).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-23 21:03:16 -05:00
Pat Hartl
9b5195f1d6 Use web-first Playwright assertions in UI tests
Replace non-waiting Assert.True(await locator.IsVisibleAsync()) checks with
auto-retrying Assertions.Expect(locator).ToBeVisibleAsync()/ToBeHiddenAsync()
to remove flakiness against Blazor's async rendering. Table-row/field page
objects (Metadata/Roles/Users/Profile) now expose ILocator helpers instead of
Task<bool>, so deletion checks wait for the element to disappear.

Also: rename ScreenshotHelper.CaptureIfFailedAsync to CaptureAsync (xUnit v2
cannot expose the test outcome to DisposeAsync, so it always captures the final
page state), drop the unused TestConstants.ServerPort/BaseUrl now that ports
bind dynamically, and fix IClassFixture doc comments to ICollectionFixture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-23 17:51:34 -05:00
Aaron Powell
77b0f04e4d Fix file upload: use FileChooser API for Blazor InputFile compatibility
Blazor Server's InputFile component doesn't reliably process synthetic
FileList objects from Playwright's SetInputFilesAsync on headless Linux.
Switch to clicking the upload label to trigger the native file dialog,
then intercept it with Playwright's FileChooser API. This triggers a
real browser file selection that Blazor always recognizes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 12:56:49 +11:00
Aaron Powell
0c3ed7cb77 Capture screenshots on test completion for CI diagnostics
- Add ScreenshotHelper that captures full-page screenshots for every test
- Screenshots are named with the full test display name for easy correlation
- Save to SCREENSHOT_DIR env var (CI) or bin/Screenshots/ (local)
- Add ITestOutputHelper to all 10 test classes for test name extraction
- Screenshots are included in the existing ui-test-results artifact upload

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 12:33:49 +11:00
Aaron Powell
952af65b2c Fix CI: decouple GameEditTests from import, add test-reporter
- GameEditTests now use a game seeded via the service layer in
  ConfiguredServerFixture instead of importing via the UI.
  This eliminates the Blazor InputFile compatibility issue on Linux CI.
- GamesPage.ImportGameAsync uses SetInputFilesAsync with retry and
  manual change event dispatch for Blazor InputFile compatibility.
- Add dorny/test-reporter to display test results in PR summary.
- Add checks/pull-requests write permissions for test-reporter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 12:07:52 +11:00
Aaron Powell
951c1a08a0 Fix game import file upload for headless Linux CI
Use Playwright's FileChooser API instead of SetInputFilesAsync on the
hidden file input. AntDesign's Upload component JS interop doesn't
recognize files set directly on the hidden input in headless Linux,
leaving the Upload button disabled. The FileChooser approach intercepts
the native file dialog, which AntDesign processes normally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 10:05:28 +11:00
Aaron Powell
c856a51504 Fix stack overflow on test disposal with FreshServerFixture
- Refactor FirstTimeSetupTests to use FreshServerFixture via ICollectionFixture
  instead of creating its own UITestApplicationFactory per test
- Skip _realHost.Dispose() in UITestApplicationFactory since the DI container's
  deep dependency chain causes an uncatchable native StackOverflowException
- All 62 tests pass with exit code 0 (61 pass, 1 skip)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:41:11 +11:00
Aaron Powell
0bac5e7b8b Move test .lcx file into repo under TestData
Copy OpenRCT2.lcx into TestData/ and reference via AppContext.BaseDirectory
so tests don't depend on a user-specific Downloads path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:45 +11:00
Aaron Powell
39ebe66c73 Add game editing UI tests with page object
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
fd0c15bf8a Fix full test suite: use ICollectionFixture and remove Hangfire
- Switch all test classes from IClassFixture<ConfiguredServerFixture> to
  [Collection("Server")] with ICollectionFixture so a single server instance
  is shared across all test classes (avoids static DatabaseContext.Provider conflicts)
- Put FirstTimeSetupTests in its own collection since it needs an unconfigured server
- Remove Hangfire hosted services in UITestApplicationFactory to prevent
  stack overflow during process shutdown (deep DI disposal chain)
- Add graceful shutdown handling with timeout in DisposeAsync
- All 54 tests pass, 1 skipped, clean exit code 0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
3e6c59e384 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-08 08:25:44 +11:00
Aaron Powell
3cc9e47461 Add user management UI tests with page object
- Create UsersPage page object with navigate, search, user visibility,
  roles check, and delete methods
- Add UserManagementTests with 5 tests: admin user visibility, search,
  roles display, new user registration, and user deletion
- Fix GamesPage.cs syntax error (unchecked is a C# keyword)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
d9d6e7a3c9 Add Settings page UI tests
Create SettingsPage page object with navigation helpers for all settings
sub-pages and SettingsTests with 9 tests covering General form elements,
Users list, Roles list, Authentication, Archives, Media, Beacon, Updates,
and Appearance settings pages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
7a90eb1d48 Add metadata CRUD UI tests for Tags, Genres, and Platforms
Create a reusable MetadataPage page object that encapsulates navigation,
add/edit/delete operations, and item visibility checks for any metadata
type. Add MetadataTests with 8 tests covering:
- Tags: empty state, add, edit, delete
- Genres: add, delete
- Platforms: add, delete

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
4f528e5378 Add role management UI tests
Add Playwright-based UI tests for the Roles management page including:
- RolesPage page object with navigation, add, delete, and visibility methods
- Tests verifying Administrator role visibility
- Tests for adding and deleting custom roles
- Test confirming Administrator role cannot be deleted

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
5e3d740b83 Refactor UI tests to use WebApplicationFactory instead of dotnet run
Replace process-based server management (ServerManager) with ASP.NET Core's
WebApplicationFactory<Program> for proper integration testing:

- Add UITestApplicationFactory with dual-host pattern (real Kestrel + dummy TestServer)
  to work around .NET 9's hard-cast to TestServer in WebApplicationFactory
- Use in-memory EF Core database with dynamic port binding (IPAddress.Loopback:0)
- Stub IVersionProvider and IGitHubService to avoid external dependencies
- Programmatically create admin user in ConfiguredServerFixture via service layer
- Remove ServerManager.cs (no longer needed)
- Skip CompleteWizardAndLogin test (requires real DB file I/O)
- 18 tests pass, 1 skipped, ~28s runtime (down from ~101s)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-08 08:25:44 +11:00
Aaron Powell
94cfd6fe18 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-03-08 08:25:44 +11:00