support flash

This commit is contained in:
Moon.eth
2026-08-03 15:28:51 +09:00
parent 1b14d94f6a
commit 7d16969f02
16 changed files with 599 additions and 9 deletions
+34
View File
@@ -5,6 +5,7 @@ import {
fetchQuotes,
postStatus,
setEmojiReaction,
uploadMedia,
updateProfileFields,
updatePublicProfile,
votePoll,
@@ -97,6 +98,39 @@ describe('updatePublicProfile', () => {
})
})
describe('media uploads', () => {
it('preserves an SWF file and its MIME type in the multipart upload', async () => {
const swf = new File(['flash bytes'], 'animation.swf', {
type: 'application/x-shockwave-flash',
})
const fetchMock = vi.fn(async (_url: string, init?: RequestInit) => {
const form = init?.body as FormData
expect(init?.method).toBe('POST')
expect(form.get('file')).toBe(swf)
expect((form.get('file') as File).name).toBe('animation.swf')
expect((form.get('file') as File).type).toBe('application/x-shockwave-flash')
return new Response(
JSON.stringify({
id: 'flash-1',
type: 'unknown',
url: 'https://media.example.test/animation.swf',
preview_url: null,
pleroma: { mime_type: 'application/x-shockwave-flash' },
}),
{ status: 200, headers: { 'Content-Type': 'application/json' } },
)
})
vi.stubGlobal('fetch', fetchMock)
await uploadMedia(new ApiClient('example.test', 'token'), swf)
expect(fetchMock).toHaveBeenCalledWith(
'https://example.test/api/v1/media',
expect.any(Object),
)
})
})
describe('poll endpoints', () => {
it('submits selected poll option indexes as JSON', async () => {
const fetchMock = vi.fn(async (_url: string, init?: RequestInit) => {