refactor(test): consolidate doctor health and sandbox fixtures

This commit is contained in:
Peter Steinberger
2026-02-16 16:48:46 +00:00
parent 2d8edf85ad
commit 0d51869c3c
5 changed files with 133 additions and 109 deletions

View File

@@ -250,6 +250,13 @@ describe("sandboxRecreateCommand", () => {
});
describe("confirmation flow", () => {
async function runCancelledConfirmation(confirmResult: boolean | symbol) {
mocks.listSandboxContainers.mockResolvedValue([createContainer()]);
mocks.clackConfirm.mockResolvedValue(confirmResult);
await sandboxRecreateCommand({ all: true, browser: false, force: false }, runtime as never);
}
it("should require confirmation without --force", async () => {
mocks.listSandboxContainers.mockResolvedValue([createContainer()]);
mocks.clackConfirm.mockResolvedValue(true);
@@ -261,20 +268,14 @@ describe("sandboxRecreateCommand", () => {
});
it("should cancel when user declines", async () => {
mocks.listSandboxContainers.mockResolvedValue([createContainer()]);
mocks.clackConfirm.mockResolvedValue(false);
await sandboxRecreateCommand({ all: true, browser: false, force: false }, runtime as never);
await runCancelledConfirmation(false);
expect(runtime.log).toHaveBeenCalledWith("Cancelled.");
expect(mocks.removeSandboxContainer).not.toHaveBeenCalled();
});
it("should cancel on clack cancel symbol", async () => {
mocks.listSandboxContainers.mockResolvedValue([createContainer()]);
mocks.clackConfirm.mockResolvedValue(Symbol.for("clack:cancel"));
await sandboxRecreateCommand({ all: true, browser: false, force: false }, runtime as never);
await runCancelledConfirmation(Symbol.for("clack:cancel"));
expect(runtime.log).toHaveBeenCalledWith("Cancelled.");
expect(mocks.removeSandboxContainer).not.toHaveBeenCalled();