codeburn/mac/Tests/CodeBurnMenubarTests/CapacityDockInteractionStateTests.swift
Aditya Vikram Singh 84fea9d550
feat(menubar): add native Capacity Dock (#1167)
* feat(menubar): add native capacity dock

* fix(menubar): harden dock interaction boundaries

* feat(menubar): polish native Capacity Dock for launch

- Flush top-edge docking via NSHostingView safe-area opt-out; shielding
  window level so the rail necks into the physical top like the system notch
- Liquid Glass legibility scrim so labels stay readable on light wallpapers
- Weekly-else-monthly headline window; unified severity colour bands
  (green <50 / yellow / orange / red) across rings and detail bars
- Squircle gauge + graphite theme defaults; auto-show connected
  subscriptions (up to 5) until the user edits the set, then respect it
- Capacity Dock Settings menu item; re-centre the settings window; info
  glyph for the About row
- Trim dead provider-credential override fields down to apiKey only
- Reconcile and extend tests for all of the above

---------

Co-authored-by: iamtoruk <hello@agentseal.org>
2026-08-29 00:37:30 -07:00

94 lines
2.9 KiB
Swift

import Testing
@testable import CodeBurnMenubar
@Suite("Capacity Dock interaction state")
struct CapacityDockInteractionStateTests {
@Test("rail exit stays expanded until the collapse grace period completes")
func railHoverLifecycle() {
var state = CapacityDockInteractionState()
state.setRailHovered(true)
#expect(state.isExpanded)
#expect(!state.canCollapse)
state.beginRailExitGrace()
#expect(state.isExpanded)
#expect(!state.canCollapse)
state.completeCollapseGrace()
#expect(!state.isExpanded)
#expect(state.canCollapse)
}
@Test("detail hover bridges the pointer gap after leaving the rail")
func detailHoverKeepsExpanded() {
var state = CapacityDockInteractionState()
state.setRailHovered(true)
state.setDetailHovered(true)
state.beginRailExitGrace()
state.completeCollapseGrace()
#expect(state.isExpanded)
#expect(!state.canCollapse)
state.setDetailHovered(false)
#expect(state.canCollapse)
}
@Test("pin survives hover exit and toggles off")
func pinLifecycle() {
var state = CapacityDockInteractionState()
state.togglePinned()
state.beginRailExitGrace()
state.completeCollapseGrace()
#expect(state.isExpanded)
#expect(state.isPinned)
state.togglePinned()
#expect(!state.isExpanded)
#expect(state.canCollapse)
}
@Test("outside click and Escape fully dismiss pinned interaction")
func dismissesPinnedState() {
var state = CapacityDockInteractionState(isRailHovered: true, isDetailHovered: true, isPinned: true)
state.dismiss()
#expect(state == CapacityDockInteractionState())
state.togglePinned()
let handled = state.handleEscape()
#expect(handled)
#expect(state == CapacityDockInteractionState())
let handledAgain = state.handleEscape()
#expect(!handledAgain)
}
@Test("dragging suppresses hover transitions without changing pin state")
func draggingSuppressesHover() {
var state = CapacityDockInteractionState(isRailHovered: true, isPinned: true)
state.beginDragging()
#expect(state.isDragging)
#expect(state.isPinned)
#expect(state.isExpanded)
#expect(!state.acceptsHoverTransitions)
state.endDragging()
#expect(!state.isDragging)
#expect(state.acceptsHoverTransitions)
#expect(state.isPinned)
}
@Test("dragging during collapse grace keeps the current rail geometry stable")
func draggingPreservesCollapseGrace() {
var state = CapacityDockInteractionState(isRailHovered: true)
state.beginRailExitGrace()
#expect(state.isExpanded)
state.beginDragging()
#expect(state.isExpanded)
#expect(state.isCollapseGraceActive)
}
}