From 8119bc34015c399c69a23fec5af63c8a4d45866f Mon Sep 17 00:00:00 2001 From: Huanqi Cao Date: Sun, 9 Aug 2026 10:51:02 +0800 Subject: [PATCH] test(sandbox): fix grant-count and dispose-warning assertions The reparse case reuses the standing workspace grant of the preceding case (same workspace -> map hit), so the failed temp grant is the third grant, not the fourth; the dispose-warning text carries 'failure(s)'. --- packages/sandbox/sandbox-local/tests/acl-session.spec.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/sandbox/sandbox-local/tests/acl-session.spec.ts b/packages/sandbox/sandbox-local/tests/acl-session.spec.ts index ff04b97360..560b16e865 100644 --- a/packages/sandbox/sandbox-local/tests/acl-session.spec.ts +++ b/packages/sandbox/sandbox-local/tests/acl-session.spec.ts @@ -323,8 +323,10 @@ describe('windows-acl write grants (LocalSandboxProvider)', () => { ctx.sessions.create(SessionId('reparse'), { seed: [recordEvent(linkRecord)], meta: { cwd: ws } }) const linkPolicy: SandboxPolicy = { mode: 'workspace-write', workspaceRoot: ws, sessionId: SessionId('reparse') } expect(() => sandbox.confine(['true'], linkPolicy)).toThrow(/EEXIST/) - expect(mockState.grants).toHaveLength(4) - expect(mockState.grants[3]!.disposed).toBe(true) + // Same workspace as the preexisting case: the standing workspace grant + // is the map hit (not recreated) — only the failed temp grant joins. + expect(mockState.grants).toHaveLength(3) + expect(mockState.grants[2]!.disposed).toBe(true) } finally { cleanup() } @@ -421,7 +423,7 @@ describe('windows-acl write grants (LocalSandboxProvider)', () => { const warn = vi.spyOn(ctx.logger, 'warn').mockImplementation(() => undefined) await fiber.dispose() // BOTH grants (standing workspace + revocable temp) fail their dispose. - expect(warn).toHaveBeenCalledWith(expect.stringContaining('cleanup completed with 2 failures')) + expect(warn).toHaveBeenCalledWith(expect.stringContaining('cleanup completed with 2 failure(s)')) expect(warn).toHaveBeenCalledWith(expect.objectContaining({ message: 'revoke exploded' })) } finally { cleanup()