fix(serve): skip two Windows-incompatible test fixtures on win32

Both tests rely on `fs.chmod(dir, 0o555)` to trigger EACCES on a
subsequent write/unlink. Windows ignores Unix-style permission bits
passed to `fs.chmod`, so the directory stays writable, the operation
succeeds, and the error path the test exercises is unreachable —
the test then sees the success status (200 / 204) instead of the
expected 500. CI failed on Windows runner only; Ubuntu + macOS pass.

Route logic is platform-agnostic — these tests validate that:

- `workspaceMemory.test.ts` POST returns the structured 500 envelope
  (no `errorMessage` / `filePath` leakage outside QWEN_SERVE_DEBUG).
- `workspaceAgents.test.ts` DELETE returns 500 `agent_delete_partial`
  when one level's `fs.unlink` silently fails inside SubagentManager.

Both invariants are still covered by the Ubuntu + macOS runs. We can't
swap in a `vi.spyOn(fs, 'unlink')` mock for the agents case either —
`SubagentManager` does `import * as fs from 'fs/promises'`, creating
a sealed ESM namespace object vitest can't redefine.

Skip pattern mirrors `customBanner.test.ts:232`
(`if (process.platform === 'win32') return;`).
This commit is contained in:
doudouOUC 2026-05-18 14:00:45 +08:00
parent d598915be6
commit f693f742c5
2 changed files with 21 additions and 0 deletions

View file

@ -677,6 +677,18 @@ describe('workspace agents routes', () => {
});
it('returns 500 agent_delete_partial when one level unlink silently fails', async () => {
// Windows ignores Unix-style permission bits passed to
// `fs.chmod` — the user-agents directory stays writable, the
// unlink succeeds, and the partial-delete path this test
// exercises is unreachable. SubagentManager's `unlink` import
// (`import * as fs from 'fs/promises'`) creates a sealed
// namespace object that vitest can't `spyOn`, so a per-platform
// mock is also off-limits. The route logic itself is
// platform-agnostic; the Ubuntu + macOS runs cover it. Mirrors
// the `process.platform === 'win32'` early-return idiom used in
// `customBanner.test.ts:232`.
if (process.platform === 'win32') return;
const bridge = buildBridgeStub();
const app = buildApp({ bridge, boundWorkspace: workspace });

View file

@ -384,6 +384,15 @@ describe('workspace memory routes', () => {
});
it('omits errorMessage + filePath in 500/413 responses unless QWEN_SERVE_DEBUG is on', async () => {
// Windows ignores Unix-style permission bits passed to
// `fs.chmod` — the directory stays writable, the POST succeeds
// with 200, and the EACCES path this test exercises is
// unreachable. The route logic itself is platform-agnostic; the
// Ubuntu + macOS runs cover it. Mirrors the
// `process.platform === 'win32'` early-return idiom already used
// in `customBanner.test.ts:232`.
if (process.platform === 'win32') return;
// Default: production response carries no `errorMessage` or
// `filePath` fields — operators read the daemon stderr log
// for the path. Setting QWEN_SERVE_DEBUG=1 enables both.