Adds IContentCrudService registration to UmbracoBuilder alongside IContentService. Both services are now resolvable from DI. Includes integration test verifying successful resolution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.8 KiB
5.8 KiB
date, researcher, git_commit, branch, repository, topic, tags, status, last_updated, last_updated_by, type
| date | researcher | git_commit | branch | repository | topic | tags | status | last_updated | last_updated_by | type | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2025-12-20T01:01:02+00:00 | Claude | f4a01ed50d |
refactor/ContentService | Umbraco-CMS | ContentService Refactoring Test Coverage Analysis |
|
complete | 2025-12-20 | Claude | implementation_strategy |
Handoff: ContentService Test Coverage Analysis for Refactoring
Task(s)
- Completed: Analyzed the ContentService refactoring design document
- Completed: Reviewed all existing ContentService test files
- Completed: Mapped existing test coverage to proposed service extraction
- Completed: Identified test coverage gaps
- Completed: Recommended test strategy for the refactoring
- Planned: Write specific tests for identified gaps (not started)
Critical References
docs/plans/2025-12-19-contentservice-refactor-design.md- The master refactoring design documenttests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentServiceTests.cs- Main test file (3707 lines, 91 tests)
Recent changes
No code changes made - this was a research/analysis session.
Learnings
Existing Test Coverage Summary
The ContentService has substantial existing test coverage across 6 test files:
| Test File | Tests | Focus Area |
|---|---|---|
ContentServiceTests.cs |
91 | Core CRUD, publishing, scheduling, hierarchy |
ContentServiceNotificationTests.cs |
8 | Saving/publishing notification handlers, culture variants |
ContentServicePublishBranchTests.cs |
10 | Branch publishing with various filters, variant/invariant content |
ContentServiceVariantTests.cs |
3 | Culture code casing consistency |
ContentServiceTagsTests.cs |
16 | Tag handling, invariant/variant transitions |
ContentServicePerformanceTest.cs |
8 | Bulk operations, caching performance |
Proposed Service Extraction (from design doc)
The design splits ContentService into 5 public services + 2 internal managers:
IContentCrudService- Create, Get, Save, DeleteIContentPublishOperationService- Publish, Unpublish, Scheduling, BranchIContentMoveService- Move, RecycleBin, Copy, SortIContentQueryService- Count, Paged queries, HierarchyIContentVersionService- Versions, Rollback, DeleteVersionsContentPermissionManager(internal)ContentBlueprintManager(internal)
Test Strategy Recommendation
Option A with targeted additions (recommended approach):
- Keep existing tests as primary safety net (they test via IContentService which becomes the facade)
- Add targeted tests for areas with new risk introduced by the refactoring
Identified Test Coverage Gaps
| Gap Area | Current State | Why It Matters |
|---|---|---|
| Notification ordering in orchestrated ops | No explicit test | MoveToRecycleBin must unpublish→move in correct sequence |
| Sort operation | No test exists | IContentMoveService.Sort() has no coverage |
| DeleteOfType/DeleteOfTypes | 1 test only | Complex orchestration: moves descendants to bin first |
| Permission operations | No tests | SetPermissions/SetPermission have zero coverage |
| Transaction boundaries | Implicit only | When services call each other, ambient scope must work |
| Lock coordination | No explicit test | Services acquiring locks within ambient scopes |
| CommitDocumentChanges internal | Limited | Culture unpublishing within this method not well tested |
| Independent service usage | N/A (new) | Consumers may inject services directly (e.g., IContentCrudService) |
Key Test File Locations
- Integration tests:
tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentServiceTests.cs - More integration tests:
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentService*Tests.cs - Unit tests referencing ContentService:
tests/Umbraco.Tests.UnitTests/(13 files, but mostly mock ContentService)
Artifacts
docs/plans/2025-12-19-contentservice-refactor-design.md- Design document (reviewed)- This handoff document
Action Items & Next Steps
- Write notification ordering tests - Verify
MoveToRecycleBinfiresContentUnpublishingNotificationbeforeContentMovingToRecycleBinNotification - Add Sort operation tests - Test
Sort(IEnumerable<IContent>)andSort(IEnumerable<int>)methods - Expand DeleteOfType tests - Verify descendant handling and notification ordering
- Add permission tests - Test
SetPermissionsandSetPermissionmethods - Add transaction boundary tests - Verify ambient scope behavior when services chain calls
- Consider independent service tests - Once services are extracted, add tests that use them directly (not via facade)
- Proceed with Phase 1 of refactoring - Extract
IContentCrudServicefirst (establishes patterns)
Other Notes
Test Infrastructure Observations
- Tests use
UmbracoIntegrationTestbase class withNewSchemaPerTestfor isolation ContentRepositoryBase.ThrowOnWarning = trueis set in many tests for strict validation- Custom notification handlers are registered via
CustomTestSetup(IUmbracoBuilder builder) - Tests use builder pattern extensively:
ContentTypeBuilder,ContentBuilder,TemplateBuilder
Key Methods That Need Careful Testing During Refactor
Per the design doc's Notification Responsibility Matrix (docs/plans/2025-12-19-contentservice-refactor-design.md:507-538):
MoveToRecycleBin- Orchestrated in Facade (unpublish + move)DeleteOfType/DeleteOfTypes- Orchestrated in Facade- All operations with cancellable notifications need pre/post verification
Design Doc Key Sections
- Service dependency diagram: lines 39-68
- Method mapping tables: lines 386-496
- Notification responsibility matrix: lines 507-538
- Transaction/scope ownership: lines 105-156