From c8db8fa7eb823448f8e7af43685da219da4ab151 Mon Sep 17 00:00:00 2001 From: creatixchu Date: Tue, 20 Oct 2026 16:27:01 +0800 Subject: [PATCH] test(plugins): verify retained details across profile invalidation --- .../tests/browser-plugin.client.spec.tsx | 8 +++++--- .../ui-plugin-manager/tests/components.client.spec.tsx | 2 +- packages/experimental/cua/tests/mount.client.spec.ts | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/client/ui-plugin-manager/tests/browser-plugin.client.spec.tsx b/packages/client/ui-plugin-manager/tests/browser-plugin.client.spec.tsx index 1fc0573899..83f72145d7 100644 --- a/packages/client/ui-plugin-manager/tests/browser-plugin.client.spec.tsx +++ b/packages/client/ui-plugin-manager/tests/browser-plugin.client.spec.tsx @@ -215,15 +215,16 @@ describe('ui-plugin-manager browser plugin', () => { face.ensure() await vi.waitFor(() => { expect(face.hooks.pluginManager.getSnapshot().status).toBe('ready') }) expect(b.list).toHaveBeenCalledTimes(1) - // Bundle detail reads go to the Host by name; a profile change forgets them. + // A profile change invalidates reads without withdrawing the displayed document. face.loadDetail('dsh-a', '1.0.0', 'en', false) - await vi.waitFor(() => { expect(face.hooks.bundleDetails.getSnapshot()).not.toEqual({}) }) + await vi.waitFor(() => { expect(Object.values(face.hooks.bundleDetails.getSnapshot())[0]?.status).toBe('ready') }) + const loadedDetails = face.hooks.bundleDetails.getSnapshot() face.retryDetail('dsh-a', '1.0.0', 'en', false) expect(face.detailImage('dsh-a', 'README.md', 'a.png', false)).toContain('api/plugin-manager/detail-file?bundle=dsh-a') expect(face.hooks.locale.getSnapshot().active).toBe('zh') b.remote.emit('plugin-manager/changed', [{ reason: 'bundle' }]) await vi.waitFor(() => { expect(b.list).toHaveBeenCalledTimes(2) }) - expect(face.hooks.bundleDetails.getSnapshot()).toEqual({}) + expect(face.hooks.bundleDetails.getSnapshot()).toEqual(loadedDetails) b.ctx.emit('connection/reset') await vi.waitFor(() => { expect(b.list).toHaveBeenCalledTimes(3) }) @@ -239,6 +240,7 @@ describe('ui-plugin-manager browser plugin', () => { await fiber.dispose() expect(b.ctx.get('pluginNavigation')).toBeUndefined() + expect(b.ctx.get('pluginChanges')).toBeUndefined() expect(b.slots.entries('main')).toHaveLength(0) expect(b.slots.entries('shell.overlay')).toHaveLength(0) expect(b.slots.entries('sidebar.panellist')).toHaveLength(0) diff --git a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx index fb8fc11ac1..bc75e20f5d 100644 --- a/packages/client/ui-plugin-manager/tests/components.client.spec.tsx +++ b/packages/client/ui-plugin-manager/tests/components.client.spec.tsx @@ -502,7 +502,7 @@ describe('PluginManagerPage', () => { expect(document.querySelector('[data-detail-document]')).toBeNull() // A read the controller forgot, after a profile change, starts again. b.setDetails({}) - expect(b.actions.loadDetail).toHaveBeenCalledTimes(2) + expect(b.actions.loadDetail).toHaveBeenLastCalledWith('dsh-better-sidebar', '0.16.0', 'en', false) }) it('says where a bundle comes from: the spec that installs it, or built in, with its version', () => { diff --git a/packages/experimental/cua/tests/mount.client.spec.ts b/packages/experimental/cua/tests/mount.client.spec.ts index 75fde53950..0ce5391c79 100644 --- a/packages/experimental/cua/tests/mount.client.spec.ts +++ b/packages/experimental/cua/tests/mount.client.spec.ts @@ -207,6 +207,7 @@ it('resumes queries when a management operation settles without a mounted permis expect(actions.hooks.cuaPermissions.getSnapshot().changing).toBe(true) actions.refresh() f.ctx.emit('connection/reset') + await setImmediate() expect(f.status).not.toHaveBeenCalled() f.changes.set(false) await vi.waitFor(() => { expect(actions.hooks.cuaPermissions.getSnapshot().busy).toBe(false) })