CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
Three-reviewer audit of the polish overhaul: - magnifyinglass -> magnifyingglass (blank SF Symbol, all 3 seats) - WordBoundaryTruncation.fit measures each word once (O(n^2) -> O(n) on pathological imported titles; live-title pins unchanged) - scopeHostedSession defers behind an in-flight replay instead of refusing (automatic actions never leak a 'Resume refused' row); replay completion re-fires the pending scope — pinned over the real client path with loadReplayHold, flip-verified - transcript ForEach on stable row ids, not indices - delete dead softBorder param; fold caretPastLeadingBlanks onto firstContentLocation; native TextField prompt for the search field - ElidedPathText.candidates/elide nonisolated (off-actor first(where:) trapped the host); new pins: degenerate truncation shapes, firstContentLocation, elide ladder
48 lines
2.0 KiB
Swift
48 lines
2.0 KiB
Swift
//
|
|
// PolishSeamTests.swift
|
|
// MuseionTests
|
|
//
|
|
// Finish-audit pins for the ui-polish loop's pure seams that shipped
|
|
// "so a test can pin" them but no pin landed: the editor's
|
|
// first-content walker (title detection + the caret hop ride it) and
|
|
// the settings path elision ladder.
|
|
//
|
|
|
|
import Foundation
|
|
@testable import Museion
|
|
import Testing
|
|
|
|
@Suite("PolishSeamTests")
|
|
struct PolishSeamTests {
|
|
/// Leading blank lines are skipped to the first CONTENT line; a
|
|
/// whitespace-only buffer has none (nil); a buffer with no leading
|
|
/// blanks returns 0. The same walker styles the title line and hops
|
|
/// programmatic carets past the invisible blank fragment.
|
|
@Test func `firstContentLocation skips leading blanks`() {
|
|
let plain = "Title\n\nbody" as NSString
|
|
#expect(ProsePresenter.firstContentLocation(plain) == 0)
|
|
let blankLead = "\n\n \nTitle\nbody" as NSString
|
|
let loc = ProsePresenter.firstContentLocation(blankLead)
|
|
#expect(loc == 5) // three leading blank lines (5 UTF-16 units incl. newline) before "Title"
|
|
#expect(ProsePresenter.firstContentLocation("" as NSString) == nil)
|
|
#expect(ProsePresenter.firstContentLocation("\n \n\t\n" as NSString) == nil)
|
|
}
|
|
|
|
/// The ladder keeps the full path, then each shorter variant with one
|
|
/// more leading component kept whole; ≤2 components has nothing to
|
|
/// elide. `elide` picks the longest candidate that fits.
|
|
@Test func `ElidedPathText candidate ladder and elision`() {
|
|
let path = "/Users/alex/Library/Mobile Documents/com~apple~CloudDocs/Museion"
|
|
let ladder = ElidedPathText.candidates(path)
|
|
#expect(ladder.first == path)
|
|
#expect(ladder.last == "/Users/…/Museion")
|
|
#expect(ladder.count == path.split(separator: "/").count - 1)
|
|
// Short paths never elide.
|
|
#expect(ElidedPathText.candidates("/a/b") == ["/a/b"])
|
|
// A wide-enough field keeps the full path; a narrow one falls to
|
|
// the shortest rung.
|
|
#expect(ElidedPathText.elide(path, into: 5000) == path)
|
|
#expect(ElidedPathText.elide(path, into: 10) == "/Users/…/Museion")
|
|
}
|
|
}
|