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

test: mark Chrome cleanup as a test-only hook

[._.]/ Adam Eivy151da9b8ab4d
diff --git a/server/services/htmlComposition/index.test.js b/server/services/htmlComposition/index.test.js
index e54a30998e..74451258f2 100644
--- a/server/services/htmlComposition/index.test.js
+++ b/server/services/htmlComposition/index.test.js
@@ -11,7 +11,7 @@ import { PATHS } from '../../lib/fileUtils.js';
import { loadHistory } from '../videoGen/history.js';
import { videoGenEvents } from '../videoGen/events.js';
import { renderComposition, cancel } from './index.js';
-import { cleanupTestBrowser } from './testBrowserCleanup.js';
+import { _cleanupTestBrowser } from './testBrowserCleanup.js';
let endpoint;
vi.mock('../browserService.js', () => ({ cdpRequest: path => fetch(`${endpoint}${path}`) }));
@@ -61,7 +61,7 @@ describe.skipIf(!chrome || !ffmpeg)('HTML composition with real Chrome and ffmpe
browserSession = await browser.newBrowserCDPSession();
}, 30000);
- afterAll(() => cleanupTestBrowser({ browser, proc, cleanup: cleanupTempDataRoots }));
+ afterAll(() => _cleanupTestBrowser({ browser, proc, cleanup: cleanupTempDataRoots }));
it('awaits every seek, encodes exactly 12 frames, keeps the target hidden and registers a thumbnail', async () => {
const input = await composition();
diff --git a/server/services/htmlComposition/testBrowserCleanup.js b/server/services/htmlComposition/testBrowserCleanup.js
index d240e22aa4..a9da206b22 100644
--- a/server/services/htmlComposition/testBrowserCleanup.js
+++ b/server/services/htmlComposition/testBrowserCleanup.js
@@ -40,7 +40,7 @@ async function terminateOwnedChrome(proc) {
// Test-only lifecycle boundary. Disconnect failure must not strand the owned
// child, and neither failure may prevent removal of temporary test data.
-export async function cleanupTestBrowser({ browser, proc, cleanup }) {
+export async function _cleanupTestBrowser({ browser, proc, cleanup }) {
const errors = [];
try {
await withinDeadline(() => browser?.close(), 5000, 'browser disconnect').catch(error => errors.push(error));
diff --git a/server/services/htmlComposition/testBrowserCleanup.test.js b/server/services/htmlComposition/testBrowserCleanup.test.js
index 65d0723571..6f74d57617 100644
--- a/server/services/htmlComposition/testBrowserCleanup.test.js
+++ b/server/services/htmlComposition/testBrowserCleanup.test.js
@@ -1,6 +1,6 @@
import { EventEmitter } from 'node:events';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { cleanupTestBrowser } from './testBrowserCleanup.js';
+import { _cleanupTestBrowser } from './testBrowserCleanup.js';
function child() {
const proc = new EventEmitter();
@@ -31,7 +31,7 @@ describe('owned test Chrome cleanup', () => {
proc.signalCode = 'SIGTERM';
proc.emit('close', null, 'SIGTERM');
const cleanup = vi.fn();
- await cleanupTestBrowser({ proc, cleanup });
+ await _cleanupTestBrowser({ proc, cleanup });
expect(proc.kill).not.toHaveBeenCalled();
expect(cleanup).toHaveBeenCalledOnce();
expect(proc.listenerCount('close')).toBe(0);
@@ -44,7 +44,7 @@ describe('owned test Chrome cleanup', () => {
proc.signalCode = signal;
proc.emit('close', null, signal);
});
- await cleanupTestBrowser({ proc, cleanup: vi.fn() });
+ await _cleanupTestBrowser({ proc, cleanup: vi.fn() });
expect(proc.kill.mock.calls).toEqual([['SIGTERM']]);
expect(proc.listenerCount('close')).toBe(0);
expect(vi.getTimerCount()).toBe(0);
@@ -59,7 +59,7 @@ describe('owned test Chrome cleanup', () => {
}
});
const cleanup = vi.fn();
- const result = cleanupTestBrowser({ proc, cleanup });
+ const result = _cleanupTestBrowser({ proc, cleanup });
await vi.advanceTimersByTimeAsync(3000);
expect(proc.kill.mock.calls).toEqual([['SIGTERM'], ['SIGKILL']]);
expect(cleanup).not.toHaveBeenCalled();
@@ -73,7 +73,7 @@ describe('owned test Chrome cleanup', () => {
it('still terminates the child and cleans data when disconnect rejects', async () => {
const proc = child();
const cleanup = vi.fn();
- const result = cleanupTestBrowser({
+ const result = _cleanupTestBrowser({
browser: { close: () => Promise.reject(new Error('disconnect failed')) }, proc, cleanup,
});
const rejected = expect(result).rejects.toThrow('disconnect failed');
@@ -88,7 +88,7 @@ describe('owned test Chrome cleanup', () => {
const proc = child();
proc.kill.mockImplementation(() => true);
const cleanup = vi.fn();
- const result = cleanupTestBrowser({
+ const result = _cleanupTestBrowser({
browser: { close: () => new Promise(() => {}) }, proc, cleanup,
});
const rejected = expect(result).rejects.toThrow(