yavsc/src/PostIt.Tests
Paul Schneider 03cd9843d3 PostIt/Yavsc.Blogs: surface 4xx body + pin controller + red UI test for Save
The 'Save' button in PostIt has been returning 400 from
/api/v1/blog ever since the editor's title and article fields
were re-bound to SelectedPost.Title / SelectedPost.Article.
The user types into the editor, taps Save, the controller
rejects with 'The Title field is required', and the PostIt
status bar shows only the generic 'Response status code does
not indicate success: 400' — no field name, no reason.

Three pieces here make the regression diagnosable and pin a
test for the fix:

1. YavscApiClient: replace EnsureSuccessStatusCode() at both
   call sites with a small helper that reads the response
   body and embeds it in the thrown HttpRequestException. The
   VM's existing catch (Exception) in ExecuteAsync forwards
   ex.Message to the status bar, so the next 'click Save'
   tells the user exactly which field the server rejected.

2. Yavsc.Blogs.Tests: two integration tests on the real
   controller (no HTTP mock) — one pins that a well-formed
   PostIt-shaped payload (Title + Article + AuthorId + dates,
   Id=0) is accepted with 201, the other pins that a payload
   with Title=string.Empty is rejected with 400. Together they
   pin the contract the VM has to honour.

3. PostIt.Tests: a red [AvaloniaFact] UI test that mounts
   MainPage inside a headless Window, types a title into the
   TextBox without first selecting a post in the list, taps
   Save, and asserts the body of the first POST contains
   the typed title. Today this test fails with Title='',
   reproducing the production 400. The matching fix (a
   Title/Article buffer on MainPageViewModel that the XAML
   binds to, and that Save uses to build the outgoing
   BlogPost) is the next commit; the test is the safety net.
2026-07-11 02:52:50 +01:00
..
BearerScopeTests.cs test(postit): pin blogs scope on bearer, fix post-refactor tests 2026-07-08 19:36:40 +01:00
BlogApiTestFakes.cs PostIt/Yavsc.Blogs: surface 4xx body + pin controller + red UI test for Save 2026-07-11 02:52:50 +01:00
Directory.Packages.props Split Directory.Packages.props: shared versions in root, per-product in src/ 2026-06-19 18:51:18 +01:00
FakeAuthorizingBrowser.cs Identity reloaded 2026-07-05 23:56:10 +01:00
MainPageSaveTests.cs PostIt/Yavsc.Blogs: surface 4xx body + pin controller + red UI test for Save 2026-07-11 02:52:50 +01:00
OidcStubAuthority.cs Identity reloaded 2026-07-05 23:56:10 +01:00
PostIt.Tests.csproj Exploiting GitVersion 2026-06-28 14:11:26 +01:00
PostItViewModelTests.cs test(postit): pin blogs scope on bearer, fix post-refactor tests 2026-07-08 19:36:40 +01:00
SchemeUrlDetectorTests.cs postit: traceable OIDC login UX + session persistence + 2nd-instance early exit 2026-06-27 12:47:52 +01:00
SessionStatusBannerTests.cs using Material.Avalonia 2026-07-09 23:28:46 +01:00
SettingsLoadTests.cs simpler 2026-07-08 23:16:16 +01:00
SignaturePadControlTests.cs a Signature Pad 2026-07-04 14:43:39 +01:00
SignaturePageViewModelTests.cs feat(postit): signature capture page (dev entry, file persistence) 2026-07-04 15:11:22 +01:00
TestApp.cs PostIt testing setup 2026-06-19 16:55:42 +01:00
UnitTest1.cs PostIt testing setup 2026-06-19 16:55:42 +01:00
YavscApiClientTests.cs test(postit): pin blogs scope on bearer, fix post-refactor tests 2026-07-08 19:36:40 +01:00