Land Finder file drops positionally, header release topmost
04's settled clauses were mostly shipped already — the create landing resolved through DropSlotMath.cardSlot with one nominal shadow per importable file — but a release on the lane header fell through to the card zones, which clamp inward, so a scrolled lane could propose behind the header stripe. FileDropZones now folds header, attach hit-test, and card-slot resolution into one pure seam asked in that order, the header answering topmost per the ruling; lane headers register their frames for it. FinderDrop.shadowCount names the floor-at-one rule. New tests pin the header boundary, a differential against cardSlot's own zones (same zones, not similar), and a store-level differential proving a file landing takes the very ranks a card move there takes. Claude-Session: https://claude.ai/code/session_01SR4XGjmBE16ZUYWpfFHXwY
This commit is contained in:
@@ -468,6 +468,128 @@ struct CardSlotTests {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - A Finder file drag's zones
|
||||
|
||||
/// `FileDropZones` — **"created cards land at the drop position"** (04-interactions.md ▸ Drag and
|
||||
/// drop, settled 2026-07-28), pinned on the same fixture the card zones are pinned on, because that
|
||||
/// is the claim: a file drop resolves through *the same card-grid zones an ordinary card drag uses*.
|
||||
///
|
||||
/// The lane, exactly as `CardSlotTests` reads it — 2 columns, 100pt wide, 8pt spacing, origin (0, 0):
|
||||
/// column 0 (x 0…100): card 0 [0, 40] · card 2 [48, 78] · card 4 [86, 136]
|
||||
/// column 1 (x 108…208): card 1 [0, 60] · card 3 [68, 88]
|
||||
/// Column bands meet at 104. The incoming cards have no measured height, so the zones are capped at
|
||||
/// the nominal one — `LaneDropRegistry.nominalCardHeight`, the same stand-in a cross-board arrival
|
||||
/// gets.
|
||||
/// `@MainActor` for one reason: `LaneDropRegistry.nominalCardHeight` is the app's own answer to "how
|
||||
/// tall is a card nobody has measured", and reading it here — rather than repeating the number — is
|
||||
/// what keeps these zones pinned to the height the shadows actually draw at.
|
||||
@MainActor
|
||||
@Suite("FileDropZones ▸ a Finder file drag's landing")
|
||||
struct FileDropZoneTests {
|
||||
private let placement = MasonryPlacement(columnCount: 2, columnWidth: 100, spacing: 8)
|
||||
private let heights: [CGFloat] = [40, 60, 30, 20, 50]
|
||||
private let nominal = LaneDropRegistry.nominalCardHeight
|
||||
|
||||
private func landing(
|
||||
_ x: CGFloat, _ y: CGFloat, headerBottom: CGFloat? = nil, current: Int? = nil,
|
||||
heights: [CGFloat]? = nil
|
||||
) -> FileDropZones.Landing {
|
||||
FileDropZones.landing(
|
||||
cursor: CGPoint(x: x, y: y), headerBottom: headerBottom, placement: placement,
|
||||
heights: heights ?? self.heights, nominalHeight: nominal, current: current)
|
||||
}
|
||||
|
||||
/// Every probe below that is **not** over a card, so the create branch is the one answering.
|
||||
private let emptyProbes: [(CGFloat, CGFloat, Int)] = [
|
||||
(20, 150, 5), // below column 0's last card — the end slot
|
||||
(150, 150, 5), // below column 1's last card — the end slot too
|
||||
(20, 82, 4), // the gap between card 2 and card 4, in column 0
|
||||
(150, 64, 3), // the gap between card 1 and card 3, in column 1
|
||||
(-60, 20, 0), // the lane's leading padding: still column 0
|
||||
(400, 20, 1), // and its trailing padding: column 1
|
||||
(104, 30, 1), // the gutter between the columns, which the band rule gives to column 1
|
||||
]
|
||||
|
||||
@Test("The create slot is the card-drag zone, at the incoming run's nominal footprint")
|
||||
func createIsTheCardZone() {
|
||||
for (x, y, expected) in emptyProbes {
|
||||
#expect(landing(x, y) == .create(index: expected), "(\(x), \(y))")
|
||||
// The claim itself: not "an index like the card zones'" but *the card zones'* answer.
|
||||
let card = DropSlotMath.cardSlot(
|
||||
cursor: CGPoint(x: x, y: y), placement: placement, heights: heights,
|
||||
draggedHeight: nominal, current: nil)
|
||||
#expect(landing(x, y) == .create(index: card ?? -1),
|
||||
"(\(x), \(y)) must be exactly what an ordinary card drag proposes")
|
||||
}
|
||||
}
|
||||
|
||||
@Test("A card under the cursor attaches — anywhere on its bounds, closed at the edges")
|
||||
func attachBeatsCreate() {
|
||||
let probes: [(CGFloat, CGFloat, Int)] = [
|
||||
(20, 20, 0), (150, 20, 1), (20, 60, 2), (150, 75, 3), (20, 100, 4),
|
||||
]
|
||||
for (x, y, expected) in probes {
|
||||
for current in [nil, 0, 1, 2, 3, 4, 5] {
|
||||
#expect(landing(x, y, current: current) == .attach(index: expected),
|
||||
"(\(x), \(y)) with current \(String(describing: current))")
|
||||
}
|
||||
}
|
||||
// Closed containment: a cursor exactly on a shared edge still counts, and the first match
|
||||
// wins, so the answer is deterministic however the frames abut.
|
||||
#expect(landing(100, 40) == .attach(index: 0))
|
||||
#expect(landing(108, 0) == .attach(index: 1))
|
||||
}
|
||||
|
||||
/// **"A release on the lane header resolves to the topmost position"** (04-interactions.md,
|
||||
/// settled 2026-07-28) — forgiving beats a dead stripe.
|
||||
@Test("The lane header is the topmost position, whatever column the cursor is over")
|
||||
func headerIsTheTopmostPosition() {
|
||||
for x: CGFloat in [-60, 20, 104, 150, 400] {
|
||||
for y: CGFloat in [-500, -40, -20] {
|
||||
#expect(landing(x, y, headerBottom: -20) == .create(index: 0), "(\(x), \(y))")
|
||||
}
|
||||
}
|
||||
// The edge is the header's own, and one point below it the masonry answers again — which is
|
||||
// column 1's first row, the very reading the rule exists to override.
|
||||
#expect(landing(150, -20, headerBottom: -20) == .create(index: 0))
|
||||
#expect(landing(150, -19, headerBottom: -20) == .create(index: 1))
|
||||
}
|
||||
|
||||
@Test("Without the header rule the stripe reads as a column, which is why the rule exists")
|
||||
func noHeaderFrameLetsTheMasonryAnswer() {
|
||||
// A lane whose header has not laid out yet: the masonry clamps inward to the nearest column,
|
||||
// so the same cursor proposes column 1's first row rather than the top of the lane.
|
||||
#expect(landing(150, -40, headerBottom: nil) == .create(index: 1))
|
||||
#expect(landing(20, -40, headerBottom: nil) == .create(index: 0))
|
||||
}
|
||||
|
||||
@Test("The header is asked first, so a scrolled masonry cannot hide the stripe behind a card")
|
||||
func headerWinsOverACardBehindIt() {
|
||||
// The masonry is scroll-view content: scrolled down, a card's resting frame can compute to a
|
||||
// y the header stripe occupies. The ruling admits no exception, so the header answers.
|
||||
#expect(landing(150, 20) == .attach(index: 1), "with no header the card takes it")
|
||||
#expect(landing(150, 20, headerBottom: 50) == .create(index: 0))
|
||||
#expect(landing(20, 20, headerBottom: 50) == .create(index: 0))
|
||||
}
|
||||
|
||||
@Test("A dead region holds, and with nothing to hold the containing zone answers")
|
||||
func deadRegionHolds() {
|
||||
// A 200pt card in column 1 and the cursor in the gutter beside its far side: the nominal
|
||||
// footprint (44) does not reach there, so the zone is dead.
|
||||
let tall: [CGFloat] = [40, 200]
|
||||
#expect(landing(104, 150, current: 1, heights: tall) == .hold)
|
||||
#expect(landing(104, 150, current: nil, heights: tall) == .create(index: 1),
|
||||
"a fresh entry must still have a landing spot")
|
||||
}
|
||||
|
||||
@Test("An empty lane takes the drop at its only position, header or not")
|
||||
func emptyLane() {
|
||||
#expect(landing(10, 10, heights: []) == .create(index: 0))
|
||||
#expect(landing(400, 900, heights: []) == .create(index: 0))
|
||||
#expect(landing(150, -40, headerBottom: -20, heights: []) == .create(index: 0))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Applying a proposal
|
||||
|
||||
@Suite("DropSlotMath ▸ applying a proposal")
|
||||
|
||||
Reference in New Issue
Block a user