This commit is contained in:
Moon.eth
2026-07-29 19:37:17 +09:00
parent 4eb785b6ad
commit 8f0d47b850
10 changed files with 614 additions and 22 deletions
+55
View File
@@ -24,4 +24,59 @@ describe('Composer', () => {
visibility: 'public',
})
})
it('composes a multiple-choice poll without a backend', async () => {
const postStatus = vi.fn().mockResolvedValue(status())
const services = testServices({
session: session({
token: 'token',
me: account(),
signedIn: true,
instance: {
title: 'Pleroma',
version: '2.9.0',
configuration: {
polls: {
max_options: 4,
max_characters_per_option: 30,
min_expiration: 300,
max_expiration: 604_800,
},
},
},
}),
endpoints: { postStatus },
})
const view = render(Composer, {
props: { initialText: 'Which old web feature should return?' },
context: new Map([[APP_SERVICES, services]]),
})
await fireEvent.click(view.getByRole('button', { name: 'Poll' }))
await fireEvent.input(view.getByRole('textbox', { name: 'Poll option 1' }), {
target: { value: 'Guestbooks' },
})
await fireEvent.input(view.getByRole('textbox', { name: 'Poll option 2' }), {
target: { value: 'Webrings' },
})
await fireEvent.click(view.getByRole('button', { name: 'Add option' }))
await fireEvent.input(view.getByRole('textbox', { name: 'Poll option 3' }), {
target: { value: 'Blink tags' },
})
await fireEvent.click(view.getByRole('checkbox', { name: 'Allow multiple choices' }))
await fireEvent.change(view.getByLabelText('Keep open for'), {
target: { value: '3600' },
})
await fireEvent.click(view.getByRole('button', { name: 'Post Entry' }))
await waitFor(() => expect(postStatus).toHaveBeenCalledOnce())
expect(postStatus.mock.calls[0][1]).toMatchObject({
status: 'Which old web feature should return?',
poll: {
options: ['Guestbooks', 'Webrings', 'Blink tags'],
expires_in: 3600,
multiple: true,
},
})
})
})