diff --git a/packages/client/ui-settings-general/tests/components.client.spec.tsx b/packages/client/ui-settings-general/tests/components.client.spec.tsx index 4180646914..5d38c9e41f 100644 --- a/packages/client/ui-settings-general/tests/components.client.spec.tsx +++ b/packages/client/ui-settings-general/tests/components.client.spec.tsx @@ -57,6 +57,12 @@ describe('Desktop collapsed update badge', () => { state = { ...state, failed: true } view.rerender() expect(screen.getByRole('img', { name: en['desktop.update.retry'] }).getAttribute('data-error')).toBe('true') + state = { failed: true, opening: false } + view.rerender() + expect(screen.getByRole('img', { name: en['desktop.update.retry'] }).getAttribute('data-error')).toBe('true') + state = { failed: false, opening: false, presentation: { phase: 'error', failure: 'install' } } + view.rerender() + expect(screen.getByRole('img', { name: en['desktop.update.retry'] }).getAttribute('data-error')).toBe('true') for (const value of ['connecting', 'disconnected'] as const) { connection = value view.rerender() diff --git a/packages/client/ui-settings-general/tests/desktop-update.client.spec.tsx b/packages/client/ui-settings-general/tests/desktop-update.client.spec.tsx index eeaa288380..316204370d 100644 --- a/packages/client/ui-settings-general/tests/desktop-update.client.spec.tsx +++ b/packages/client/ui-settings-general/tests/desktop-update.client.spec.tsx @@ -138,3 +138,19 @@ it('renders the same semantic update in the active Web locale', async () => { expect(screen.getByRole('button', { name: 'Update' })).toBeTruthy() } finally { f.view.unmount(); f.status.resolve(available) } }) + +it('shows fallback progress and error details when the shell omits optional fields', async () => { + const f = fixture() + try { + await f.emit({ phase: 'downloading' }) + const progress = screen.getByRole('button', { name: '0%…' }) + fireEvent.focus(progress) + expect((await screen.findByRole('tooltip')).textContent).toBe('0%…') + await f.emit({ phase: 'downloading', version: '1.0.1' }) + fireEvent.focus(screen.getByRole('button', { name: '0%…' })) + expect((await screen.findByRole('tooltip')).textContent).toContain('1.0.1') + await f.emit({ phase: 'error' }) + fireEvent.focus(screen.getByRole('button', { name: '重试更新' })) + expect((await screen.findByRole('tooltip')).textContent).toBe('安装更新失败,请稍后重试。') + } finally { f.view.unmount(); f.status.resolve({ phase: 'idle' }) } +}) diff --git a/packages/client/ui-settings-general/tests/shell.client.spec.ts b/packages/client/ui-settings-general/tests/shell.client.spec.ts index b4e9e3b08e..bd24d3cd15 100644 --- a/packages/client/ui-settings-general/tests/shell.client.spec.ts +++ b/packages/client/ui-settings-general/tests/shell.client.spec.ts @@ -53,7 +53,8 @@ describe('ui-settings-general shell', () => { let publish: ((state: DesktopUpdatePresentation) => void) | undefined const off = vi.fn() const subscribe = vi.fn((listener: typeof publish) => { publish = listener; return off }) - vi.stubGlobal('dshDesktop', { protocolVersion: 1, updates: { status: () => initial.promise, subscribe, open: async () => {} } }) + const open = vi.fn(async () => {}) + vi.stubGlobal('dshDesktop', { protocolVersion: 1, updates: { status: () => initial.promise, subscribe, open } }) onTestFinished(() => { vi.unstubAllGlobals(); initial.resolve({ phase: 'idle' }) }) const c = await start() const row = injectedOf(c) @@ -63,6 +64,9 @@ describe('ui-settings-general shell', () => { const status = { phase: 'available' as const, version: '1.0.1' } publish!(status) expect(row.hooks.desktopUpdate.getSnapshot().presentation).toEqual(status) + row.openDesktopUpdate() + await c.flush() + expect(open).toHaveBeenCalledOnce() await c.unload(SELF) await c.flush() expect(off).toHaveBeenCalledOnce()