CI / ci (push) Canceled after 0s
Variant B per the #104 prototype verdict: the library column groups pieces by project (serif lowercase heads, collapse toggle, Pass-State groups inside, 2px edge-bar selection shared with the new Archive pane via LibraryPostRow). Move to Project / Archive / Move Back / whole-project Unarchive are folder moves — post.md bytes untouched, never clobbering, ids globally unique. File ▸ New Post ⌘N and New Project… ⌥⌘N (CommandGroup, never CommandMenu per #84). Every folder move flushes pending edits first and aborts when the write failed — nothing moves without its text. Project membership and the archived-refusal derive from freshly resolved disk paths, never the scan snapshot. Slug and project-name comparisons fold through one canonical key (NFC + lowercase). Two reviewer fanouts this session; their findings are all fixed or visibly parked. 144/144 tests green (run twice), swiftformat/swiftlint clean. Closes #108
7.1 KiB
7.1 KiB
MuseionTests
Purpose
Unit tests for the Museion application target, hosted in the app process (TEST_HOST).
Ownership
Owned by the root AGENTS.md contract.
Local Contracts
- Uses Swift Testing (
@Test,#expect) — not XCTest. - Imports
@testable import Museion; app code is default-MainActor, so cross-actor tests need@MainActoror nonisolated declarations in app code. - Deployment target and versions follow the app target; leave
CURRENT_PROJECT_VERSION = 1here.
Work Guidance
- Non-trivial logic leaves one runnable check behind: the smallest test that fails if the logic breaks. No fixtures or per-function suites unless asked.
EngineGateTests.swiftbuilds fakehermesshell scripts in temp dirs and runs them through the realProcesspath — copy that pattern for any future child-process testing.ACPClientTests.swiftextends it into a full fake ACP server: a zsh script speaking real NDJSON JSON-RPC over stdio (makeFakeACP), with a per-binary mode file (crashAfterHandshake,hangOnPrompt, default full) and a base64-encoded fix-card payload — shell quoting can never break the wire JSON. OnlyacpTempDirremains as a helper; crash assertions use Swift Testing'sconfirmation(hook the callback BEFORE triggering the crash).makeStrictFakeACP(same file) guardssession/newthe way adapter ≥0.21.5 does — rejecting a missingmcpServerswith-32602— pinning the wire contract the lenient fake can't catch.ProfileProvisionerTests.swiftextends it: the fake creates the profile at<binaryDir>/profiles/<name>(self-locating, race-free under parallel tests); payload dirs are built at runtime; the bundled-payload test asserts manifest ↔ payload correspondence. #48 failure-path tests live inProfileProvisionerFailureTests.swift(own file — Not-Now defer + re-fail, config.yaml byte-identity + fresh-profile no-config (mcp_servers negative invariant), state.json engine-gate-only, copy-phase catch branch, path-traversal rejection, orphaned-temp sweep). Shared helpers (makeFakeHermes,makePayload,defaultSkills,provTempDir) are internal inProfileProvisionerTests.swift.ProfileBackupTests.swift(own helpersbackupTempDir/makeProfileFixture) injects profile/backups roots, a fixed clock, and apsScanstub — a dev machine may run the real engine, so the ps scan is never trusted in tests.PostLibraryTests.swift(#17, #107) — throwaway Homes viamakeHome/writePiece/writePostin temp dirs: bare corpus posts (First Draft/writer defaults), lenient + quoted frontmatter (pass_state/origin/type), two-level scan acrossprojects/<name>/<id>/+archive/<name>/<id>/(project/isArchived stamped, noise at both levels), lazy folders / hidden dirs / symlinks not surfacing, localizedStandardCompare title sort,untitlededges (blank, marker-only, unterminated frontmatter), leading-blank-line frontmatter, default Home =~/Documents/Museion.PostStoreTests.swift(#18, #107) — write side viastoreHome/readPost(same temp-dir pattern): slug algorithm cases (diacritics, CJK, cap, punctuation-only → untitled), lazy first write intoprojects/<name>/<id>/+ #59 stamp (type first) round-trip throughPost.scan, untitled fallback, case-insensitive collision suffixes over the GLOBAL slug space (projects + archive; archived slugs never reused),writeNew(project:)routing, rename (retitle + move within the same project, archived stays archived, insert-title path, same-slug retitle-only, collision -2), trash removes from projects/ and archive/, overwrite preservation + bare-post normalization,readBodystripping, blocked-project failure path. #108: project moves —readPiece(home:root:project:id:)path-aware helper; move (byte-identity, same-project no-op), archive/restore round-trip, archived-move refusal,unarchiveProjectfresh + merge cases (dot-entries skipped),createProjectvalidation matrix (duplicate case-insensitive + NFD twin, empty/slash/dot/:rejected), hidden user folders survive unarchive (source removed only when emptied),unarchiveProjectmodel test (dirty open piece flushes before the move). Fold pin: decomposed-jamo folder on disk vs a precomposed title →-2(Swift==/Set already fold canonical equivalence — the premise asserts byte inequality;foldedis the explicit, tested contract).PostsModelTests.swift(#108 audits) — the model-layer lifecycle the store tests can't see, viamakeModelHome(direct@MainActormodel over a temp home): archive-open-piece clears selection+session, moveToProject reopens the session at the newfolderURL, restore reopens off the archive path, New Project's draft lands in the named project, abandoning a draft for an external file dropspendingProject, unarchive of a dirty open piece flushes before the folder move,moveTargetslists empty projects from disk (default included).EditorSessionTests.swift(#19) — session mechanics viamakeSessionHome/seedPost: debounce → flush + sidecar round-trip, clean-flush no-op + ⌘S immediate, #67 conflict (echo suppressed, Yes-reload, No-keep-local → overwrite), write failure →.failed+ retry.ReadingPresenterTests.swift(#76, ADR-0011) — apex HTML pipeline coverage with inline fixture strings: chunker sentinel stamping, stamper attribute rewrite (multi-digit),blocks(for:)line↔range map (monotonic, 1-based lines, exact chunk offsets — the click→edit map), pipeline tests running the REAL bundled apex binary (headings/inline marks,1. 1. 1.renumber via native<ol>, mixed-lists stay split, table/quote/fence/link/HR constructs with exactdata-source-linestamps, base64 image embed againstspike/prose, native footnotes), fallback = escaped source, stylesheet carries the slot CSS vars.ProsePresenterTests.swift(#77) — editing-surface parity pinned: heading ladder sizes (30/22/19/17-bold), half-height blanks (9pt), quote secondary-ink + indent, fence interior mono-14, inline traits (bold/italic/code/link underline + dimmed marks), CSS-1.8 leading calibration tolerance, CommonMark intraword-underscore rule, reattribute with fence-state retrofit.FocusModeTests.swift(#21, map #21) — soft-centering band math pinned: in-band no-op, below-band recenter down, above-band recenter up, document-bottom clamp (parks, then no-ops while parked — no jump), short-document floor at 0.ImportExternalTests.swift(#22, map #22) — import + external buffer viaimportHome/writeExternal(temp-dir convention): #95 frontmatter merge (external keys verbatim, our keys win — externaltype: outlineoverwritten totype: post, original untouched), CRLF file normalized at the boundary (block detected, keys stamped, LF body), bare file → fresh block + #60 collision suffixes, empty file →untitled, unreadable file (UTF-16) →loadFailed, nothing written, original untouched, external session saves in place with NO sidecar (#93), #67 conflict raised on a foreign write + Yes-reload. Imports land atprojects/posts/<id>/post.md(#107).
Verification
xcodebuild -project Museion.xcodeproj -scheme Museion -destination 'platform=macOS' -only-testing:MuseionTests test
Child DOX Index
- None — flat directory.