hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits
| 1 | import { api, contractBaseUrl, expectPage, isLive, json, loginAdmin, pngFile, SKIP_MESSAGE } from "./helpers/live-client"; |
| 2 | |
| 3 | if (!isLive) console.warn(SKIP_MESSAGE); |
| 4 | |
| 5 | describe.skipIf(!isLive)(`content contract @ ${contractBaseUrl}`, () => { |
| 6 | let noteId = ""; |
| 7 | let eventId = ""; |
| 8 | |
| 9 | beforeAll(async () => { |
| 10 | await loginAdmin(); |
| 11 | const note = await json<{ id: string; title: string }>("/notes", { |
| 12 | method: "POST", |
| 13 | body: { title: `contract-note-${Date.now()}`, content: "contract body" }, |
| 14 | }); |
| 15 | noteId = note.id; |
| 16 | }); |
| 17 | |
| 18 | afterAll(async () => { |
| 19 | if (eventId) await api(`/events/${eventId}`, { method: "DELETE" }); |
| 20 | if (noteId) await api(`/notes/${noteId}`, { method: "DELETE" }); |
| 21 | }); |
| 22 | |
| 23 | it("supports note pagination and native multipart file lifecycle", async () => { |
| 24 | expectPage(await json("/notes?limit=1")); |
| 25 | const form = new FormData(); |
| 26 | form.append("file", pngFile("contract.png")); |
| 27 | const file = await json<{ id: string; content_type: string }>(`/notes/${noteId}/files`, { |
| 28 | method: "POST", |
| 29 | body: form, |
| 30 | }); |
| 31 | expect(file.content_type).toBe("image/png"); |
| 32 | expectPage(await json(`/notes/${noteId}/files?limit=10`)); |
| 33 | expect((await api(`/notes/${noteId}/files/${file.id}`, { method: "DELETE" })).status).toBe(204); |
| 34 | }); |
| 35 | |
| 36 | it("preserves event audience and paginated listing", async () => { |
| 37 | const event = await json<{ id: string; audience: { kind: string } }>("/events", { |
| 38 | method: "POST", |
| 39 | body: { title: `contract-event-${Date.now()}`, audience: { kind: "school" } }, |
| 40 | }); |
| 41 | eventId = event.id; |
| 42 | expect(event.audience.kind).toBe("school"); |
| 43 | expectPage(await json("/events?limit=1")); |
| 44 | }); |
| 45 | }); |