wip
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import { describe, test, expect } from 'vitest'
|
||||
import type { Page } from 'playwright'
|
||||
import { PlaywrightAutomationAdapter } from 'packages/automation/infrastructure/adapters/automation'
|
||||
|
||||
describe('CarsFlow integration', () => {
|
||||
test('adapter emits panel-attached then action-started then action-complete for performAddCar', async () => {
|
||||
const adapter = new PlaywrightAutomationAdapter({})
|
||||
const adapter = new PlaywrightAutomationAdapter({}, undefined, undefined)
|
||||
const received: Array<{ type: string }> = []
|
||||
adapter.onLifecycle?.((e) => {
|
||||
received.push({ type: (e as { type: string }).type })
|
||||
adapter.onLifecycle?.((e: { type: string; actionId?: string; timestamp: number; payload?: any }) => {
|
||||
received.push({ type: e.type })
|
||||
})
|
||||
|
||||
|
||||
// Use mock page fixture: minimal object with required methods
|
||||
const mockPage = {
|
||||
waitForSelector: async () => {},
|
||||
@@ -16,7 +17,7 @@ describe('CarsFlow integration', () => {
|
||||
waitForTimeout: async () => {},
|
||||
click: async () => {},
|
||||
setDefaultTimeout: () => {},
|
||||
}
|
||||
} as unknown as Page
|
||||
|
||||
// call attachPanel which emits panel-attached and then action-started
|
||||
await adapter.attachPanel(mockPage, 'add-car')
|
||||
|
||||
@@ -45,6 +45,9 @@ describe('Overlay lifecycle (integration)', () => {
|
||||
info: (...args: unknown[]) => void;
|
||||
warn: (...args: unknown[]) => void;
|
||||
error: (...args: unknown[]) => void;
|
||||
fatal: (...args: unknown[]) => void;
|
||||
child: (...args: unknown[]) => LoggerLike;
|
||||
flush: (...args: unknown[]) => Promise<void>;
|
||||
};
|
||||
const logger = console as unknown as LoggerLike;
|
||||
|
||||
@@ -63,7 +66,7 @@ describe('Overlay lifecycle (integration)', () => {
|
||||
const ackPromise: Promise<ActionAck> = service.startAction(action);
|
||||
|
||||
expect(publisher.events.length).toBe(1);
|
||||
const first = publisher.events[0];
|
||||
const first = publisher.events[0]!;
|
||||
expect(first.type).toBe('modal-opened');
|
||||
expect(first.actionId).toBe('hosted-session');
|
||||
|
||||
@@ -84,8 +87,8 @@ describe('Overlay lifecycle (integration)', () => {
|
||||
expect(ack.id).toBe('hosted-session');
|
||||
expect(ack.status).toBe('confirmed');
|
||||
|
||||
expect(publisher.events[0].type).toBe('modal-opened');
|
||||
expect(publisher.events[0].actionId).toBe('hosted-session');
|
||||
expect(publisher.events[0]!.type).toBe('modal-opened');
|
||||
expect(publisher.events[0]!.actionId).toBe('hosted-session');
|
||||
});
|
||||
|
||||
it('emits panel-missing when cancelAction is called', async () => {
|
||||
@@ -96,6 +99,9 @@ describe('Overlay lifecycle (integration)', () => {
|
||||
info: (...args: unknown[]) => void;
|
||||
warn: (...args: unknown[]) => void;
|
||||
error: (...args: unknown[]) => void;
|
||||
fatal: (...args: unknown[]) => void;
|
||||
child: (...args: unknown[]) => LoggerLike;
|
||||
flush: (...args: unknown[]) => Promise<void>;
|
||||
};
|
||||
const logger = console as unknown as LoggerLike;
|
||||
|
||||
@@ -108,7 +114,7 @@ describe('Overlay lifecycle (integration)', () => {
|
||||
await service.cancelAction('hosted-session-cancel');
|
||||
|
||||
expect(publisher.events.length).toBe(1);
|
||||
const ev = publisher.events[0];
|
||||
const ev = publisher.events[0]!;
|
||||
expect(ev.type).toBe('panel-missing');
|
||||
expect(ev.actionId).toBe('hosted-session-cancel');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user