import test from "node:test"
import assert from "node:assert/strict"

import {
  getNextStartupVisualProgress,
  getStartupCurtainFootnote,
  getStartupCurtainStatus
} from "../src/features/shell/startupStatus.ts"

test("startup curtain uses concise one-line loading statuses", () => {
  assert.equal(getStartupCurtainStatus("syncing-config", "starting"), "准备配置")
  assert.equal(getStartupCurtainStatus("syncing-projects", "starting"), "同步项目")
  assert.equal(getStartupCurtainStatus("starting-runtime", "starting"), "启动助手")
  assert.equal(getStartupCurtainStatus("connecting-gateway", "starting"), "连接服务")
  assert.equal(getStartupCurtainStatus("ready", "ready"), "即将进入")
  assert.equal(getStartupCurtainStatus(undefined, "starting"), "准备中")
})

test("startup curtain only keeps footnote text for errors", () => {
  assert.equal(getStartupCurtainFootnote("starting"), "")
  assert.equal(getStartupCurtainFootnote("error").length > 0, true)
})

test("visual startup progress advances without retreating", () => {
  assert.equal(getNextStartupVisualProgress(0.56, 0.82), 0.82)
  assert.equal(getNextStartupVisualProgress(0.82, 0.24), 0.82)
})

