



























@@ -13,6 +13,7 @@ const waitForGatewayReachable = vi.hoisted(() =>
1313vi.fn<() => Promise<{ ok: boolean; detail?: string }>>(async () => ({ ok: true })),
1414);
1515const setupWizardShellCompletion = vi.hoisted(() => vi.fn(async () => {}));
16+const healthCommand = vi.hoisted(() => vi.fn(async () => {}));
1617const buildGatewayInstallPlan = vi.hoisted(() =>
1718vi.fn(async () => ({
1819programArguments: [],
@@ -86,7 +87,7 @@ vi.mock("../commands/health-format.js", () => ({
8687}));
87888889vi.mock("../commands/health.js", () => ({
89-healthCommand: vi.fn(async () => {}),
90+ healthCommand,
9091}));
91929293vi.mock("../commands/onboard-search.js", () => ({
@@ -243,6 +244,8 @@ describe("finalizeSetupWizard", () => {
243244waitForGatewayReachable.mockReset();
244245waitForGatewayReachable.mockResolvedValue({ ok: true });
245246setupWizardShellCompletion.mockClear();
247+healthCommand.mockReset();
248+healthCommand.mockResolvedValue(undefined);
246249buildGatewayInstallPlan.mockClear();
247250gatewayServiceInstall.mockClear();
248251gatewayServiceIsLoaded.mockReset();
@@ -558,6 +561,57 @@ describe("finalizeSetupWizard", () => {
558561);
559562});
560563564+it("uses the setup token for health checks to avoid local env token drift", async () => {
565+const prompter = createLaterPrompter();
566+567+await finalizeSetupWizard({
568+flow: "quickstart",
569+opts: {
570+acceptRisk: true,
571+authChoice: "skip",
572+installDaemon: false,
573+skipHealth: false,
574+skipUi: true,
575+},
576+baseConfig: {},
577+nextConfig: {
578+gateway: {
579+auth: {
580+mode: "token",
581+token: "config-token",
582+},
583+},
584+},
585+workspaceDir: "/tmp",
586+settings: {
587+port: 18789,
588+bind: "loopback",
589+authMode: "token",
590+gatewayToken: "session-token",
591+tailscaleMode: "off",
592+tailscaleResetOnExit: false,
593+},
594+ prompter,
595+runtime: createRuntime(),
596+});
597+598+expect(healthCommand).toHaveBeenCalledWith(
599+expect.objectContaining({
600+json: false,
601+timeoutMs: 10_000,
602+config: expect.objectContaining({
603+gateway: expect.objectContaining({
604+auth: expect.objectContaining({
605+mode: "token",
606+token: "session-token",
607+}),
608+}),
609+}),
610+}),
611+expect.any(Object),
612+);
613+});
614+561615it("shows actionable gateway guidance instead of a hard error in no-daemon onboarding", async () => {
562616waitForGatewayReachable.mockResolvedValue({
563617ok: false,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。