Repository navigation
chore(api): close the follow-ups of #194 and keep the Api tests under the file-size rule - #209
Merged
Merged
Conversation
… the file-size rule Split the five Api test files over about 400 lines by behaviour (EventMetrics, Feedback, Comment API, the old-text conversion and the route validation tests) into files named for what they test, with the shared helpers in *TestSupport.cs bases. Every test exists exactly once afterwards; three are renamed to say "old text" for the retired column. TableNames now names all seven tables and their partitions, and the registrations move from Program.cs into AddTableStores (no behaviour change). StoredNamesTests pins the stored table and partition names as literals, and TableStoreRegistrationTests checks the extension registers one store per table under those names, over a mocked service client. The Azurite tests now run only against local Azurite and skip with the reason otherwise, before any client exists. The conversion tests put the marker back as they found it and delete the Comments they caused. The storage query test counts the rows storage returns, so a list that read the whole partition and filtered in memory fails it, and checks the cascade with the raw table client instead of the code under test. The two Azurite files share one Flow helper, Store/Check take the row key so StoreKeyed/CheckKeyed are gone, and CommentApiTests.Stored() is inlined. The "activity-note:" salt is unchanged: it derives the Comment ids, and changing it would add duplicate Comments on a re-run. Refs #194, #205
… assertions able to fail The local-Azurite guard of the Azurite tests decided on the connection string text. UseDevelopmentStorage=true with a remote DevelopmentStorageProxyUri, or the devstoreaccount1 account with a remote TableEndpoint, passed it, and the Tables client then wrote to that remote host. The guard now builds a TableServiceClient from the string (this contacts nothing) and runs the tests only when client.Uri.Host is loopback (127.0.0.1, localhost, ::1). A string the client cannot read skips, and the skip message names the reason or the refused host. The "devstoreaccount1 on any host" allowance is gone: the azurite:10002 row is now refused. UseDevelopmentStorage=TRUE moves to the refused rows, because Azure.Data.Tables 12.11.0 cannot parse that value. TableStoreRegistrationTests counted the table clients it had created itself. A new test counts the service descriptors AddTableStores registers, so an eighth or a duplicate store registration fails it. StoredNamesTests compared test literals with test literals. A new test compares StoredNames.Stores and StoredNames.AllTables with the production TableNames and FeedbackStore constants. The startup test registers its stores with AddTableStores() instead of by hand, so it cannot drift from Program.cs. Refs #194
Contributor
Author
Review fixes (commit 1080de2) and DISPOSITIONThis adds one commit on top of 56e0d98. It touches only Api.Tests: Review-fix card
Original card, #194 items 1 to 9
Validation of 1080de2 (cold: bin/obj deleted,
|
| errors | warnings | Api.Tests | Web.Tests | |
|---|---|---|---|---|
| 56e0d98 | 0 | 0 | 514 passed + 4 skipped | 727 |
| 1080de2 | 0 | 0 | 521 passed + 4 skipped (525) | 727 |
1080de2 with slot Azurite (127.0.0.1:10012) + running API |
525 passed, 0 skipped |
The 7 new Api cases are:
AzuriteSupportTests.AConnectionStringToLocalAzuriteRuns("UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1")AConnectionStringToOtherStorageDoesNotRunfor the two bypass stringsAConnectionStringToOtherStorageDoesNotRun("UseDevelopmentStorage=TRUE")AConnectionStringThatCannotBeReadSkipsAndSaysWhyTableStoreRegistrationTests.TheExtensionRegistersTheSevenStoresEachOnceAndNothingElseStoredNamesTests.TheLiteralListsTheOtherTestsUseMatchTheProductionNames
The azurite:10002 row moved from accepted to refused, so it is not a new case.
A3 flow (worker, with-slot.sh slot 1). The 4 Azurite tests run against each connection string. A listener on the container's own non-loopback address, also bound on port 10002, counts connections.
| case | 1080de2 | control 56e0d98 |
|---|---|---|
| remote account | PASS: 4 skipped, 0 connections | PASS |
UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://<listener> |
PASS: 4 skipped, 0 connections | FAIL: 4 failed, 16 connections |
devstoreaccount1 + TableEndpoint=http://<listener>/… |
PASS: 4 skipped, 0 connections | FAIL: 4 failed, 16 connections |
card literal …ProxyUri=http://evil.example.test |
PASS: 4 skipped | FAIL: 4 failed; the client tried evil.example.test:10002 ("Name or service not known") |
card literal …TableEndpoint=https://evil.example.test/… |
PASS: 4 skipped | FAIL: 4 failed; the client tried evil.example.test:443 ("Name or service not known") |
E2E was not run because no Web or E2E file changed.
Summary
🎉 No failed tests in this run. Github Test Reporter by CTRF 💚 |
This was referenced Nov 26, 2026
Closed
mwg-bender Bot
added a commit
that referenced
this pull request
Nov 27, 2026
…d one-off edits (0.6.0 #268) Closes items 1 to 4 of the 0.6.0 spec-audit leftovers. - Zone-pinned list and details tests (#204 story 19): OccurrenceLocalTimeTests pins the browser zone to Kathmandu (UTC+05:45) and stores an Occurrence at its Series' UTC-04:00, then reads the time the Events list and the Event details dialog show. Dropping ToLocalTime() from either page turns its test red on any machine. - If-Match on one-off edits and cancel (#204 story 22): EventService.UpdateAsync and DeleteAsync take the Event's eTag and send it as If-Match as read (Azure's weak tags are not .NET-parsed), and send none when there is no tag. The edit dialog (a standalone Event, and This event only on an Occurrence) sends the tag of the Event it opened, Delete and This event only cancel send the row's tag, and Select Winner sends the tag of the Event the details dialog shows. A 409 goes through the existing message path. The Series cancel is unchanged: the list row holds no Series tag, so it sends none. - docs/api-validation.md: the test-class names #209 split or renamed. - AccessibleNamesTests uses PageActions.Pick instead of its own copy. Refs #268
mwg-bender Bot
added a commit
that referenced
this pull request
Nov 27, 2026
…d one-off edits (0.6.0 #268) (#270) ## Summary Items 1 to 4 of #268, the 0.6.0 spec-audit leftovers. Item 5 (splitting the five Web.Tests files over 400 lines) belongs to the next card and is not in this PR. | Item | Disposition | | --- | --- | | #268.1 zone-pinned list and details tests (#204 story 19) | DONE: `OccurrenceLocalTimeTests` (2 tests) | | #268.2 If-Match on cancel and one-off edits (#204 story 22) | DONE: `EventService` sends the Event's eTag; 10 tests in `EventIfMatchTests.cs` | | #268.3 stale test-class names in `docs/api-validation.md` | DONE: all 38 class names the file mentions now exist | | #268.4 duplicate `Pick` in `AccessibleNamesTests.cs` | DONE: uses `PageActions.Pick` (530 -> 524 lines) | | #268.5 Web.Tests files over 400 lines | OUTSIDE: next card | ## Cause (item 2) `EventService.UpdateAsync` and `DeleteAsync` sent no `If-Match`, although the API honours it on `PUT` and `DELETE api/events/{id}`. A one-off edit, a "This event only" edit or cancel, a plain Delete and Select Winner could therefore overwrite an Event another admin had saved in the meantime. The live control run below shows it: on plain `dev` a stale edit answered 200 and replaced the other admin's name. ## Change - `EventService.UpdateAsync(entity, ETag eTag = default)` and `DeleteAsync(id, ETag eTag = default)` send the tag as `If-Match` as read (`TryAddWithoutValidation`, the way `SeriesService.UpdateAsync` and `CommentClient` do, because Azure's weak tags are not .NET-parsed). A default tag sends no header, so a caller with no tag behaves as before. - The callers pass the tag they already hold: the edit dialog passes the tag of the Event it opened (a standalone Event, and This event only on an Occurrence); the Events page passes the row's tag on Delete and on This event only cancel; Select Winner passes the tag of the Event the details dialog shows. A 409 goes through the existing `ApiResult` message path, so no UX changed. - `SeriesService.DeleteAsync` (cancel all) is unchanged: the cancel runs from the list row, which holds no Series tag, and the card says to send no header where no tag is held. Its no-header behaviour is pinned by `TheSeriesCancel_SendsNoIfMatch`. - `docs/api-validation.md` (Test coverage): `CommentApiTests`, `RetiredCommentsFieldTests` and the unsplit `EventMetricsTests` / `ApiValidationRouteTests` coverage now name the classes #209 split them into. - `AccessibleNamesTests` drops its own `Pick` and uses `PageActions.Pick` (already imported with `using static`). ## Validation All numbers from cold builds (`clean-build.sh`, then build the slnx, then `test --no-build`), base `origin/dev` `3279277ac7b91a8e4de0e97454f90ce92b10432c`. | | Baseline | After | | --- | --- | --- | | Build | 0 errors, 0 warnings | 0 errors, 0 warnings | | Api.Tests | 911 passed + 2 skipped (913) | 911 passed + 2 skipped (913) | | Web.Tests | 1247 | **1259** (+12) | | E2E | 5 passed + 14 skipped (19) | 5 passed + 14 skipped (19) | No test was removed, renamed or rewritten. Added: `OccurrenceLocalTimeTests` (2), `EventEditIfMatchTests` (4), `EventDeleteAndWinnerIfMatchTests` (6). Red first: on `dev` 8 of the 10 If-Match tests failed (the two that pin "no tag, no header" pass on both). The item 1 tests pin behaviour `dev` already has, so their red comes from mutations. Mutations, each applied, run, then restored: | Mutation | Tests red | | --- | --- | | `EventList.razor`: drop `ToLocalTime()` | `TheList_ShowsTheOccurrencesTime_InTheBrowsersZone` | | `EventDetailsDialog.razor`: drop `ToLocalTime()` | `TheDetailsDialog_ShowsTheOccurrencesTime_InTheBrowsersZone` | | `EventService`: drop the If-Match header | 8 of 10 | | `EventEditDialog.Save.cs`: drop the edit's tag | 2 (standalone update, stale update) | | `EventEditDialog.razor.cs`: drop This event only's tag | 1 (This event only) | | `Events.razor`: drop the Delete's tag | 3 (Delete, This event only cancel, stale delete) | | `EventDetailsDialog.razor`: drop Select Winner's tag | 2 (Select Winner, stale Select Winner) | ### Live run (by the worker, Playwright headless Chromium on a `with-slot.sh` stack, browser zone Asia/Kathmandu) The script seeds a standalone Event and a weekly Series through the API, drives the UI, and records the headers of every write the browser sends. | Flow | Branch `fbf7e4f` | Control plain `dev` | | --- | --- | --- | | F1 Update Event on a standalone Event | PASS: `If-Match` = the listed eTag, 200 | FAIL: `If-Match` null | | F2 Update Event, This event only, on an Occurrence | PASS: the Occurrence's own eTag, 200, stored Modified, no Series PUT | FAIL: `If-Match` null | | F3 Delete, This event only (cancel one Occurrence) | PASS: the Occurrence's eTag, 204, row gone, no Series DELETE | FAIL: `If-Match` null | | F4 stale edit (the Event saved through the API after the list loaded) | PASS: 409, the dialog shows "The event was not saved. The request conflicts with the stored data. Reload and try again.", the other save kept | FAIL: no header, 200, the other admin's name overwritten | Branch SUMMARY pass=4 fail=0 error=0; control SUMMARY pass=0 fail=4 error=0. The control failures are the behaviour this PR changes, not a regression. Select Winner and the plain standalone Delete were covered by bUnit tests only, not in the live run. ## Notes - One commit by `MWG Bender[bot]` (author and committer). `Refs #268`: Nerd closes the issue by hand once item 5 has a disposition. - Observations (not fixed): none beyond item 5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the API and Api.Tests items of #194 (spec #205). Splits the five Api test files that were over the 400-line rule, pins the stored table and partition names, keeps the Azurite tests on local Azurite only, and makes the storage query test prove the filtering happens in storage.
Change
Largest Api test file afterwards: 361 lines (
SingleActivityApiTests, untouched).Azurite guard:
EM_AZURITE_CONNECTIONmust beUseDevelopmentStorage=true, or every endpoint must be on a loopback host (127.0.0.1, localhost, ::1), or it must namedevstoreaccount1together with its own endpoints. Otherwise the tests skip withAzurite test skipped: EM_AZURITE_CONNECTION does not point at local Azurite (...)before any client is built. Account settings with no endpoint (Azure public cloud) never count as local, whatever the account name.The
"activity-note:"hash salt and the namesActivityNoteConversion,ActivityNoteConversionStartupandactivity-notes-v1are unchanged. The salt derives the Comment ids, so changing it would add duplicate Comments on a re-run.Validation
Base
origin/dev2730911, cold builds (--no-incrementalafter deleting bin/obj):UseDevelopmentStorage=true) + running APICount preservation (by
[TestMethod]name, base vs head): 230 methods / 366 cases -> 235 / 385. Missing 0; moved unchanged 95; renamed 3 (...OldCommentsColumn...->...OldTextColumn...x2,RetiredCommentsFieldTests.AnOldCommentsValue...->RetiredOldTextFieldTests.AnOldTextValue...); added 5 methods / 19 cases (StoredNamesTests1,TableStoreRegistrationTests1,AzuriteSupportTests7 + 9 + 1).Break-it mutations, each applied, run, then restored. All 8 turned red:
TableNames.Games = "Game"->StoredNamesTestsredTableStoreRegistrationTestsredTableStoreRegistrationTestsredAzuriteSupportTests5 redConnection()no longer checks for local Azurite ->AzuriteSupportTests1 redAzuriteSupportTests1 redGetWhereAsyncreads the whole partition and filters in memory ->StorageQueryAzuriteTestsredStorageQueryAzuriteTestsred (raw-client check)The Azurite run left the account as it found it: same marker
CompletedUtc, and the same row count in every table before and after.Live flows (worker,
with-slot.shslot 0, Azurite + API):origin/devA2 list on both trees: Activities, ActivityComments, EventMetrics, Events, FeedbackLikes, FeedbackLinks, Games, Holidays, Themes. Themes and Holidays have no GET-one route, so A1 reads them through their list. E2E not run: no Web or E2E file changes.
Notes
EM_AZURITE_CONNECTION(needs.github/, moved to Nerd).Refsonly; Nerd closes chore(api): follow-ups from the review of the API, conversion tests and docs follow-ups (#191) #194 by hand once every item has a disposition.