### Fixed

- Fixed flaky timing issues in P2P synchronisation.
- Fixed more binary file handling issues in CLI.

### Tests

- Rewrite P2P end-to-end tests to use the CLI as host.
This commit is contained in:
vorotamoroz
2026-03-16 00:48:22 +09:00
parent 89bf0488c3
commit 6c69547cef
14 changed files with 1039 additions and 20 deletions
+20
View File
@@ -116,6 +116,22 @@ export const acceptWebPeer: BrowserCommand = async (ctx) => {
return false;
};
/** Write arbitrary text to a file on the Node.js host (used for phase handoff). */
export const writeHandoffFile: BrowserCommand<[filePath: string, content: string]> = async (
_ctx,
filePath: string,
content: string
) => {
const fs = await import("node:fs/promises");
await fs.writeFile(filePath, content, "utf-8");
};
/** Read a file from the Node.js host (used for phase handoff). */
export const readHandoffFile: BrowserCommand<[filePath: string]> = async (_ctx, filePath: string): Promise<string> => {
const fs = await import("node:fs/promises");
return fs.readFile(filePath, "utf-8");
};
export default function BrowserCommands(): Plugin {
return {
name: "vitest:custom-commands",
@@ -128,6 +144,8 @@ export default function BrowserCommands(): Plugin {
openWebPeer,
closeWebPeer,
acceptWebPeer,
writeHandoffFile,
readHandoffFile,
},
},
},
@@ -141,5 +159,7 @@ declare module "vitest/browser" {
openWebPeer: (setting: P2PSyncSetting, serverPeerName: string) => Promise<void>;
closeWebPeer: () => Promise<void>;
acceptWebPeer: () => Promise<boolean>;
writeHandoffFile: (filePath: string, content: string) => Promise<void>;
readHandoffFile: (filePath: string) => Promise<string>;
}
}