From 4c519faaf748cea25f9d0be87dd0f3e09d7bae4c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Mar 2026 15:05:37 -0800 Subject: android hce nfc --- test/e2e/dm-subscribe.spec.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'test/e2e/dm-subscribe.spec.ts') diff --git a/test/e2e/dm-subscribe.spec.ts b/test/e2e/dm-subscribe.spec.ts index abc7c293..b2f7d6fa 100644 --- a/test/e2e/dm-subscribe.spec.ts +++ b/test/e2e/dm-subscribe.spec.ts @@ -81,22 +81,27 @@ test("recipient receives DM via relay subscription in real-time", async ({ brows await bobPage.goto(`/messages/${alicePubkey}`); await bobPage.waitForLoadState("domcontentloaded"); + // Wait for textarea to become enabled (canSend=true after relay query) const bobTextarea = bobPage.locator("#message-contents"); - await expect(bobTextarea).toBeVisible({ timeout: 15_000 }); + await expect(bobTextarea).toBeEnabled({ timeout: 15_000 }); - const sendButton = bobPage.locator("#send-message"); - await expect(sendButton).toBeEnabled({ timeout: 5_000 }); - - // --- Bob sends a message --- + // --- Bob sends a message (fill text first, then button enables) --- const testMessage = `realtime-test-${Date.now()}`; console.log(`[bob] Sending: ${testMessage}`); await bobTextarea.fill(testMessage); + const sendButton = bobPage.locator('button[aria-label="Send"]'); + await expect(sendButton).toBeEnabled({ timeout: 5_000 }); await sendButton.click(); await expect(bobTextarea).toHaveValue("", { timeout: 15_000 }); - console.log("[bob] Message sent"); - - // Verify Bob's relay accepted the events - const bobAccepts = bobWsFrames.filter((m) => m.includes('"OK"') && m.includes(",true,")); + console.log("[bob] Message sent (textarea cleared)"); + + // Wait for relay to accept events (publish is async after textarea clears) + let bobAccepts: string[] = []; + for (let i = 0; i < 30; i++) { + bobAccepts = bobWsFrames.filter((m) => m.includes('"OK"') && m.includes(",true,")); + if (bobAccepts.length > 0) break; + await bobPage.waitForTimeout(500); + } console.log(`[bob] Relay accepted ${bobAccepts.length} events`); expect(bobAccepts.length, "Relay should accept at least 1 event").toBeGreaterThanOrEqual(1); -- cgit v1.2.3