wip
This commit is contained in:
72
tests/smoke/electron-init.smoke.test.ts
Normal file
72
tests/smoke/electron-init.smoke.test.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { DIContainer } from '../../apps/companion/main/di-container';
|
||||
import { StartAutomationSessionUseCase } from '../../packages/application/use-cases/StartAutomationSessionUseCase';
|
||||
import { CheckAuthenticationUseCase } from '../../packages/application/use-cases/CheckAuthenticationUseCase';
|
||||
import { InitiateLoginUseCase } from '../../packages/application/use-cases/InitiateLoginUseCase';
|
||||
import { ClearSessionUseCase } from '../../packages/application/use-cases/ClearSessionUseCase';
|
||||
import { ConfirmCheckoutUseCase } from '../../packages/application/use-cases/ConfirmCheckoutUseCase';
|
||||
import { PlaywrightAutomationAdapter } from '../../packages/infrastructure/adapters/automation/PlaywrightAutomationAdapter';
|
||||
import { InMemorySessionRepository } from '../../packages/infrastructure/repositories/InMemorySessionRepository';
|
||||
import { NoOpLogAdapter } from '../../packages/infrastructure/adapters/logging/NoOpLogAdapter';
|
||||
|
||||
// Mock Electron's app module
|
||||
vi.mock('electron', () => ({
|
||||
app: {
|
||||
getPath: vi.fn((name: string) => {
|
||||
if (name === 'userData') return '/tmp/test-user-data';
|
||||
return '/tmp/test';
|
||||
}),
|
||||
getAppPath: vi.fn(() => '/tmp/test-app'),
|
||||
isPackaged: false,
|
||||
},
|
||||
}));
|
||||
|
||||
describe('Electron DIContainer Smoke Tests', () => {
|
||||
beforeEach(() => {
|
||||
DIContainer['instance'] = undefined;
|
||||
});
|
||||
|
||||
it('DIContainer initializes without errors', () => {
|
||||
expect(() => DIContainer.getInstance()).not.toThrow();
|
||||
});
|
||||
|
||||
it('All use cases are accessible', () => {
|
||||
const container = DIContainer.getInstance();
|
||||
|
||||
expect(() => container.getStartAutomationUseCase()).not.toThrow();
|
||||
expect(() => container.getCheckAuthenticationUseCase()).not.toThrow();
|
||||
expect(() => container.getInitiateLoginUseCase()).not.toThrow();
|
||||
expect(() => container.getClearSessionUseCase()).not.toThrow();
|
||||
expect(() => container.getConfirmCheckoutUseCase()).not.toThrow();
|
||||
});
|
||||
|
||||
it('Use case instances are available after initialization', () => {
|
||||
const container = DIContainer.getInstance();
|
||||
|
||||
// Verify all core use cases are available
|
||||
expect(container.getStartAutomationUseCase()).not.toBeNull();
|
||||
expect(container.getStartAutomationUseCase()).toBeDefined();
|
||||
|
||||
// These may be null in test mode, but should not throw
|
||||
expect(() => container.getCheckAuthenticationUseCase()).not.toThrow();
|
||||
expect(() => container.getInitiateLoginUseCase()).not.toThrow();
|
||||
expect(() => container.getClearSessionUseCase()).not.toThrow();
|
||||
});
|
||||
|
||||
it('Container provides access to dependencies', () => {
|
||||
const container = DIContainer.getInstance();
|
||||
|
||||
// Verify core dependencies are accessible
|
||||
expect(container.getSessionRepository()).toBeDefined();
|
||||
expect(container.getAutomationEngine()).toBeDefined();
|
||||
expect(container.getBrowserAutomation()).toBeDefined();
|
||||
expect(container.getLogger()).toBeDefined();
|
||||
});
|
||||
|
||||
it('ConfirmCheckoutUseCase can be verified without errors', () => {
|
||||
const container = DIContainer.getInstance();
|
||||
|
||||
// This getter should not throw even if null (verifies the import)
|
||||
expect(() => container.getConfirmCheckoutUseCase()).not.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user