/** * Guard tests for `readAppFileBytes` — the byte-reading helper behind the app * asset endpoint (`GET /v1/apps/:appId/asset/:path*`, served to sandboxed apps * via `window.vellum.asset`). * * - Bytes round-trip intact (the point of the helper: utf-8 decoding would * corrupt binary media). * - Path validation still rejects traversal, absolute paths, and the * protected `records/` directory. */ import { mkdirSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { createApp, getAppDirPath, readAppFileBytes, } from "../apps/app-store.js"; let testDir: string; beforeEach(() => { testDir = join( tmpdir(), `vellum-app-asset-test-${Date.now()}-${Math.random().toString(36).slice(2)}`, ); process.env.VELLUM_WORKSPACE_DIR = testDir; }); afterEach(() => { rmSync(testDir, { recursive: true, force: true }); }); function makeApp(): string { return createApp({ name: "Asset Test", schemaJson: "{}", htmlDefinition: "