mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix(frontend): add WebSocket client cleanup and delay between tests
This commit is contained in:
parent
c7b02d90e8
commit
e47ee79241
@ -32,9 +32,17 @@ describe("useWebSocket", () => {
|
||||
});
|
||||
|
||||
// Clean up after each test to prevent cross-test contamination
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
// Unmount any rendered hooks to trigger their cleanup effects (closes WebSocket connections)
|
||||
cleanup();
|
||||
// Clear all tracked WebSocket clients to prevent cross-test message leaks
|
||||
// This is necessary because wsLink is a singleton and clients persist across tests
|
||||
wsLink.clients.forEach((client) => client.close());
|
||||
wsLink.clients.clear();
|
||||
// Small delay to ensure WebSocket cleanup completes before next test starts
|
||||
await new Promise<void>((resolve) => {
|
||||
setTimeout(resolve, 10);
|
||||
});
|
||||
});
|
||||
|
||||
it("should establish a WebSocket connection", async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user