fix(create): prevent duplicate rapid submissions

This commit is contained in:
hzw
2026-09-18 23:13:32 +08:00
parent 9eb2fcd453
commit 878bd35cf4
3 changed files with 50 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
import { expect, test } from "bun:test";
import { createCreationSubmitGate } from "../src/pages/create/creation-submit-gate";
test("creation submit gate rejects a second submit until the first submit releases it", () => {
const gate = createCreationSubmitGate();
expect(gate.tryAcquire()).toBe(true);
expect(gate.tryAcquire()).toBe(false);
gate.release();
expect(gate.tryAcquire()).toBe(true);
});