Procházet zdrojové kódy

test: close the coverage gaps on the permission line

Two real branches gain assertions (effectivePermissionPreset's backward
scan over non-preset events; the popup options() throw when the projection
vanished between availability and open — a sync throw, not a rejection).
The empty ui-permission node half joins the ui-model entry on the
client-lane coverage debt list (same pure-UI plugin shape, same TODO).
imccyu před 2 měsíci
rodič
revize
728d28e7e4

+ 3 - 0
packages/client/ui-permission/tests/browser-plugin.spec.ts

@@ -81,6 +81,9 @@ describe('ui-permission browser plugin', () => {
     const again = await c.ui.options(proj, new AbortController().signal)
     expect(again.find(option => option.id === 'workspace-write')?.active).toBe(true)
     expect(again.find(option => option.id === 'read-only')?.detail).toBe('Reads only.')
+    // A projection that vanished between availability and open throws.
+    expect(() => c.ui.options({ sessionId: sid('ghost') }, new AbortController().signal))
+      .toThrow(/not available on this host/)
   })
 
   it('a pick submits the /permission line; rejection and unmatched throw', async () => {

+ 3 - 0
packages/ui/permission/tests/permission.spec.ts

@@ -34,6 +34,9 @@ describe('effectivePermissionPreset', () => {
     session.append('permission/preset', { preset: 'danger-full-access' })
     session.append('permission/preset', { preset: 'workspace-write' })
     expect(effectivePermissionPreset(session.events)).toBe('workspace-write')
+    // The backward scan steps over non-preset events to the latest selection.
+    session.append('sandbox/mode', { mode: 'read-only' })
+    expect(effectivePermissionPreset(session.events)).toBe('workspace-write')
   })
 })
 

+ 1 - 0
vitest.config.ts

@@ -138,6 +138,7 @@ export default defineConfig({
         'packages/client/ui-command/src/client/service.ts',
         'packages/client/ui-command/src/client/PopupSelectView.tsx',
         'packages/client/ui-model/src/index.ts',
+        'packages/client/ui-permission/src/index.ts',
         'packages/client/ui-model/src/client/ModelSelect.tsx',
         'packages/client/ui-model/src/client/directory.ts',
         'packages/client/ui-model/src/client/index.ts',