Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: unmount StoryBuilder test tree before removing the EventSource stub (#10468)

[._.]/ Adam Eivy3d4ee93406fb
diff --git a/client/src/pages/StoryBuilder.test.jsx b/client/src/pages/StoryBuilder.test.jsx
index 880c8269e7..de877a659a 100644
--- a/client/src/pages/StoryBuilder.test.jsx
+++ b/client/src/pages/StoryBuilder.test.jsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
-import { act, render, screen, waitFor } from '@testing-library/react';
+import { act, cleanup, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter, Routes, Route } from 'react-router';
import { MockEventSource, lastEventSource } from '../test/mockEventSource';
@@ -919,7 +919,9 @@ describe('StoryBuilder — detail stepper', () => {
staleSteps: [], llm: { provider: '', model: '' }, activeSteps,
});
beforeEach(() => { MockEventSource.reset(); global.EventSource = MockEventSource; });
- afterEach(() => { delete global.EventSource; });
+ // afterEach hooks run in reverse registration order, so RTL's auto-cleanup would fire AFTER this
+ // hook; unmount first so a late useSseProgress effect never sees EventSource gone.
+ afterEach(() => { cleanup(); delete global.EventSource; });
it('attaches to the surviving run, shows it, disables the kickoff and reloads once on completion', async () => {
api.getStorySession.mockResolvedValue(liveSession([