mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-12 20:15:49 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const { startGmailWatcherMock } = vi.hoisted(() => ({
|
|
startGmailWatcherMock: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("./gmail-watcher.js", () => ({
|
|
startGmailWatcher: startGmailWatcherMock,
|
|
}));
|
|
|
|
import { startGmailWatcherWithLogs } from "./gmail-watcher-lifecycle.js";
|
|
|
|
describe("startGmailWatcherWithLogs", () => {
|
|
const log = {
|
|
info: vi.fn(),
|
|
warn: vi.fn(),
|
|
error: vi.fn(),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
startGmailWatcherMock.mockClear();
|
|
log.info.mockClear();
|
|
log.warn.mockClear();
|
|
log.error.mockClear();
|
|
delete process.env.OPENCLAW_SKIP_GMAIL_WATCHER;
|
|
});
|
|
|
|
afterEach(() => {
|
|
delete process.env.OPENCLAW_SKIP_GMAIL_WATCHER;
|
|
});
|
|
|
|
it("logs startup success", async () => {
|
|
startGmailWatcherMock.mockResolvedValue({ started: true, reason: undefined });
|
|
|
|
await startGmailWatcherWithLogs({
|
|
cfg: {},
|
|
log,
|
|
});
|
|
|
|
expect(log.info).toHaveBeenCalledWith("gmail watcher started");
|
|
expect(log.warn).not.toHaveBeenCalled();
|
|
expect(log.error).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("logs actionable non-start reason", async () => {
|
|
startGmailWatcherMock.mockResolvedValue({ started: false, reason: "auth failed" });
|
|
|
|
await startGmailWatcherWithLogs({
|
|
cfg: {},
|
|
log,
|
|
});
|
|
|
|
expect(log.warn).toHaveBeenCalledWith("gmail watcher not started: auth failed");
|
|
});
|
|
|
|
it("suppresses expected non-start reasons", async () => {
|
|
startGmailWatcherMock.mockResolvedValue({
|
|
started: false,
|
|
reason: "hooks not enabled",
|
|
});
|
|
|
|
await startGmailWatcherWithLogs({
|
|
cfg: {},
|
|
log,
|
|
});
|
|
|
|
expect(log.warn).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("supports skip callback when watcher is disabled", async () => {
|
|
process.env.OPENCLAW_SKIP_GMAIL_WATCHER = "1";
|
|
const onSkipped = vi.fn();
|
|
|
|
await startGmailWatcherWithLogs({
|
|
cfg: {},
|
|
log,
|
|
onSkipped,
|
|
});
|
|
|
|
expect(startGmailWatcherMock).not.toHaveBeenCalled();
|
|
expect(onSkipped).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("logs startup errors", async () => {
|
|
startGmailWatcherMock.mockRejectedValue(new Error("boom"));
|
|
|
|
await startGmailWatcherWithLogs({
|
|
cfg: {},
|
|
log,
|
|
});
|
|
|
|
expect(log.error).toHaveBeenCalledWith("gmail watcher failed to start: Error: boom");
|
|
});
|
|
});
|