mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
polls
This commit is contained in:
@@ -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,
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user