From 85636ce95c3ce41195c4748f3736f628f6558d5f Mon Sep 17 00:00:00 2001 From: BigBodyCobain <43977454+BigBodyCobain@users.noreply.github.com> Date: Wed, 6 May 2026 22:54:11 -0600 Subject: [PATCH] Stabilize secure mail warmup test --- .../__tests__/mesh/messagesViewFirstContact.test.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/__tests__/mesh/messagesViewFirstContact.test.tsx b/frontend/src/__tests__/mesh/messagesViewFirstContact.test.tsx index e7ef780..921bf5e 100644 --- a/frontend/src/__tests__/mesh/messagesViewFirstContact.test.tsx +++ b/frontend/src/__tests__/mesh/messagesViewFirstContact.test.tsx @@ -2,7 +2,7 @@ import '@testing-library/jest-dom/vitest'; import React from 'react'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen } from '@testing-library/react'; +import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'; let contactsState: Record = {}; @@ -300,11 +300,13 @@ describe('MessagesView first-contact trust UX', () => { renderMessagesView(); await openComposeForRecipient('!sb_pinned', 'hello after warmup'); - fireEvent.click(screen.getByRole('button', { name: 'Send Secure Mail' })); + const sendButton = screen.getByRole('button', { name: 'Send Secure Mail' }); + await waitFor(() => expect(sendButton).toBeEnabled(), { timeout: 5000 }); + fireEvent.click(sendButton); + await waitFor(() => expect(mocks.prepareWormholeInteractiveLane).toHaveBeenCalled(), { timeout: 5000 }); + await waitFor(() => expect(mocks.sendDmMessage).toHaveBeenCalled(), { timeout: 5000 }); await screen.findByText(/Mail delivered to Pinned Peer/i, {}, { timeout: 5000 }); - expect(mocks.prepareWormholeInteractiveLane).toHaveBeenCalled(); - expect(mocks.sendDmMessage).toHaveBeenCalled(); }, 10000); it('does not flatten witness policy not met into a generic witnessed root label', async () => {