import { test, expect } from '@playwright/test'; test('channel: CREATE_PROCESS -> PROCESS_CREATED (flux minimal)', async ({ page }) => { await page.goto('/?e2e=1'); await page.evaluate(() => { const iframe = document.createElement('iframe'); iframe.src = '/?e2e=1'; iframe.id = 'app-frame'; document.body.appendChild(iframe); }); await page.exposeFunction('captureMessage', (data: any) => { (window as any).__lastMsg = data; }); await page.evaluate(() => { window.addEventListener('message', (ev) => { (window as any).captureMessage(ev.data); }); }); await page.waitForFunction(() => (window as any).__lastMsg?.type === 'LISTENING', { timeout: 5000 }); await page.evaluate(() => { const iframe = document.getElementById('app-frame') as HTMLIFrameElement; setTimeout(() => { iframe.contentWindow!.postMessage({ type: 'REQUEST_LINK', messageId: 'e2e-p1' }, window.origin); }, 50); }); await page.waitForFunction(() => (window as any).__lastMsg?.type === 'LINK_ACCEPTED'); const accepted: any = await page.evaluate(() => (window as any).__lastMsg); await page.evaluate((tokens) => { const iframe = document.getElementById('app-frame') as HTMLIFrameElement; const processData: any = { processName: 'E2E Process', description: 'Automated' }; const privateFields: string[] = []; const roles: Record = { pairing: { members: [], validation_rules: [{ quorum: 1.0, fields: ['processName','description'], min_sig_member: 1.0 }], storages: [] } }; iframe.contentWindow!.postMessage({ type: 'CREATE_PROCESS', processData, privateFields, roles, accessToken: tokens.accessToken, messageId: 'e2e-p2' }, window.origin); }, accepted); await page.waitForFunction(() => (window as any).__lastMsg?.type === 'PROCESS_CREATED'); const created: any = await page.evaluate(() => (window as any).__lastMsg); expect(created.processCreated?.processId).toBeTruthy(); });