---
phase: 02-permissions
plan: 01
subsystem: testing
tags: [xunit, tdd, permissions, csom, csv-export, html-export, classification]

requires:
  - phase: 01-foundation
    provides: OperationProgress model, xUnit test infrastructure, AsyncRelayCommand patterns

provides:
  - PermissionEntryHelper static helper (IsExternalUser, FilterPermissionLevels, IsSharingLinksGroup)
  - 5 test scaffold files covering PERM-01 through PERM-06
  - Classification tests (7 green) validating pure-function helper logic
  - Export service stubs (CsvExportService, HtmlExportService) — NotImplementedException placeholders for Plan 03
  - PermissionsService compile fixes (Principal.Email removed, folder param corrected to ListItem)

affects: [02-02, 02-03, 02-04, 02-06]

tech-stack:
  added: []
  patterns:
    - "Test scaffold: skipped stubs for CSOM-dependent tests, real [Fact] for pure-function tests"
    - "Export service stubs with NotImplementedException — replaced in Plan 03"
    - "PermissionEntryHelper: pure static classification logic, no dependencies"

key-files:
  created:
    - SharepointToolbox/Core/Helpers/PermissionEntryHelper.cs
    - SharepointToolbox.Tests/Services/PermissionsServiceTests.cs
    - SharepointToolbox.Tests/ViewModels/PermissionsViewModelTests.cs
    - SharepointToolbox.Tests/Services/PermissionEntryClassificationTests.cs
    - SharepointToolbox.Tests/Services/Export/CsvExportServiceTests.cs
    - SharepointToolbox.Tests/Services/Export/HtmlExportServiceTests.cs
    - SharepointToolbox/Services/Export/CsvExportService.cs
    - SharepointToolbox/Services/Export/HtmlExportService.cs
  modified:
    - SharepointToolbox/Services/PermissionsService.cs

key-decisions:
  - "Export service stubs created in Plan 02-01 (not Plan 03) so test project compiles before implementation"
  - "PermissionEntryHelper placed in main project Core/Helpers — pure static, no coupling to test project"
  - "Principal.Email removed from CSOM load expression — Email only exists on User (CSOM Principal subtype), not Principal base"
  - "folder param in GetFolderPermissionsAsync changed to ListItem (SecurableObject) instead of Folder (not a SecurableObject)"

patterns-established:
  - "Skip-stub pattern: CSOM-dependent tests use [Fact(Skip=...)] so they compile and report in test count without requiring live SharePoint"
  - "Pure-function tests: no Skip needed for static helper logic — run immediately and validate contracts"

requirements-completed: [PERM-01, PERM-02, PERM-03, PERM-04, PERM-05, PERM-06]

duration: 5min
completed: 2026-04-02
---

# Phase 2 Plan 1: Wave 0 Test Scaffold Summary

**PermissionEntryHelper static classification helpers plus 5 test scaffold files covering PERM-01 through PERM-06, with 7 immediately-passing classification tests and 6 stub/skip tests waiting on Plan 02/03 implementations**

## Performance

- **Duration:** 5 min
- **Started:** 2026-04-02T11:48:37Z
- **Completed:** 2026-04-02T11:53:52Z
- **Tasks:** 2
- **Files modified:** 9

## Accomplishments

- `PermissionEntryHelper.cs` with `IsExternalUser`, `FilterPermissionLevels`, and `IsSharingLinksGroup` — pure static, 7 tests green immediately
- 5 test scaffold files created covering PERM-01 through PERM-06 (PERM-07 covered by Phase 1)
- `CsvExportService` and `HtmlExportService` stub placeholders so export tests compile now; full implementation deferred to Plan 03
- Fixed two pre-existing compile errors in `PermissionsService.cs`: removed `Principal.Email` (only on `User`) and corrected folder param to `ListItem` (a `SecurableObject`)

## Task Commits

Each task was committed atomically:

1. **Task 1: Scaffold PermissionsService, ViewModel, and classification test stubs** - `a9f6bde` (test)
2. **Task 2: Scaffold export service test stubs** - `83464a0` (test)
3. **Rule 3 + Rule 1 - Service stubs and PermissionsService bug fixes** - `9f2e2f9` (fix)

## Files Created/Modified

- `SharepointToolbox/Core/Helpers/PermissionEntryHelper.cs` — IsExternalUser, FilterPermissionLevels, IsSharingLinksGroup static helpers
- `SharepointToolbox.Tests/Services/PermissionsServiceTests.cs` — 2 skipped stubs (PERM-01, PERM-04)
- `SharepointToolbox.Tests/ViewModels/PermissionsViewModelTests.cs` — 1 skipped stub (PERM-02)
- `SharepointToolbox.Tests/Services/PermissionEntryClassificationTests.cs` — 7 real [Fact] tests (PERM-03)
- `SharepointToolbox.Tests/Services/Export/CsvExportServiceTests.cs` — 3 real [Fact] tests (PERM-05), fail until Plan 03
- `SharepointToolbox.Tests/Services/Export/HtmlExportServiceTests.cs` — 3 real [Fact] tests (PERM-06), fail until Plan 03
- `SharepointToolbox/Services/Export/CsvExportService.cs` — NotImplementedException stub so export tests compile
- `SharepointToolbox/Services/Export/HtmlExportService.cs` — NotImplementedException stub so export tests compile
- `SharepointToolbox/Services/PermissionsService.cs` — Bug fixes: removed Principal.Email, corrected Folder→ListItem param

## Decisions Made

- Export service stubs created in Plan 02-01 so that the test project compiles. Without stubs, the export test files cause CS0234 (namespace not found) blocking ALL tests from running. Plan 03 replaces the stubs with real implementations.
- `PermissionEntryHelper` placed in main project `Core/Helpers` — it's shared logic used by both `PermissionsService` (production) and tests. Keeping it in the main project avoids any test→production dependency inversion.

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 3 - Blocking] Created CsvExportService and HtmlExportService stubs**
- **Found during:** Task 2 (export test scaffold)
- **Issue:** Export test files reference `SharepointToolbox.Services.Export.*` which doesn't exist yet, causing CS0234 compilation failures that block all tests
- **Fix:** Created `Services/Export/CsvExportService.cs` and `Services/Export/HtmlExportService.cs` with `NotImplementedException` stubs matching the method signatures from the `<interfaces>` block
- **Files modified:** SharepointToolbox/Services/Export/CsvExportService.cs, SharepointToolbox/Services/Export/HtmlExportService.cs
- **Verification:** `dotnet build` succeeds; test project compiles
- **Committed in:** `9f2e2f9`

**2. [Rule 1 - Bug] Fixed Principal.Email in PermissionsService CSOM load expression**
- **Found during:** Task 2 (first full build after adding export stubs)
- **Issue:** `ra.Member.Email` causes CS1061 — `Principal` doesn't have `Email` (only `User` does)
- **Fix:** Removed `ra.Member.Email` from the CSOM Include expression; `UserLogins` uses `LoginName` which is on `Principal`
- **Files modified:** SharepointToolbox/Services/PermissionsService.cs
- **Verification:** Build succeeds, no CS1061
- **Committed in:** `9f2e2f9`

**3. [Rule 1 - Bug] Fixed Folder→ListItem parameter in GetFolderPermissionsAsync**
- **Found during:** Task 2 (same build)
- **Issue:** `ExtractPermissionsAsync` expects `SecurableObject`; `Folder` is not a `SecurableObject` (CS1503). The `ListItem` variable (`item`) IS a `SecurableObject`.
- **Fix:** Changed `folder` argument to `item` in the `ExtractPermissionsAsync` call; `folder` is still loaded for URL/name metadata
- **Files modified:** SharepointToolbox/Services/PermissionsService.cs
- **Verification:** Build succeeds, no CS1503
- **Committed in:** `9f2e2f9`

---

**Total deviations:** 3 auto-fixed (1 blocking, 2 bugs)
**Impact on plan:** All auto-fixes required for test compilation. Bugs 2 and 3 were pre-existing in PermissionsService.cs from a prior plan execution. No scope creep — stubs and bug fixes are minimal correctness work.

## Issues Encountered

- `SiteListServiceTests.cs` (from commit `5c10840`) had a spurious compilation error on first build pass, but resolved after fresh `dotnet build` — likely stale obj/ cache. No action needed.
- Export service stubs throw `NotImplementedException` at runtime, causing 6 test failures in the suite. This is the expected state until Plan 03.

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness

- Classification helper and test scaffold complete — Plan 02-02 can create interfaces/models with tests already waiting
- Export service stubs in place — Plan 03 can replace `throw new NotImplementedException()` with real implementations, making the 6 failing export tests turn green
- `PermissionsService.cs` compile errors fixed — Plan 02-04 (PermissionsViewModel) and 02-06 (integration) can build immediately

## Self-Check: PASSED

All 9 key files verified present on disk. All 3 task commits (a9f6bde, 83464a0, 9f2e2f9) confirmed in git log.

---
*Phase: 02-permissions*
*Completed: 2026-04-02*
