test(folders): cover attributes-to-specialUse wiring; fix FolderLabelsTest fidelity claim #113

Merged
JMR-dev merged 1 commits from test-specialuse-wiring into main 2026-07-02 07:36:33 +00:00
JMR-dev commented 2026-07-02 07:25:53 +00:00 (Migrated from github.com)

Closes #64.

Addresses the two test gaps flagged in PR #54's review (mutation-verified in the ticket).

1. Attributes -> specialUse wiring now has coverage

The one production link between a server LIST response and the folder feature was never exercised with meaningful values:

  • FetchedFolder.toEntity deriving role (via FolderRole.roleOf) and specialUse (via FolderRole.isServerSpecial) from IMAP attributes (Mappers.kt), and
  • FolderEntity.toDomain's specialUse pass-through.

Every listFolders stub returned emptyList(), and other suites hand-set specialUse on their own layer, so deleting the specialUse assignment compiled and silently persisted a non-special folder for every folder.

  • New FolderMapperTest pins each RFC 6154 attribute to its expected (role, specialUse) through FetchedFolder.toEntity: \Sent/\Drafts/\Junk/\Trash/\Archive both classify the role and mark the folder special; \All/\Flagged mark it special but drive no role of their own; non-special / structural flags stay unmarked; and toDomain carries the flag back out.
  • New MailRepositoryImplTest.refreshFolders case stubs imapClient.listFolders with a \Drafts special folder plus an attribute-less user folder, slot-captures folderDao.replaceForAccount, and asserts persisted specialUse == [true, false] (and roles).
  • Extended observeFolders test asserts the toDomain special-use leg.

2. FolderLabelsTest fidelity claim corrected

baseLabelsOf's doc comment claimed it builds labels "the way the drawer does", but it is a hand-copied literal stand-in for folderDisplayLabel (which is @Composable and can't run in a JVM test). Reworded to state it is an independent literal fixture that pins the de-duplication logic, not the role-to-wording mapping. FolderDrawerTest now gives ARCHIVE a server name (All Mail) that differs from its friendly label so it can actually discriminate role-to-label drift.

Notes

  • The mapping itself was correct, only uncovered -- no production code changed. The attribute-to-role table refactor is out of scope (issue #65).
  • Fast CI gate green locally (JDK 21): assembleDebug, testDebugUnitTest, lintDebug, ktlintCheck, detekt, and compileDebugAndroidTestKotlin all pass. New tests: FolderMapperTest 6/6; MailRepositoryImplTest 24/24.

🤖 Generated with Claude Code

Closes #64. Addresses the two test gaps flagged in PR #54's review (mutation-verified in the ticket). ## 1. Attributes -> specialUse wiring now has coverage The one production link between a server LIST response and the folder feature was never exercised with meaningful values: - `FetchedFolder.toEntity` deriving `role` (via `FolderRole.roleOf`) and `specialUse` (via `FolderRole.isServerSpecial`) from IMAP attributes (`Mappers.kt`), and - `FolderEntity.toDomain`'s `specialUse` pass-through. Every `listFolders` stub returned `emptyList()`, and other suites hand-set `specialUse` on their own layer, so deleting the `specialUse` assignment compiled and silently persisted a non-special folder for every folder. - **New `FolderMapperTest`** pins each RFC 6154 attribute to its expected `(role, specialUse)` through `FetchedFolder.toEntity`: `\Sent`/`\Drafts`/`\Junk`/`\Trash`/`\Archive` both classify the role and mark the folder special; `\All`/`\Flagged` mark it special but drive no role of their own; non-special / structural flags stay unmarked; and `toDomain` carries the flag back out. - **New `MailRepositoryImplTest.refreshFolders` case** stubs `imapClient.listFolders` with a `\Drafts` special folder plus an attribute-less user folder, slot-captures `folderDao.replaceForAccount`, and asserts persisted `specialUse == [true, false]` (and roles). - **Extended `observeFolders` test** asserts the `toDomain` special-use leg. ## 2. FolderLabelsTest fidelity claim corrected `baseLabelsOf`'s doc comment claimed it builds labels "the way the drawer does", but it is a hand-copied literal stand-in for `folderDisplayLabel` (which is `@Composable` and can't run in a JVM test). Reworded to state it is an independent literal fixture that pins the de-duplication logic, not the role-to-wording mapping. `FolderDrawerTest` now gives ARCHIVE a server name (`All Mail`) that differs from its friendly label so it can actually discriminate role-to-label drift. ## Notes - The mapping itself was correct, only uncovered -- **no production code changed**. The attribute-to-role table refactor is out of scope (issue #65). - Fast CI gate green locally (JDK 21): `assembleDebug`, `testDebugUnitTest`, `lintDebug`, `ktlintCheck`, `detekt`, and `compileDebugAndroidTestKotlin` all pass. New tests: FolderMapperTest 6/6; MailRepositoryImplTest 24/24. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.