31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { jest } from '@jest/globals'
|
|
import { MockAutomationLifecycleEmitter } from '../mocks/MockAutomationLifecycleEmitter'
|
|
import { PlaywrightAutomationAdapter } from '../../../packages/infrastructure/adapters/automation/PlaywrightAutomationAdapter'
|
|
|
|
describe('CarsFlow integration', () => {
|
|
test('adapter emits panel-attached then action-started then action-complete for performAddCar', async () => {
|
|
const adapter = new PlaywrightAutomationAdapter({} as any)
|
|
const received: any[] = []
|
|
adapter.onLifecycle?.((e: any) => { received.push(e) })
|
|
|
|
// Use mock page fixture: minimal object with required methods
|
|
const mockPage: any = {
|
|
waitForSelector: async () => {},
|
|
evaluate: async () => {},
|
|
waitForTimeout: async () => {},
|
|
click: async () => {},
|
|
setDefaultTimeout: () => {},
|
|
}
|
|
|
|
// call attachPanel which emits panel-attached and then action-started
|
|
await adapter.attachPanel(mockPage, 'add-car')
|
|
|
|
// simulate complete event
|
|
await adapter.emitLifecycle?.({ type: 'action-complete', actionId: 'add-car', timestamp: Date.now() } as any)
|
|
|
|
const types = received.map(r => r.type)
|
|
expect(types.indexOf('panel-attached')).toBeGreaterThanOrEqual(0)
|
|
expect(types.indexOf('action-started')).toBeGreaterThanOrEqual(0)
|
|
expect(types.indexOf('action-complete')).toBeGreaterThanOrEqual(0)
|
|
})
|
|
}) |