also looking at this
feat: expose owned VTOL transition simulation through native CLI
#82
20 files
+743
-36
| @@ -0,0 +1,73 @@ | ||
| 1 | import { expect, test } from 'bun:test' | |
| 2 | import { command } from '@stacksjs/testing' | |
| 3 | ||
| 4 | test('CI qualifies both full-route commands outside the checkout', async () => { | |
| 5 | const workflow = Bun.YAML.parse(await Bun.file(new URL('../../.github/workflows/ci.yml', import.meta.url)).text()) as { | |
| 6 | jobs: { check: { steps: { run?: string, 'working-directory'?: string }[] } } | |
| 7 | } | |
| 8 | expect(workflow.jobs.check.steps.filter(step => step.run?.startsWith('$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:simulate')).map(step => ({ command: step.run, directory: step['working-directory'] }))).toEqual([ | |
| 9 | { command: '$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:simulate', directory: '${{ runner.temp }}' }, | |
| 10 | { command: '$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:simulate --electrical', directory: '${{ runner.temp }}' }, | |
| 11 | ]) | |
| 12 | }) | |
| 13 | ||
| 14 | test('native VTOL full-route command reports qualified initial hover, cruise, back hover and landing', async () => { | |
| 15 | const result = await command(['vtol:simulate']).withTimeout(60000) | |
| 16 | expect(result.exitCode).toBe(0) | |
| 17 | const report = JSON.parse(result.stdout) | |
| 18 | expect(report.status).toBe('completed') | |
| 19 | expect(report.scope).toBe('development-lift-and-cruise') | |
| 20 | expect(report.demonstrationMatched).toBe(true) | |
| 21 | expect(report.transitionEvidence.map((row: { taskId: string, phase: string }) => [row.taskId, row.phase])).toEqual([ | |
| 22 | ['initial-hover', 'hover'], ['front', 'cruise'], ['back', 'hover'], | |
| 23 | ]) | |
| 24 | for (const row of report.transitionEvidence) { | |
| 25 | expect(row.eventId).toBeString() | |
| 26 | expect(row.reference).toBeString() | |
| 27 | expect(row.outcome).toBe('confirmed') | |
| 28 | expect(row.measurementCapturedAtMs).toBeLessThanOrEqual(row.capturedAtMs) | |
| 29 | } | |
| 30 | expect(report.observedFlight).toBe(true) | |
| 31 | expect(report.landingContact).toBe(true) | |
| 32 | expect(report.mission.state).toBe('completed') | |
| 33 | expect(report.mission.taskId).toBe('land') | |
| 34 | expect(report.mission.reason).toBe('landed') | |
| 35 | expect(report.board.actuators).toEqual([0, 0, 0, 0, 0, 0, 0, 0]) | |
| 36 | expect(report.board.expiresAtMs).toBeNull() | |
| 37 | expect(report.physicalFlightEnabled).toBe(false) | |
| 38 | expect(report.boardOutputsInhibited).toBe(true) | |
| 39 | expect(report).not.toHaveProperty('trace') | |
| 40 | expect(report).not.toHaveProperty('path') | |
| 41 | expect(report).not.toHaveProperty('energy') | |
| 42 | }, 90000) | |
| 43 | ||
| 44 | test('native full-route electrical option retains qualified landing and modeled energy evidence', async () => { | |
| 45 | const result = await command(['vtol:simulate', '--electrical']).withTimeout(60000) | |
| 46 | expect(result.exitCode).toBe(0) | |
| 47 | const report = JSON.parse(result.stdout) | |
| 48 | expect(report.demonstrationMatched).toBe(true) | |
| 49 | expect(report.completeTransitions).toBe(true) | |
| 50 | expect(report.landingContact).toBe(true) | |
| 51 | expect(report.energy.model).toEqual({ evidence: 'modeled-vehicle-battery-v1', capacityWh: 100, maximumSourceW: 1061 }) | |
| 52 | expect(report.energy.lastObservation.energyUsedWh).toBeGreaterThan(0) | |
| 53 | expect(report.energy.lastObservation.capturedAtMs).toBeLessThan(report.energy.lastObservation.observedAtMs) | |
| 54 | expect(report.energy.lastObservation.cutoff).toBe(false) | |
| 55 | }, 90000) | |
| 56 | ||
| 57 | test('native full-route command preserves partial outcomes and rejects invalid duration', async () => { | |
| 58 | const short = await command(['vtol:simulate', '--seconds', '2']).withTimeout(60000) | |
| 59 | expect(short.exitCode).toBe(1) | |
| 60 | const report = JSON.parse(short.stdout) | |
| 61 | expect(report.status).toBe('duration-exhausted') | |
| 62 | expect(report.demonstrationMatched).toBe(false) | |
| 63 | expect(report.completeTransitions).toBe(false) | |
| 64 | expect(report.landingContact).toBe(false) | |
| 65 | expect(report.mission.state).toBe('running') | |
| 66 | expect(report.boardNeutral).toBe(true) | |
| 67 | expect(report.transitionEvidence.map((row: { taskId: string }) => row.taskId)).toEqual(['initial-hover']) | |
| 68 | for (const seconds of ['NaN', '1', '181', '2.5']) { | |
| 69 | const invalid = await command(['vtol:simulate', '--seconds', seconds]).withTimeout(60000) | |
| 70 | expect(invalid.exitCode).toBe(1) | |
| 71 | expect(invalid.stdout).toBe('') | |
| 72 | } | |
| 73 | }, 90000) | |