Files
wursor/api/__tests__/sandbox/media-proxy.test.ts
T
SinachPat a037b882e9
Mirror to GitHub / mirror (push) Canceled after 0s
feat: Sprint 1 — Playwright e2e + sandbox orchestration (TDD)
- e2e: Playwright chat-flow (sign up -> chat) with api/web webServer harness
- api: sandbox services subset/media-proxy/manifest/gc + DockerClient contract
- api: SandboxManager orchestrator (fake-Docker tested); /health route
- 53 unit tests green; Playwright e2e green
2026-08-15 20:01:58 +01:00

27 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { mediaProxyTarget, resolveMediaPath, stageReplacement } from '../../src/sandbox/media-proxy.ts';
describe('media proxy', () => {
it('proxies an upload to the origin', () => {
expect(mediaProxyTarget('https://example.com', '/wp-content/uploads/2024/hero.jpg')).toBe(
'https://example.com/wp-content/uploads/2024/hero.jpg',
);
});
it('serves a staged replacement locally instead of proxying', () => {
const staged = new Set(['/wp-content/uploads/2024/hero.jpg']);
expect(resolveMediaPath('https://example.com', '/wp-content/uploads/2024/hero.jpg', staged)).toBe(
'/wp-content/uploads/2024/hero.jpg',
);
expect(resolveMediaPath('https://example.com', '/wp-content/uploads/2024/other.jpg', staged)).toBe(
'https://example.com/wp-content/uploads/2024/other.jpg',
);
});
it('copies a file only when it is replaced', () => {
expect(stageReplacement('https://example.com', '/wp-content/uploads/2024/hero.jpg', 12)).toEqual({
copiedPaths: ['/wp-content/uploads/2024/hero.jpg'],
});
});
});