Files
museion/MuseionTests/SessionScopeTests.swift
T
AlexKucera 3a7d495b4b
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
feat(ui): design-council polish overhaul
Eight arbitrated rounds over the workspace surface: piece-scoped Mentor
hosting, conversation-voice system messages, glyph-measured roster
truncation, bounded learnings/archive columns, symmetric trends grid,
top-aligned settings forms, serif editor titles, outline rail rhythm,
launch auto-focus root fix. New seams pinned by SessionScopeTests +
WordBoundaryTruncationTests; full suite green.
2026-11-07 20:41:34 +01:00

42 lines
1.9 KiB
Swift

//
// SessionScopeTests.swift
// MuseionTests
//
// Owner ruling (2026-11-07): the Mentor pane hosts the OPEN PIECE's
// session — the pure seam over the roster (exact pieceTitle match,
// newest-first) pinned here: match, no-match, and title-with-no-roster.
//
import Foundation
@testable import Museion
import Testing
@Suite("SessionScopeTests")
struct SessionScopeTests {
/// The roster is newest-first (the model's own order), so the FIRST
/// exact pieceTitle match is the newest session for the piece. No
/// match — including near-misses, no open piece, or no roster at all —
/// hosts nothing: nil, the pane's honest empty presentation.
@Test func `hosted session id picks newest exact piece title match`() {
let older = SessionEntry(
sessionId: "s-old", name: "Old", pieceTitle: "Essay X",
createdAt: Date(timeIntervalSinceNow: -600),
)
let newer = SessionEntry(sessionId: "s-new", name: "New", pieceTitle: "Essay X", createdAt: Date())
let other = SessionEntry(sessionId: "s-other", name: "Other", pieceTitle: "Draft Y", createdAt: Date())
let roster = [newer, older, other] // newest-first, as the model keeps it
// Match — the newest session for the piece wins; a different piece
// finds its own.
#expect(SessionRoster.hostedSessionId(forOpenPieceTitle: "Essay X", in: roster) == "s-new")
#expect(SessionRoster.hostedSessionId(forOpenPieceTitle: "Draft Y", in: roster) == "s-other")
// No match — EXACT match only; near-misses never host.
#expect(SessionRoster.hostedSessionId(forOpenPieceTitle: "essay x", in: roster) == nil)
#expect(SessionRoster.hostedSessionId(forOpenPieceTitle: "Unwritten", in: roster) == nil)
// No open piece (draft, external guest, nothing) hosts nothing.
#expect(SessionRoster.hostedSessionId(forOpenPieceTitle: nil, in: roster) == nil)
// A title with no roster behind it hosts nothing.
#expect(SessionRoster.hostedSessionId(forOpenPieceTitle: "Essay X", in: []) == nil)
}
}