mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
quote posts
This commit is contained in:
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { ApiClient } from './client'
|
||||
import {
|
||||
fetchNotifications,
|
||||
fetchQuotes,
|
||||
postStatus,
|
||||
setEmojiReaction,
|
||||
updateProfileFields,
|
||||
@@ -181,6 +182,58 @@ describe('emoji reaction endpoints', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('quote endpoints', () => {
|
||||
it('sends both current and legacy quote parameters when composing', async () => {
|
||||
const fetchMock = vi.fn(async (_url: string, init?: RequestInit) => {
|
||||
expect(JSON.parse(String(init?.body))).toMatchObject({
|
||||
status: 'Commentary',
|
||||
quoted_status_id: 'quoted/one',
|
||||
quote_id: 'quoted/one',
|
||||
})
|
||||
return new Response(JSON.stringify({ id: 'quote-1' }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
})
|
||||
vi.stubGlobal('fetch', fetchMock)
|
||||
|
||||
await postStatus(new ApiClient('example.test', 'token'), {
|
||||
status: 'Commentary',
|
||||
quoted_status_id: 'quoted/one',
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to the legacy Pleroma quote-list endpoint', async () => {
|
||||
const fetchMock = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(
|
||||
new Response(JSON.stringify({ error: 'Not found' }), {
|
||||
status: 404,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}),
|
||||
)
|
||||
.mockResolvedValueOnce(
|
||||
new Response(JSON.stringify([{ id: 'quote-1' }]), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}),
|
||||
)
|
||||
vi.stubGlobal('fetch', fetchMock)
|
||||
|
||||
const page = await fetchQuotes(new ApiClient('old-pleroma.example', 'token'), 'status/one', {
|
||||
limit: 20,
|
||||
})
|
||||
|
||||
expect(page.items).toEqual([{ id: 'quote-1' }])
|
||||
expect(fetchMock.mock.calls[0][0]).toBe(
|
||||
'https://old-pleroma.example/api/v1/statuses/status%2Fone/quotes?limit=20',
|
||||
)
|
||||
expect(fetchMock.mock.calls[1][0]).toBe(
|
||||
'https://old-pleroma.example/api/v1/pleroma/statuses/status%2Fone/quotes?limit=20',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchNotifications', () => {
|
||||
it('defensively applies requested types when a server ignores the filter', async () => {
|
||||
vi.stubGlobal(
|
||||
|
||||
Reference in New Issue
Block a user