Skip to content

The agent that grows with you

test(desktop): cover restart transitions and stale status copy

Yuan Lid6593c841d83
diff --git a/apps/desktop/src/components/update-status.test.tsx b/apps/desktop/src/components/update-status.test.tsx
index 1be0d8b25de..2c97d348a4a 100644
--- a/apps/desktop/src/components/update-status.test.tsx
+++ b/apps/desktop/src/components/update-status.test.tsx
@@ -5,6 +5,7 @@ import type { DesktopUpdateStatus, DesktopVersionInfo } from '@/global'
import { I18nProvider, type Locale, TRANSLATIONS, type Translations } from '@/i18n'
import { en } from '@/i18n/en'
import type { UpdateApplyState } from '@/store/updates'
+import { $backendUpdateApply, $backendUpdateStatus, $updateApply, $updateStatus } from '@/store/updates'
import { deriveUpdateStatus, UpdateStatusCard, VersionHero } from './update-status'
@@ -208,9 +209,34 @@ describe('deriveUpdateStatus', () => {
})
it('hides the client status card while a bundle restart is pending', () => {
- render(<UpdateStatusCard target="client" version={{ appVersion: '0.19.0', bundleSwapPending: true } as DesktopVersionInfo} />)
-
+ $updateApply.set(IDLE_APPLY)
+ $updateStatus.set({ supported: true, error: 'check-failed', message: 'ECONNREFUSED' })
+ const version = { appVersion: '0.19.0', bundleSwapPending: false } as DesktopVersionInfo
+ const { rerender, unmount } = render(<UpdateStatusCard target="client" version={version} />)
+
+ expect(screen.getByText(en.updates.cantReach)).toBeTruthy()
+ rerender(<UpdateStatusCard target="client" version={{ ...version, bundleSwapPending: true }} />)
+ expect(screen.queryByText(en.updates.cantReach)).toBeNull()
+ expect(screen.queryByText('ECONNREFUSED', { exact: false })).toBeNull()
expect(screen.queryByRole('button')).toBeNull()
+ rerender(<UpdateStatusCard target="client" version={version} />)
+ expect(screen.getByText(en.updates.cantReach)).toBeTruthy()
+ expect(screen.getByRole('button', { name: en.updates.checkNow })).toBeTruthy()
+ unmount()
+ $updateStatus.set(null)
+ })
+
+ it('keeps the independent backend status visible during a client restart', () => {
+ $backendUpdateApply.set(IDLE_APPLY)
+ $backendUpdateStatus.set({ supported: true, error: 'backend-check-failed' })
+
+ const { unmount } = render(
+ <UpdateStatusCard target="backend" version={{ appVersion: '0.19.0', bundleSwapPending: true } as DesktopVersionInfo} />
+ )
+
+ expect(screen.getByText(en.updates.cantReach)).toBeTruthy()
+ unmount()
+ $backendUpdateStatus.set(null)
})
it('backend target says the backend is current, not "you"', () => {