// // GatelessLaunchTests.swift // MuseionTests // // #151 — the gateless launch pins. Scenario: // // ## Scenario: Gateless launch — the workspace is the first frame // From user story #151 (map #148; #150 architecture, #149 UX contract) // // Given a launch with no engine verdict yet // When the app opens // Then the workspace renders immediately, the engine check runs async // (provisioning + backup auto-fire on pass), and the rail pill + mentor // header name the checking/failed states without ever blocking. // import Foundation @testable import Museion import Testing @Suite("GatelessLaunchTests") struct GatelessLaunchTests { // MARK: startLaunchCheck (#151 machinery) /// Hosted tests run the app as their runner — the launch check must /// neither probe nor arm the auto-fire chain there (the panes' guard /// pattern; a fired chain would write the REAL profile roots). @Test @MainActor func `startLaunchCheck no-ops under hosted tests`() async { let gate = AppGateState() await gate.startLaunchCheck() #expect(gate.gateModel.phase == .idle) #expect(gate.gateModel.onPass == nil) } /// The entry point arms onPass before the check runs — the moved /// onEnginePass body (provisioning → backup). The model-level facts /// stay pinned by EngineGateTests (onPass fires per passing check, /// Re-check included; a repeat begin is a no-op). @Test @MainActor func `wireAutoFire arms the launch chain`() { let gate = AppGateState() gate.wireAutoFire() #expect(gate.gateModel.onPass != nil) } // MARK: Pill visibility mapping (#149 variant A contract) /// The pill exists only while checking or failed — idle and a healthy /// pass render NOTHING (the slot collapses, rail spacing closes). @Test @MainActor func `pill visibility maps idle and healthy pass to hidden`() { #expect(EngineStatusSurface.visibility(phase: .idle, provisioningFailed: false) == .hidden) #expect(EngineStatusSurface.visibility(phase: .idle, provisioningFailed: true) == .hidden) #expect( EngineStatusSurface.visibility( phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: false, ) == .hidden, ) } @Test @MainActor func `checking maps to the pulsing dot`() { #expect(EngineStatusSurface.visibility(phase: .checking, provisioningFailed: false) == .pulsing) } @Test @MainActor func `engine failure maps to the orange failed state`() { #expect( EngineStatusSurface.visibility( phase: .fail(firstProbePath: "/x", stderrExcerpt: ""), provisioningFailed: false, ) == .failed, ) } /// A provisioning failure rides the same orange surface under a passed /// gate — the pill names why Passes/Sessions are dead (#38's /// no-silent-degradation AC, carried by the pill). @Test @MainActor func `provisioning failure keeps the pill failed under a passed gate`() { #expect( EngineStatusSurface.visibility( phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: true, ) == .failed, ) } // MARK: Mentor header states (#149's contract — the pure mapping) @Test @MainActor func `header state maps the gate verdicts`() { #expect(MentorEngineStatus.state(phase: .idle, provisioningFailed: false) == .checking) #expect(MentorEngineStatus.state(phase: .checking, provisioningFailed: false) == .checking) #expect( MentorEngineStatus.state( phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: false, ) == .ready, ) } @Test @MainActor func `header names setup failed only under a passed gate`() { #expect( MentorEngineStatus.state( phase: .pass(engineVersion: "9.9.9", binaryPath: "/x"), provisioningFailed: true, ) == .setupFailed, ) } /// The outrank rule: engine failure wins over a lingering provisioning /// failure (no engine → Retry can't run anyway). @Test @MainActor func `header engine failure outranks a lingering provisioning failure`() { #expect( MentorEngineStatus.state( phase: .fail(firstProbePath: "/x", stderrExcerpt: ""), provisioningFailed: true, ) == .engineMissing, ) } }