import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { prepareFileConsentActivityFs } from "./file-consent-helpers.js"; import {
getPendingUploadFs,
removePendingUploadFs,
setPendingUploadActivityIdFs,
storePendingUploadFs,
} from "./pending-uploads-fs.js"; import { clearPendingUploads } from "./pending-uploads.js"; import { setMSTeamsRuntime } from "./runtime.js"; import { msteamsRuntimeStub } from "./test-runtime.js";
// Track temp dirs created by each test so afterEach can clean them up. const createdTempDirs: string[] = [];
async function makeTempStateDir(): Promise<string> { const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "openclaw-msteams-pending-"));
createdTempDirs.push(dir); return dir;
}
// Confirm the backing file actually exists on disk with expected shape const storePath = path.join(stateDir, "msteams-pending-uploads.json"); const raw = await fs.promises.readFile(storePath, "utf-8"); const parsed = JSON.parse(raw) as {
version: number;
uploads: Record<string, { bufferBase64: string; filename: string }>;
};
expect(parsed.version).toBe(1);
expect(parsed.uploads["upload-x"]?.filename).toBe("secret.bin");
expect(Buffer.from(parsed.uploads["upload-x"].bufferBase64, "base64").toString("utf8")).toBe( "top secret",
);
// Second "process": reader using the same state dir const reader = await getPendingUploadFs("upload-x", { env });
expect(reader?.buffer.toString("utf8")).toBe("top secret");
expect(reader?.filename).toBe("secret.bin");
});
it("writes the pending upload to the fs store with the same id as the card", async () => { const stateDir = await makeTempStateDir(); const env = makeEnv(stateDir); // Redirect state dir via env so the helper's FS writes land under our tmp const originalEnv = process.env.OPENCLAW_STATE_DIR;
process.env.OPENCLAW_STATE_DIR = stateDir;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.