Refactor infra tests, clean E2E step suites, and fix TS in tests
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
import { MockAutomationLifecycleEmitter } from '../../../mocks/MockAutomationLifecycleEmitter'
|
||||
import { OverlaySyncService } from 'packages/application/services/OverlaySyncService'
|
||||
|
||||
describe('renderer overlay integration', () => {
|
||||
test('renderer shows confirmed only after main acks confirmed', async () => {
|
||||
const emitter = new MockAutomationLifecycleEmitter()
|
||||
const publisher = { publish: async () => {} }
|
||||
const svc = new OverlaySyncService({ lifecycleEmitter: emitter as any, publisher: publisher as any, logger: console as any })
|
||||
|
||||
// simulate renderer request
|
||||
const promise = svc.startAction({ id: 'add-car', label: 'Adding...' })
|
||||
|
||||
// ack should be tentative until emitter emits action-started
|
||||
await new Promise((r) => setTimeout(r, 20))
|
||||
const tentative = await Promise.race([promise, Promise.resolve({ id: 'add-car', status: 'tentative' })])
|
||||
// since no events yet, should still be pending promise; but we assert tentative fallback works after timeout in other tests
|
||||
emitter.emit({ type: 'action-started', actionId: 'add-car', timestamp: Date.now() })
|
||||
const ack = await promise
|
||||
expect(ack.status).toBe('confirmed')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user