Skip to content

refactor(web): close the follow-ups of #196 and remove GameService - #210

Merged
mwg-bender[bot] merged 1 commit into
devfrom
refactor/060-library-followups
Nov 23, 2026
Merged

mwg-bender[bot] merged 1 commit into
devfrom
refactor/060-library-followups

Conversation

@mwg-bender

@mwg-bender mwg-bender Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

This was generated by AI (Nerd Bender's Kanban worker, card t_711ba11a).

Summary

Closes the follow-ups of #196 (shared Library page and its pages) under spec #205, and removes GameService. The Events page, the Stats page and the Activity details performance panel now read the Games through LibraryClient<GameEntity>. Library form errors now reach the inner input of a Fluent text field in a real browser. The rest is the review's test and design leftovers. One commit, refactor(web), Refs #196, #205.

Change

  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.1 GameService removed. Events.razor, Stats.razor and ActivityPerformancePanel.razor inject LibraryClient<GameEntity> and call its GetAllAsync, which throws on failure the same way, so each page keeps its error bar and Retry. GameService.cs, its registration and its PageHarness entry are gone, as are the duplicate GET api/games route row and the typeof(GameService) entry. ApiResultTests keeps its point (a real service load against a failing server yields the server's message) with EventService. New GameReadersTests: Events, Stats and the panel each send exactly one GET api/games.
  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.2 Messages reach the input. A Fluent text field copies aria-describedby into its shadow root, where the message id does not resolve. LibraryFieldMessage now loads a collocated module (LibraryFieldMessage.razor.js) that sets input.ariaDescribedByElements = [message holder] on the field's inner input. That is ARIA element reflection, which crosses the shadow boundary. Chromium then gives the field its message as its description, and the description follows the message as it comes and goes. The Game picker (fluent-select) is the combobox itself, so its own aria-describedby already resolves; the module leaves it alone. bUnit checks: the link call per field names the holder that the field's aria-describedby names, and the Game picker's aria-invalid and aria-describedby. Browser evidence is below. The Events card solves the metrics form separately.
  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.3 LibraryName<T>.Of reads a null name as empty, so a search never throws on it.
  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.4 Program.cs registers everything through AppServices.AddAppServices(apiBase). A test builds that and resolves the four Library clients and the app's HttpClient.
  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.11 One LibraryItemButton for the Edit and Delete of table rows, the icon card and the Games card (Labelled). Activities.razor gets one DetailsKey(id) for the details-{id} focus key.
  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.12 LibraryName<T> replaces the Name + SetName pair. LibraryField is the one typed key for LibraryFieldError.Field, LibraryFieldMessage Field= and FieldAttributes(...), and it owns MessageId.
  • refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.13 RowAction says AnyBusy. Running stays only as an alias for Shared/Events/EventList.razor, which this card may not edit. AddLibraryClients moves to LibraryClients.cs. LibraryPage implements IDisposable and unsubscribes OnValidationStateChanged when the editor closes or the page goes.
  • Tests (refactor(web): follow-ups from the review of the shared Library page follow-ups (#192) #196.5, .6, .8, .9, .10).
    • LibraryPageTests (823 lines) is split over one abstract LibraryPageFixture into LibraryPageTests (list), LibraryEditorTests, GamesWebsiteTests and LibraryClientTests. Every base test exists exactly once.
    • The stale toggle test is renamed and renders Activities with rows.
    • GetRawConstantValue is replaced by direct AreEqual on the constants.
    • LibraryClientTests and ServiceRouteContractTests share one disposed provider setup (LibraryServices).
    • ActivitiesPageTests asserts the editor's own "Game is required." and no longer hard-codes the API text.
    • ThemesHolidaysPageTests uses usings and puts the title and icon type in the DataRow.
    • LibraryPage.razor is 384 → 379 lines.

Validation

Base origin/dev moved during the run, from 2730911 to 617f4a4 (#207 docs, #208 Series, no file in this card's scope). The branch was rebased before push and everything below was re-run on the rebased head.

errors warnings Api.Tests Web.Tests
base 2730911 (cold, worker) 0 0 495 + 4 skipped 727
base 617f4a4 (cold, worker) 0 0 589 + 4 skipped 727
head (rebased, cold, worker) 0 0 589 + 4 skipped 735 (727 + 8)

Count preservation: no test removed. One renamed (CardView_IsOfferedOnlyToAPageThatGivesACardTemplate → ViewToggle_IsOfferedOnlyToAPageWithACardTemplateOrIcon). Eight added:

  • GameReadersTests.EventsPage_SendsOneGamesRead
  • GameReadersTests.StatsPage_SendsOneGamesRead
  • GameReadersTests.ActivityDetails_PerformancePanel_SendsOneGamesRead
  • LibraryPageTests.Search_AnItemWithNoName_CountsAsEmpty
  • LibraryClientTests.AppServices_RegisterTheFourLibraryClients
  • LibraryEditorTests.Editor_AClosedEditorsForm_NoLongerRendersThePage
  • LibraryEditorTests.FieldMessage_LinksItsMessagesToTheFieldsInput
  • ActivitiesPageTests.GamePicker_SaysItIsInvalid_AndNamesItsMessage

A name diff of base against head shows no other change.

Break-it mutations, each applied to a throwaway copy of the production line and restored. All 10 went red:

  • M1: null name not defaulted
  • M2: no unsubscribe
  • M3: AddLibraryClients removed from AppServices
  • M4: no link call
  • M5: Game picker without FieldAttributes
  • M6: Events reads Games twice
  • M7: Stats with no Games read
  • M8: panel with no Games read
  • M9: Activities rows hidden
  • M10: shared Edit button never disabled

Live runs by the worker, through with-slot.sh (Azurite + API + Release web build behind SWA, headless Chromium 153, admin cookie), on the branch and on plain origin/dev 617f4a4 as a control:

flow branch 17270c8 control origin/dev 617f4a4
G1a Events page: one GET api/games, the Event's Game shows PASS (x1, shown) PASS (x1, shown)
G1b Stats page: one GET api/games, Game named, not Deleted PASS (x1, offered 1) PASS (x1, offered 1)
G1c Activity details: panel reads Games once, numbers show PASS (page x1, panel x1, offered 1, won 1) PASS (same)
G2 Games editor: invalid fields described by their messages PASS FAIL (descriptions "")
G2 Activities editor PASS FAIL (Activity Name ""; the Game combobox already PASSES on dev)
G2 Themes editor PASS FAIL ("")
G2 Holidays editor PASS FAIL ("")
G3 Games: invalid Website message linked, follows fix and break; nothing stored PASS FAIL ("" throughout; nothing stored on either)
G4 repo E2E suite 7 of 7 7 of 7

G1 is the same on both sides, so the Game reads did not change. G2 and G3 fail on dev and pass on the branch, which is the #196.2 fix. Accessibility-tree output from the branch, verbatim (Chromium CDP Accessibility.getFullAXTree):

G2 Games editor: [{"role":"textbox","name":"Game Name","description":"Name is required.","invalid":"true"},{"role":"textbox","name":"Website (Optional)","description":"Website must be an http or https address.","invalid":"true"}]
G2 Activities editor: [{"role":"combobox","name":"Game","description":"Game is required.","invalid":"true"},{"role":"textbox","name":"Activity Name","description":"Name is required.","invalid":"true"}]
G2 Themes editor: [{"role":"textbox","name":"Name","description":"Name is required.","invalid":"true"}]
G2 Holidays editor: [{"role":"textbox","name":"Name","description":"Name is required.","invalid":"true"}]
G3 broken={"description":"Website must be an http or https address.","invalid":"true"} fixed={"description":"","invalid":"false"} again={"description":"Website must be an http or https address.","invalid":"true"}

The same on origin/dev: {"role":"textbox","name":"Game Name","description":"","invalid":"true"} and the same empty description for every text field. Before the fix, a probe on the base compared the techniques: a host idref gave ""; input.ariaDescribedByElements gave the message and followed it live; aria-description on the input gave the text but would need re-syncing; on the host it gave ""; ariaErrorMessageElements gave only an errormessage relation, no description. The element link was chosen.

Notes

The Events page, the Stats page and the Activity details performance panel
read the Games through LibraryClient<GameEntity>, so GameService, its
registration and its duplicate GET api/games route row are gone. Each reader
still sends exactly one GET api/games (GameReadersTests).

A Fluent text field copies aria-describedby into its shadow root, where the
message id cannot be found, so a screen reader got no description for a
field with an error. LibraryFieldMessage now links the field's inner input
to its message holder by element (ariaDescribedByElements) through a
collocated module; in Chromium the Library forms' fields are described by
their messages and the link follows the message as it comes and goes. The
Game picker is the combobox itself and its own link already resolves.

Also: a null name reads as empty again (no throw when searched); one
LibraryField key for a field's rule, message and attributes; one
LibraryName for the Name and SetName pair; one LibraryItemButton for the
Edit and Delete of rows, icon cards and the Games card; RowAction says
AnyBusy (Running stays only for the Events list, owned elsewhere); the page
stops watching a closed editor's form; AddLibraryClients has its own file and
Program.cs registers everything through AddAppServices, which a test builds.
LibraryPageTests is split into LibraryPageTests, LibraryEditorTests,
GamesWebsiteTests and LibraryClientTests over one fixture.

Refs #196, #205
@github-actions

Copy link
Copy Markdown

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
1328 1324 0 0 4 0 57.0s

🎉 No failed tests in this run.

Github Test Reporter by CTRF 💚

@mwg-bender
mwg-bender Bot merged commit bc2617d into dev Nov 23, 2026
7 checks passed
mwg-bender Bot added a commit that referenced this pull request Nov 26, 2026
> *This was generated by AI (Nerd Bender's Kanban worker, card t_9dc12a0f).*

## Summary

The last open item of #196, the follow-ups from the review of the shared Library page (#192). The audit against `origin/dev` 13e2b31 found 13 of the 15 items already closed on `dev`, almost all by #210. #196.14 and #196.15 are history, not code. The one item still open in code was the rest of **#196.7**: `DialogSafetyTests` still called the Library page's private `CloseForm` by reflection. This PR replaces that call with an internal seam. The per-item dispositions are in the table below and are repeated as a PR comment.

## Change

- `LibraryPage.razor`: `CloseForm` is `internal` instead of `private`. A one-line comment says why: no page event can close the dialog while a save runs, and the test needs to do exactly that. The method body is unchanged.
- `MW-GC.EventManager.Web.csproj`: `<InternalsVisibleTo Include="MW-GC.EventManager.Web.Tests" />`. **Design call (the smallest seam):** the Web project had no `InternalsVisibleTo` before. The API project already grants the same access to both test projects (`MW-GC.EventManager.API/Properties/AssemblyInfo.cs`). A public method would have widened the component's API instead.
- `DialogSafetyTests.SaveFinishingAfterCancelAndReopen_DoesNotCloseOrResetTheNewerDialog`: the test closes the dialog through `EventCallback.Factory.Create(library, library.CloseForm).InvokeAsync()` on the renderer. The renderer then re-renders the page as it does after a real event, so the reflected `StateHasChanged` call is gone too. Every assertion is unchanged. The `_edit` and `CancelForm` reflection that #196.7 also named was already gone on `dev`: the test reads the newer dialog through the page, and `CancelButton_IsIgnoredWhileSaveInFlight` uses the Cancel button's own handler.
- The `CloseThrough` helper stays for `EventEditDialog.CloseCustomize`, which is outside #196 (see Observations). Its comment now names only that use.

## DISPOSITION (#196, items 1 to 15)

| item | disposition | evidence |
|---|---|---|
| #196.1 | ALREADY DONE | #210. `GameService.cs` is deleted. `Events.razor:5`, `Stats.razor:5` and `ActivityPerformancePanel.razor:9` inject `LibraryClient<GameEntity>`. Only one `GET api/games` row is left (`ServiceRouteContractTests.cs:71`). `GameReadersTests` covers each reader. |
| #196.2 | ALREADY DONE | #210. `LibraryFieldMessage.razor.js:11` sets `ariaDescribedByElements` on the inner input. The accessibility tree was checked in a browser in #210's evidence. The Game picker is covered by `ActivitiesPageTests.cs:167`. This PR did not re-run that browser check. |
| #196.3 | ALREADY DONE | #210. `LibraryField.cs:33` reads `read(item) ?? string.Empty`. Test: `LibraryPageTests.Search_AnItemWithNoName_CountsAsEmpty` (`:77`). |
| #196.4 | ALREADY DONE | #210. `Program.cs:12` calls only `AddAppServices`. Test: `LibraryClientTests.AppServices_RegisterTheFourLibraryClients` (`:68`). #210 mutation M3 removed `AddLibraryClients`, and the test went red. |
| #196.5 | ALREADY DONE | #210. `LibraryPageTests.cs:99-103` renders Activities with a row and checks that the row shows. |
| #196.6 | ALREADY DONE | #210. `ActivitiesPageTests.cs:156-165` asserts the form's own "Game is required." and compares refusals with the API's, not its text. |
| #196.7 | **DONE** | This PR, `CloseForm`: an internal seam, called on the renderer. `_edit` and `CancelForm` were already off reflection (#210, #211). |
| #196.8 | ALREADY DONE | #210. The test is renamed `ViewToggle_IsOfferedOnlyToAPageWithACardTemplateOrIcon`. No `GetRawConstantValue` is left. `LibraryServices.cs` is the one shared, disposed provider. Message-id uniqueness is documented on `LibraryField.MessageId` (`LibraryField.cs:16-21`). |
| #196.9 | ALREADY DONE | #210. `ThemesHolidaysPageTests.cs:128-130` puts the title and icon type in the `DataRow`, uses plain `using` lines, and has no fully-qualified names. |
| #196.10 | ALREADY DONE | #210. `LibraryPageTests.cs` is 227 lines, split into `LibraryEditorTests` (288), `GamesWebsiteTests` (171), `LibraryClientTests` (118) and `LibraryPageFixture` (150). `LibraryPage.razor` is 380 lines after this PR (379 before). |
| #196.11 | ALREADY DONE | #210. `LibraryItemButton.razor` holds the one Edit/Delete markup. `Activities.razor:272` has `DetailsKey`. |
| #196.12 | ALREADY DONE | #210. `LibraryName<T>` and the typed `LibraryField` key are in place. |
| #196.13 | ALREADY DONE | #210 and later. `RowAction` exposes only `AnyBusy`; the `Running` alias is gone and `EventList.razor:68` uses `AnyBusy`. `LibraryPage.razor:300-309` unsubscribes on close and in `Dispose`. Test: `LibraryEditorTests.Editor_AClosedEditorsForm_NoLongerRendersThePage`. `AddLibraryClients` lives in `LibraryClients.cs`. |
| #196.14 | DECLINED | History (the commit type of #192), not code. |
| #196.15 | DECLINED | History (a reason given in the #192 PR text), not code. |

## Validation

All numbers come from a cold build (`clean-build.sh`, then `build --no-incremental`, then `test --no-build`), run by the worker.

| | errors | warnings | Api.Tests | Web.Tests | E2E (no stack) |
|---|---|---|---|---|---|
| base 13e2b31 | 0 | 0 | 901 + 2 skipped (903) | 1245 | 5 + 13 skipped (18) |
| head f1b262a | 0 | 0 | 901 + 2 skipped (903) | 1245 | 5 + 13 skipped (18) |

Count preservation: no test was added, removed, renamed or split, so 1245 before and after. One existing test changes how it closes the dialog; none of its assertions change.

Break-it mutations on `SaveFinishingAfterCancelAndReopen_DoesNotCloseOrResetTheNewerDialog`, each applied to `LibraryPage.razor` and then restored (the restore was checked byte for byte):
- **M1:** the save ignores its dialog token (`var current = true;`). The test goes **red** at `page.DialogTitle()`: the late save closed the newer dialog.
- **M2:** the internal `CloseForm` does nothing. The test goes **red** at `Assert.IsFalse(page.HasFormDialog())`.

Live run by the worker, through `with-slot.sh` on slot 0 (Azurite + API + Release web build behind SWA, headless Chromium, admin cookie). The script seeds two Games, one Activity and one Event through the API.

| flow | branch f1b262a | control `origin/dev` 13e2b31 |
|---|---|---|
| P1 Games page loads, both Games listed (1 `GET api/games`) | PASS | PASS |
| P2 Games Edit dialog: Cancel closes it, then a rename saves and closes (stored name read back from the API) | PASS | PASS |
| P3 Activities page loads, the Activity shows its Game | PASS | PASS |
| P4 Game picker: Add Activity, pick the second Game, save; the API stores the picked Game | PASS | PASS |
| P5 Events page loads, the Event's details list its Game and Activity | PASS | PASS |
| P6 Stats page loads and names the Game, with no load error | PASS | PASS |

There were no console errors on either side, and `api_flows.py` passed 10 of 10 on both. The first branch run reported P2 as FAIL: the script's open-dialog check used Playwright's `visible=true` on the `fluent-dialog` host, whose box lives in its shadow root. That was a bug in the script, not in the app (the same run saved the rename and stored it). The check was fixed to test whether the element is present, and the run above is the re-run. The repo E2E suite was not run against a live slot here, because no E2E file changed. The #196.2 accessibility-tree check was not re-run.

## Notes

- `Refs #196`, not `Closes`. Every item above has a disposition, so Nerd can close #196 by hand.
- Not merged.

## Observations for Nerd

- `EventEditDialog.CloseCustomize` is still called by reflection in `DialogSafetyTests.cs:230` and `EventsPageWiringTests.cs:227`, and `EventDetailsDialog.CloseDetails` in `EventsPageWiringTests.cs:245`. These are the same pattern on the Events side, outside #196. Now that the Web project grants `InternalsVisibleTo`, the same one-line seam would retire `CloseThrough` and its `System.Reflection` import in both files.
- `UnrenderedEventsPage.cs`, `FeedbackPageTests.cs` and `EventMetricsFormTests.cs` also use reflection. Those are other issues; I did not check them against the new seam.
@MWG-Logan
MWG-Logan deleted the refactor/060-library-followups branch November 27, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants