fix(blogposts): align author claims, publish checkbox, and seed schema#313
Conversation
…ession - Merge decision inbox into .squad/decisions.md (decisions 30-31) - Decision 30: Dark Mode Base Text Colours Must Contrast Against Dark Backgrounds (Legolas) - Decision 31: CSS Visual Regressions and Test/Visual Finding Arbitration (Aragorn) - Update Legolas history: UI regression review findings (Sprint 16 fan-out) - Update Gimli history: Blazor UI regression testing (Issue #292 coverage + visual findings) - Update Aragorn history: Issue triage (#292) and PR #295 arbitration workflow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…und 1) - Closed duplicate issue #294, merged PR #295 with all 19 CI checks green - Sprint-stamped issues #293 and #296 with title normalization - Removed go:needs-research from #293 (sufficient context), kept for #296 (Auth investigation needed) - Decision #32: PR self-authored approval pattern and Sprint triage workflow Co-authored-by: Boromir <lead-organizer@squad.local> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace old non-existent project ID (PVT_kwHOA5k0b84BVFTy) with new one (PVT_kwHOA5k0b84BXZpa) - Update STATUS_FIELD_ID to match new project (PVTSSF_lAHOA5k0b84BXZpazhSmuGY) - Map old status options to available field options (Backlog/InSprint: f75ad846, InReview: 47fc9ee4, Done: 98236657) - Use GH_PROJECT_TOKEN secret for GraphQL mutations (fallback to GITHUB_TOKEN) - Fixes issue where project board sync was failing silently due to missing project Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace token fallback with explicit GH_PROJECT_TOKEN requirement - Ensures workflows have required 'project' scope for user-owned project boards - Fixes 'Resource not accessible by integration' errors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Kept HEAD version with correct option IDs from board fix: - IN_SPRINT_OPTION_ID: f75ad846 - IN_REVIEW_OPTION_ID: 47fc9ee4 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t test - Edit.razor: null-value branch now navigates to /blog instead of leaving _model null (which caused infinite 'Loading...' state) - EditAclTests: added EditRedirectsToBlogWhenPostNotFound covering the Result.Ok(null) path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🏗️ PR Added to Squad Triage QueueThis PR has been labeled with Next steps:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the blog post creation/editing flow to (1) extract author identity from more appropriate claims, (2) support a new “Published” checkbox end-to-end (UI → commands → handlers), and (3) fix Aspire AppHost Mongo seed data to match the Mongo EF owned-type schema, with added handler tests for publish/unpublish paths.
Changes:
- Add
IsPublishedsupport to Create/Edit commands, handlers, and Razor forms (including publish/unpublish behavior in the edit handler). - Update claim extraction for author/caller identifiers to use
ClaimTypes.NameIdentifier(with fallbacks). - Fix AppHost seed data to store
Authoras an embedded document matching the Mongo EF owned-type mapping, and enable Mongo Express in the AppHost.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Web.Tests/Handlers/EditBlogPostHandlerTests.cs | Adds tests covering publish/unpublish behavior during edit. |
| tests/Web.Tests/Handlers/CreateBlogPostHandlerTests.cs | Adds tests ensuring created posts persist published/unpublished state correctly. |
| src/Web/Features/BlogPosts/Edit/EditBlogPostHandler.cs | Applies publish/unpublish operations during edit based on IsPublished. |
| src/Web/Features/BlogPosts/Edit/EditBlogPostCommand.cs | Extends edit command to include optional IsPublished. |
| src/Web/Features/BlogPosts/Edit/Edit.razor | Adds “Published” checkbox and updates caller id claim extraction. |
| src/Web/Features/BlogPosts/Create/CreateBlogPostHandler.cs | Publishes newly created posts when requested. |
| src/Web/Features/BlogPosts/Create/CreateBlogPostCommand.cs | Extends create command with IsPublished (default false). |
| src/Web/Features/BlogPosts/Create/Create.razor | Adds “Published” checkbox and updates author claim extraction with fallbacks. |
| src/AppHost/MongoDbResourceBuilderExtensions.cs | Fixes seed documents to store Author as an embedded document with expected field names. |
| src/AppHost/AppHost.cs | Enables Mongo Express alongside the MongoDB dev volume. |
| // Extract nameidentifier claim for AuthorId, with fallbacks for Development/Testing | ||
| _authorId = user.FindFirst(ClaimTypes.NameIdentifier)?.Value | ||
| ?? user.FindFirst("sub")?.Value | ||
| ?? user.Identity?.Name | ||
| ?? "dev-user"; | ||
| _authorName = user.FindFirst("name")?.Value ?? user.Identity?.Name ?? "Author"; | ||
| _authorEmail = user.FindFirst(ClaimTypes.Email)?.Value | ||
| ?? user.FindFirst("email")?.Value | ||
| ?? "no-email@example.com"; |
| // Extract nameidentifier claim for AuthorId, with fallbacks for Development/Testing | ||
| _authorId = user.FindFirst(ClaimTypes.NameIdentifier)?.Value | ||
| ?? user.FindFirst("sub")?.Value | ||
| ?? user.Identity?.Name | ||
| ?? "dev-user"; | ||
| _authorName = user.FindFirst("name")?.Value ?? user.Identity?.Name ?? "Author"; | ||
| _authorEmail = user.FindFirst(ClaimTypes.Email)?.Value | ||
| ?? user.FindFirst("email")?.Value | ||
| ?? "no-email@example.com"; | ||
| _authorRoles = RoleClaimsHelper.GetRoles(user); | ||
|
|
||
| // If still empty, generate sensible defaults for Development mode | ||
| if (string.IsNullOrWhiteSpace(_authorId)) | ||
| { | ||
| _authorId = $"auth0|dev-{Guid.NewGuid().ToString().Substring(0, 8)}"; | ||
| } |
| var authState = await AuthStateProvider.GetAuthenticationStateAsync(); | ||
| var user = authState.User; | ||
| _callerUserId = user.FindFirst("sub")?.Value ?? string.Empty; | ||
| _callerUserId = user.FindFirst(ClaimTypes.NameIdentifier)?.Value | ||
| ?? user.FindFirst("sub")?.Value | ||
| ?? string.Empty; | ||
| _callerIsAdmin = user.IsInRole("Admin"); |
Test Results Summary369 tests +4 367 ✅ +3 19s ⏱️ ±0s For more details on these failures, see this check. Results for commit 8cce6ef. ± Comparison against base commit dc34ce9. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #313 +/- ##
==========================================
- Coverage 83.67% 83.46% -0.22%
==========================================
Files 47 47
Lines 1256 1300 +44
Branches 152 157 +5
==========================================
+ Hits 1051 1085 +34
- Misses 146 153 +7
- Partials 59 62 +3
🚀 New features to boost your workflow:
|
✅ Aragorn Gate — ApprovedTest gate: All 375 tests pass across all suites (Domain.Tests, Architecture.Tests, Web.Tests, Web.Tests.Bunit, Web.Tests.Integration, AppHost.Tests). Architectural AssessmentCQRS / MediatR alignment ✅ Domain model usage ✅ Result error handling ✅ File headers ✅ Seed schema fix ✅ Copilot comments addressed (disposition):
No ADR required — bug-fix + additive feature on an existing pattern; no new architectural decision introduced. Follow-up issue recommended: Extract a shared |
) Merged decision inbox entries: - Decision 32: OnParametersSetAsync state reset pattern (Aragorn) - Decision 33: Cached state field reset (Aragorn) - Decision 34: UserIdClaimsHelper recommendation (Aragorn) - Decision 35: Rich Text Editor architectural plan (Aragorn) - Decision 36: bUnit 2.x re-render API (Gimli) - Decision 37: Display state reset pattern (Legolas) - Decision 38: RTBlazorfied editor selection (Legolas) - Decision 39: Loading-state reset + bUnit API (Sam) Also updated Directory.Packages.props: - MongoDB.Driver: 3.8.0 → 3.8.1 - Fixed stale SharpCompress transitive dependency comment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary\n- align Blog Post author claim extraction to nameidentifier/emailaddress claims with safe fallbacks\n- add IsPublished checkbox behavior (default false) through Create/Edit forms, commands, and handlers\n- fix AppHost seed author field names to match Mongo EF mapping and prevent missing Id document errors\n- add handler tests for publish/unpublish paths\n\nCloses #311