mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 05:47:39 +00:00
refactor(test): consolidate doctor health and sandbox fixtures
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user