Files
Moh e2e06be86e test: add comprehensive automated test coverage
- Vitest multi-project setup (unit / integration / component)
- Real-Postgres integration harness via in-process PGlite (TEST_DATABASE_URL
  override), migrations applied per worker; production code untouched
- Unit: routing, locale, validation/Zod schemas, metadata, mail, site-theme,
  marquee, media, portfolio helpers, plus architecture-rule tests
- Integration: Prisma data layer, API routes, and all server actions
- Component: UI primitives and form components (jsdom + Testing Library)
- 371 tests passing
2026-08-06 02:27:20 +02:00

24 lines
807 B
TypeScript

import { mkdirSync, unlinkSync, writeFileSync } from "fs";
import path from "path";
import { MEDIA_UPLOAD_ROOT } from "@/lib/media-storage";
/**
* Some sandboxed / read-only-mount environments allow writes but forbid `unlink`.
* Filesystem round-trip tests that create AND delete managed media files self-skip
* when deletion isn't permitted, so the suite stays green there while still running
* fully on a normal filesystem (developer machine / CI).
*/
export const canManageUploads: boolean = (() => {
try {
const dir = path.join(MEDIA_UPLOAD_ROOT, "tests");
mkdirSync(dir, { recursive: true });
const probe = path.join(dir, `.cap-probe-${process.pid}-${Date.now()}`);
writeFileSync(probe, "probe");
unlinkSync(probe);
return true;
} catch {
return false;
}
})();