Testing: cover the attributes-to-specialUse wiring; fix FolderLabelsTest fixture fidelity claim #64

Closed
opened 2026-07-01 21:17:32 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-01 21:17:32 +00:00 (Migrated from github.com)

Origin: code review of PR #54. Two test gaps in the folder-label feature, verified by mutation analysis.

1. The attributes → specialUse wiring has zero coverage

The single production link between server data and the feature — toEntity's specialUse = FolderRole.isServerSpecial(attributes) (Mappers.kt:163) and toDomain's pass-through (Mappers.kt:153) — is never executed with meaningful values by any test:

  • FetchedFolder appears in zero test files; every listFolders stub returns emptyList().
  • All other tests hand-set specialUse on their own layer (FolderRoleTest tests the predicate, LibreMailDatabaseTest the DAO column, FolderLabelsTest/FolderDrawerTest the domain/UI).

Mutation-verified: delete Mappers.kt:163 and everything compiles via FolderEntity's specialUse = false default; refreshFolders persists 0 for every folder, the provider-suffix branch goes dead, real Gmail accounts regress to "Drafts ([Gmail])" — while assembleDebug, testDebugUnitTest, and connectedDebugAndroidTest all stay green.

Fix: a ~12-line MailRepositoryImplTest case — stub imapClient.listFolders with FetchedFolder("[Gmail]/Drafts", "Drafts", listOf("\\Drafts"), selectable = true) plus an attribute-less folder, slot-capture folderDao.replaceForAccount, assert persisted specialUse == [true, false]. Optionally assert specialUse in the existing observeFolders test for the toDomain leg.

2. FolderLabelsTest's fixture claims fidelity nothing enforces

baseLabelsOf's doc comment (FolderLabelsTest.kt:31) says it builds labels "the way the drawer does", but it's a hand-copied mirror of folderDisplayLabel with hardcoded English literals. A wording change to folder_archive/folder_spam/folder_trash (or a new folderDisplayLabel branch) leaves the suite green against the stale copy — and the androidTest fixtures use displayName == friendly name for those roles, so they can't discriminate drift either.

Fix: drop the fidelity claim (state it's an independent literal fixture) or inline expected literals per test; optionally add one androidTest fixture where displayName ≠ friendly name for ARCHIVE/SPAM/TRASH.

Origin: code review of PR #54. Two test gaps in the folder-label feature, verified by mutation analysis. ## 1. The attributes → specialUse wiring has zero coverage The single production link between server data and the feature — `toEntity`'s `specialUse = FolderRole.isServerSpecial(attributes)` (`Mappers.kt:163`) and `toDomain`'s pass-through (`Mappers.kt:153`) — is never executed with meaningful values by any test: - `FetchedFolder` appears in **zero** test files; every `listFolders` stub returns `emptyList()`. - All other tests hand-set `specialUse` on their own layer (`FolderRoleTest` tests the predicate, `LibreMailDatabaseTest` the DAO column, `FolderLabelsTest`/`FolderDrawerTest` the domain/UI). Mutation-verified: delete `Mappers.kt:163` and everything compiles via `FolderEntity`'s `specialUse = false` default; `refreshFolders` persists 0 for every folder, the provider-suffix branch goes dead, real Gmail accounts regress to "Drafts ([Gmail])" — while `assembleDebug`, `testDebugUnitTest`, and `connectedDebugAndroidTest` all stay green. **Fix:** a ~12-line `MailRepositoryImplTest` case — stub `imapClient.listFolders` with `FetchedFolder("[Gmail]/Drafts", "Drafts", listOf("\\Drafts"), selectable = true)` plus an attribute-less folder, slot-capture `folderDao.replaceForAccount`, assert persisted `specialUse == [true, false]`. Optionally assert `specialUse` in the existing `observeFolders` test for the `toDomain` leg. ## 2. FolderLabelsTest's fixture claims fidelity nothing enforces `baseLabelsOf`'s doc comment (`FolderLabelsTest.kt:31`) says it builds labels "the way the drawer does", but it's a hand-copied mirror of `folderDisplayLabel` with hardcoded English literals. A wording change to `folder_archive`/`folder_spam`/`folder_trash` (or a new `folderDisplayLabel` branch) leaves the suite green against the stale copy — and the androidTest fixtures use `displayName == friendly name` for those roles, so they can't discriminate drift either. **Fix:** drop the fidelity claim (state it's an independent literal fixture) or inline expected literals per test; optionally add one androidTest fixture where displayName ≠ friendly name for ARCHIVE/SPAM/TRASH.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#64