Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test: isolate desktop sync fixture from host disk space

leonongoing0d671cca3b7f
diff --git a/electron/cloud-sync-engine.node-test.mjs b/electron/cloud-sync-engine.node-test.mjs
index 8573a9f4a3..c7e4502a5b 100644
--- a/electron/cloud-sync-engine.node-test.mjs
+++ b/electron/cloud-sync-engine.node-test.mjs
@@ -125,6 +125,22 @@ test("bots' work: new files come down marked as downloaded; nothing here is dele
assert.equal(s.read("report.md"), "v1");
});
+test("bots' work: waits for the local disk reserve, then downloads when it fits", async (t) => {
+ const s = setup(t);
+ s.cloud.put("f1", "report.md", "v1");
+ const waiting = await s.outputs({ freeBytes: () => GB + 1 });
+ assert.equal(waiting.status, "waiting");
+ assert.equal(waiting.waitingBytes, 2);
+ assert.equal(existsSync(join(s.local, "report.md")), false);
+ assert.deepEqual(s.cloud.calls.filter(([kind]) => kind === "download"), []);
+
+ const ready = await s.outputs({ freeBytes: () => GB + 2 });
+ assert.equal(ready.status, "synced");
+ assert.equal(ready.waitingBytes, 0);
+ assert.equal(s.read("report.md"), "v1");
+ assert.deepEqual(s.cloud.calls.filter(([kind]) => kind === "download"), [["download", "report.md"]]);
+});
+
test("bots' work: a newer version replaces an untouched file (the old one to the Recycle Bin), and lands beside the person's edit", async (t) => {
const s = setup(t);
s.cloud.put("f1", "report.md", "v1");
diff --git a/server/cloud-sync.e2e.test.ts b/server/cloud-sync.e2e.test.ts
index 85a385a0b9..546bd87fea 100644
--- a/server/cloud-sync.e2e.test.ts
+++ b/server/cloud-sync.e2e.test.ts
@@ -115,6 +115,7 @@ function desktop(pcHome: string) {
settingsFile: join(pcHome, "user", "settings.json"), stateFile: join(pcHome, "user", "state.db"),
documentsDir: join(pcHome, "Documents"), localDataDir: join(pcHome, ".openmausbot"), homeDir: pcHome, platform: process.platform, hostname: "Ash-PC",
cloudOrigin: () => PC_ORIGIN, fetch: desktopFetch as typeof fetch, trashItem: async (file: string) => rmSync(file), markDownloaded: async () => {},
+ freeBytes: () => 100 * 1024 ** 3,
watch: () => () => {}, now: () => Date.now() + 60_000,
});
}