Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(desktop-app): l4 cover multi-overlay interaction keeps embed hidden

Diego Zacariasf7f0bdc39ea8
diff --git a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
index 59aaad3da..ea0baef60 100644
--- a/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SandboxUiPage.test.tsx
@@ -897,6 +897,53 @@ describe('SandboxUiPage', () => {
expect(sandboxUi.setVisible.mock.calls).toEqual([[true]])
})
+ it('keeps the native view hidden until the last of several overlays closes', async () => {
+ sandboxUi.listApps.mockResolvedValueOnce({
+ apps: [
+ {
+ appRef: 'sandbox-recipes/sales-crm',
+ title: "Andy's Sales CRM",
+ defaultPath: '/',
+ ready: true,
+ phase: 'active',
+ updatedAt: null,
+ },
+ ],
+ })
+ sandboxUi.open.mockResolvedValueOnce(undefined)
+ sandboxUi.capturePreview.mockResolvedValueOnce('data:image/png;base64,multi')
+
+ const { rerender } = render(<SandboxUiPage />)
+
+ fireEvent.click(await screen.findByRole('button', { name: "Open Andy's Sales CRM" }))
+ await screen.findByRole('button', { name: 'Back to apps' })
+ await waitFor(() => expect(sandboxUi.setVisible).toHaveBeenLastCalledWith(true))
+ sandboxUi.setVisible.mockClear()
+
+ // Two overlays open at once (a deep-link dialog and a header overlay); the
+ // native view must hide exactly once.
+ rerender(<SandboxUiPage deepLinkShellOverlayOpen headerShellOverlayOpen />)
+
+ await waitFor(() => expect(screen.getByTestId('sandbox-ui-embed-preview')).toBeTruthy())
+ expect(sandboxUi.setVisible.mock.calls).toEqual([[false]])
+
+ // Close only ONE overlay: the OR of the remaining overlays is still true, so
+ // the embed stays hidden and setVisible is not called again.
+ sandboxUi.setVisible.mockClear()
+ rerender(<SandboxUiPage deepLinkShellOverlayOpen />)
+
+ await waitFor(() => expect(sandboxUi.capturePreview).toHaveBeenCalledTimes(1))
+ expect(sandboxUi.setVisible).not.toHaveBeenCalled()
+ expect(screen.getByTestId('sandbox-ui-embed-preview')).toBeTruthy()
+
+ // Close the last overlay: only now is the native view restored.
+ sandboxUi.setVisible.mockClear()
+ rerender(<SandboxUiPage />)
+
+ await waitFor(() => expect(screen.queryByTestId('sandbox-ui-embed-preview')).toBeNull())
+ expect(sandboxUi.setVisible.mock.calls).toEqual([[true]])
+ })
+
it('hides an active native view even before local launch state is available', async () => {
sandboxUi.listApps.mockResolvedValueOnce({ apps: [] })
sandboxUi.capturePreview.mockResolvedValueOnce(null)