Files
backnotprop__plannotator/apps/paste-service/core/handler.test.ts
Michael Ramos be2d06a7c2 Make HTML annotations render HTML by default
* feat(annotate): render html files by default

* fix(annotate): support raw html assets and sharing

* fix(annotate): address html first review followups

* fix(editor): avoid raw html sidebar init crash

* fix(annotate): support portable html shares

* fix(annotate): harden html share support

* fix(share): clear attachments when loading shared payloads

* fix(share): warn on remote share link failures

* perf(annotate): lazy-build html share payloads

* test(annotate): guard lazy html share generation

* test(annotate): drop flaky html share server test
2026-06-16 16:16:05 -07:00

41 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import {
createPaste,
DEFAULT_PASTE_MAX_SIZE,
} from "./handler";
import type { PasteStore } from "./storage";
class MemoryPasteStore implements PasteStore {
values = new Map<string, string>();
async put(id: string, data: string): Promise<void> {
this.values.set(id, data);
}
async get(id: string): Promise<string | null> {
return this.values.get(id) ?? null;
}
}
describe("paste payload limits", () => {
test("default limit accepts HTML-scale encrypted payloads above the old 512 KB ceiling", async () => {
const store = new MemoryPasteStore();
const result = await createPaste("x".repeat(600 * 1024), store);
expect(result.id).toHaveLength(8);
expect(store.values.get(result.id)).toHaveLength(600 * 1024);
});
test("rejects payloads above the default encrypted payload limit", async () => {
const store = new MemoryPasteStore();
await expect(createPaste("x".repeat(DEFAULT_PASTE_MAX_SIZE + 1), store))
.rejects
.toMatchObject({
status: 413,
message: "Payload too large (max 5 MB encrypted)",
});
});
});