This commit is contained in:
2025-12-11 21:06:25 +01:00
parent c49ea2598d
commit ec3ddc3a5c
227 changed files with 3496 additions and 2083 deletions

View File

@@ -11,6 +11,13 @@
* - Electron build/init/DI smoke tests.
* - Domain and application unit/integration tests.
*
* This file is intentionally test-empty to avoid misleading Playwright+Electron
* coverage while keeping the historical entrypoint discoverable.
*/
* This file now contains a minimal Vitest suite to keep the historical
* entrypoint discoverable without failing the test runner.
*/
import { describe, it, expect } from 'vitest';
describe('companion-boot smoke (retired)', () => {
it('is documented as retired and covered elsewhere', () => {
expect(true).toBe(true);
});
});

View File

@@ -4,6 +4,13 @@
* Canonical boot coverage now lives in
* [companion-boot.smoke.test.ts](tests/smoke/companion-boot.smoke.test.ts).
*
* This file is intentionally test-empty to avoid duplicate or misleading
* coverage while keeping the historical entrypoint discoverable.
*/
* This file now contains a minimal Vitest suite to keep the historical
* entrypoint discoverable without failing the test runner.
*/
import { describe, it, expect } from 'vitest';
describe('electron-app smoke (superseded)', () => {
it('is documented as superseded and covered elsewhere', () => {
expect(true).toBe(true);
});
});

View File

@@ -3,15 +3,15 @@ import { execSync } from 'child_process';
/**
* Electron Build Smoke Test
*
* Purpose: Detect browser context errors during Electron build
*
*
* Purpose: Detect browser context errors during Electron build.
*
* This test catches bundling issues where Node.js modules are imported
* in the renderer process, causing runtime errors.
*
* RED Phase: This test MUST FAIL due to externalized modules
*
* It now runs under the Playwright test runner used by the smoke suite.
*/
test.describe('Electron Build Smoke Tests', () => {
test('should build Electron app without browser context errors', () => {
// When: Building the Electron companion app

View File

@@ -23,7 +23,7 @@ vi.mock('electron', () => ({
describe('Electron DIContainer Smoke Tests', () => {
beforeEach(() => {
(DIContainer as any).instance = undefined;
(DIContainer as typeof DIContainer & { instance?: unknown }).instance = undefined;
});
it('DIContainer initializes without errors', () => {

View File

@@ -29,22 +29,35 @@ export class IPCVerifier {
const channel = 'auth:check';
try {
const result = await this.app.evaluate(async ({ ipcMain }) => {
return new Promise((resolve) => {
// Simulate IPC invoke handler by calling the first registered handler for the channel
const handlers = (ipcMain as any).listeners('auth:check') || [];
const handler = handlers[0];
if (!handler) {
resolve({ error: 'Handler not registered' });
} else {
// Invoke the handler similar to ipcMain.handle invocation signature
// (event, ...args) => Promise
const mockEvent = {} as any;
Promise.resolve(handler(mockEvent)).then((res: any) => resolve(res)).catch((err: any) => resolve({ error: err && err.message ? err.message : String(err) }));
}
});
});
const result = await this.app.evaluate(
async ({ ipcMain }: { ipcMain: { listeners: (channel: string) => unknown[] } }) => {
return new Promise((resolve) => {
// Simulate IPC invoke handler by calling the first registered handler for the channel
const handlers = ipcMain.listeners('auth:check') || [];
const handler = handlers[0] as
| ((event: unknown, ...args: unknown[]) => unknown | Promise<unknown>)
| undefined;
if (!handler) {
resolve({ error: 'Handler not registered' });
} else {
// Invoke the handler similar to ipcMain.handle invocation signature
// (event, ...args) => Promise
const mockEvent: unknown = {};
Promise.resolve(handler(mockEvent))
.then((res: unknown) => resolve(res))
.catch((err: unknown) =>
resolve({
error:
err && err instanceof Error && err.message
? err.message
: String(err),
}),
);
}
});
},
);
const typed: IpcHandlerResult = result as IpcHandlerResult;
@@ -72,19 +85,32 @@ export class IPCVerifier {
const channel = 'browser-mode:get';
try {
const result = await this.app.evaluate(async ({ ipcMain }) => {
return new Promise((resolve) => {
const handlers = (ipcMain as any).listeners('browser-mode:get') || [];
const handler = handlers[0];
if (!handler) {
resolve({ error: 'Handler not registered' });
} else {
const mockEvent = {} as any;
Promise.resolve(handler(mockEvent)).then((res: any) => resolve(res)).catch((err: any) => resolve({ error: err && err.message ? err.message : String(err) }));
}
});
});
const result = await this.app.evaluate(
async ({ ipcMain }: { ipcMain: { listeners: (channel: string) => unknown[] } }) => {
return new Promise((resolve) => {
const handlers = ipcMain.listeners('browser-mode:get') || [];
const handler = handlers[0] as
| ((event: unknown, ...args: unknown[]) => unknown | Promise<unknown>)
| undefined;
if (!handler) {
resolve({ error: 'Handler not registered' });
} else {
const mockEvent: unknown = {};
Promise.resolve(handler(mockEvent))
.then((res: unknown) => resolve(res))
.catch((err: unknown) =>
resolve({
error:
err && err instanceof Error && err.message
? err.message
: String(err),
}),
);
}
});
},
);
const typed: IpcHandlerResult = result as IpcHandlerResult;
@@ -112,20 +138,38 @@ export class IPCVerifier {
const channel = 'start-automation';
try {
const result = await this.app.evaluate(async ({ ipcMain }) => {
return new Promise((resolve) => {
const handlers = (ipcMain as any).listeners('start-automation') || [];
const handler = handlers[0];
if (!handler) {
resolve({ error: 'Handler not registered' });
} else {
// Test with mock data
const mockEvent = {} as any;
Promise.resolve(handler(mockEvent, { sessionName: 'test', mode: 'test' })).then((res: any) => resolve(res)).catch((err: any) => resolve({ error: err && err.message ? err.message : String(err) }));
}
});
});
const result = await this.app.evaluate(
async ({ ipcMain }: { ipcMain: { listeners: (channel: string) => unknown[] } }) => {
return new Promise((resolve) => {
const handlers = ipcMain.listeners('start-automation') || [];
const handler = handlers[0] as
| ((
event: unknown,
payload: { sessionName: string; mode: string },
) => unknown | Promise<unknown>)
| undefined;
if (!handler) {
resolve({ error: 'Handler not registered' });
} else {
// Test with mock data
const mockEvent: unknown = {};
Promise.resolve(
handler(mockEvent, { sessionName: 'test', mode: 'test' }),
)
.then((res: unknown) => resolve(res))
.catch((err: unknown) =>
resolve({
error:
err && err instanceof Error && err.message
? err.message
: String(err),
}),
);
}
});
},
);
const typed: IpcHandlerResult = result as IpcHandlerResult;

View File

@@ -15,8 +15,7 @@ describe('Playwright Adapter Smoke Tests', () => {
}
throw reason;
};
const anyProcess = process as any;
anyProcess.on('unhandledRejection', unhandledRejectionHandler);
process.on('unhandledRejection', unhandledRejectionHandler);
});
afterEach(async () => {
@@ -40,8 +39,7 @@ describe('Playwright Adapter Smoke Tests', () => {
afterAll(() => {
if (unhandledRejectionHandler) {
const anyProcess = process as any;
anyProcess.removeListener('unhandledRejection', unhandledRejectionHandler);
process.removeListener('unhandledRejection', unhandledRejectionHandler);
unhandledRejectionHandler = null;
}
});