mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:31:35 +00:00
test(core): trim redundant test resets and use mockClear
This commit is contained in:
@@ -30,7 +30,7 @@ describe("subscribeEmbeddedPiSession", () => {
|
|||||||
const firstPayload = onPartialReply.mock.calls[0][0];
|
const firstPayload = onPartialReply.mock.calls[0][0];
|
||||||
expect(firstPayload.text).toBe("Hi there");
|
expect(firstPayload.text).toBe("Hi there");
|
||||||
|
|
||||||
onPartialReply.mockReset();
|
onPartialReply.mockClear();
|
||||||
|
|
||||||
emit({ type: "message_start", message: { role: "assistant" } });
|
emit({ type: "message_start", message: { role: "assistant" } });
|
||||||
emitAssistantTextDelta({ emit, delta: "</final>Oops no start" });
|
emitAssistantTextDelta({ emit, delta: "</final>Oops no start" });
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { stageSandboxMedia } from "./reply/stage-sandbox-media.js";
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
childProcessMocks.spawn.mockReset();
|
childProcessMocks.spawn.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("stageSandboxMedia", () => {
|
describe("stageSandboxMedia", () => {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ const { handleInlineActions } = await import("./get-reply-inline-actions.js");
|
|||||||
|
|
||||||
describe("handleInlineActions", () => {
|
describe("handleInlineActions", () => {
|
||||||
it("skips whatsapp replies when config is empty and From !== To", async () => {
|
it("skips whatsapp replies when config is empty and From !== To", async () => {
|
||||||
handleCommandsMock.mockReset();
|
|
||||||
|
|
||||||
const typing: TypingController = {
|
const typing: TypingController = {
|
||||||
onReplyStart: async () => {},
|
onReplyStart: async () => {},
|
||||||
startTypingLoop: async () => {},
|
startTypingLoop: async () => {},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ describe("noteSessionLockHealth", () => {
|
|||||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
note.mockReset();
|
note.mockClear();
|
||||||
envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]);
|
envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]);
|
||||||
root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-doctor-locks-"));
|
root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-doctor-locks-"));
|
||||||
process.env.OPENCLAW_STATE_DIR = root;
|
process.env.OPENCLAW_STATE_DIR = root;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ describe("doctor state integrity oauth dir checks", () => {
|
|||||||
process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
|
process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
|
||||||
delete process.env.OPENCLAW_OAUTH_DIR;
|
delete process.env.OPENCLAW_OAUTH_DIR;
|
||||||
fs.mkdirSync(process.env.OPENCLAW_STATE_DIR, { recursive: true, mode: 0o700 });
|
fs.mkdirSync(process.env.OPENCLAW_STATE_DIR, { recursive: true, mode: 0o700 });
|
||||||
vi.mocked(note).mockReset();
|
vi.mocked(note).mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ vi.mock("../infra/channel-activity.js", async (importOriginal) => {
|
|||||||
|
|
||||||
describe("sendWebhookMessageDiscord activity", () => {
|
describe("sendWebhookMessageDiscord activity", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
recordChannelActivityMock.mockReset();
|
recordChannelActivityMock.mockClear();
|
||||||
vi.stubGlobal(
|
vi.stubGlobal(
|
||||||
"fetch",
|
"fetch",
|
||||||
vi.fn(async () => {
|
vi.fn(async () => {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ describe("ensureGatewayStartupAuth", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
mocks.writeConfigFile.mockReset();
|
mocks.writeConfigFile.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function expectNoTokenGeneration(cfg: OpenClawConfig, mode: string) {
|
async function expectNoTokenGeneration(cfg: OpenClawConfig, mode: string) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ describe("imessage targets", () => {
|
|||||||
|
|
||||||
describe("createIMessageRpcClient", () => {
|
describe("createIMessageRpcClient", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spawnMock.mockReset();
|
spawnMock.mockClear();
|
||||||
vi.stubEnv("VITEST", "true");
|
vi.stubEnv("VITEST", "true");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ describe("ports helpers", () => {
|
|||||||
|
|
||||||
describeUnix("inspectPortUsage", () => {
|
describeUnix("inspectPortUsage", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
runCommandWithTimeoutMock.mockReset();
|
runCommandWithTimeoutMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports busy when lsof is missing but loopback listener exists", async () => {
|
it("reports busy when lsof is missing but loopback listener exists", async () => {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ afterEach(() => {
|
|||||||
envSnapshot.restore();
|
envSnapshot.restore();
|
||||||
process.argv = [...originalArgv];
|
process.argv = [...originalArgv];
|
||||||
process.execArgv = [...originalExecArgv];
|
process.execArgv = [...originalExecArgv];
|
||||||
spawnMock.mockReset();
|
spawnMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
function clearSupervisorHints() {
|
function clearSupervisorHints() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ let probeLineBot: typeof import("./probe.js").probeLineBot;
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
getBotInfoMock.mockReset();
|
getBotInfoMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("probeLineBot", () => {
|
describe("probeLineBot", () => {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function setRegistry(entries: MockRegistryToolEntry[]) {
|
|||||||
|
|
||||||
describe("resolvePluginTools optional tools", () => {
|
describe("resolvePluginTools optional tools", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
loadOpenClawPluginsMock.mockReset();
|
loadOpenClawPluginsMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skips optional tools without explicit allowlist", () => {
|
it("skips optional tools without explicit allowlist", () => {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe("killProcessTree", () => {
|
|||||||
let killSpy: ReturnType<typeof vi.spyOn>;
|
let killSpy: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spawnMock.mockReset();
|
spawnMock.mockClear();
|
||||||
killSpy = vi.spyOn(process, "kill");
|
killSpy = vi.spyOn(process, "kill");
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe("process supervisor PTY command contract", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
createPtyAdapterMock.mockReset();
|
createPtyAdapterMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("passes PTY command verbatim to shell args", async () => {
|
it("passes PTY command verbatim to shell args", async () => {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ vi.mock("../logging/subsystem.js", () => ({
|
|||||||
|
|
||||||
describe("resolveTelegramAccount", () => {
|
describe("resolveTelegramAccount", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
warnMock.mockReset();
|
warnMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to the first configured account when accountId is omitted", () => {
|
it("falls back to the first configured account when accountId is omitted", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user