fix: delete-and-redraft preserves polls (#1343)
* fix: delete-and-redraft preserves polls fixes #1342 * fix test
This commit is contained in:
parent
e5df77b2a8
commit
95a68e1fe2
|
@ -17,7 +17,12 @@ export async function deleteAndRedraft (status) {
|
||||||
description: _.description || '',
|
description: _.description || '',
|
||||||
data: _
|
data: _
|
||||||
})),
|
})),
|
||||||
inReplyToId: status.in_reply_to_id
|
inReplyToId: status.in_reply_to_id,
|
||||||
|
// note that for polls there is no real way to preserve the original expiry
|
||||||
|
poll: status.poll && {
|
||||||
|
multiple: !!status.poll.multiple,
|
||||||
|
options: (status.poll.options || []).map(option => option.title)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
let showComposeDialog = await dialogPromise
|
let showComposeDialog = await dialogPromise
|
||||||
showComposeDialog()
|
showComposeDialog()
|
||||||
|
|
|
@ -12,9 +12,27 @@ import {
|
||||||
getNthStatusSpoiler,
|
getNthStatusSpoiler,
|
||||||
composeModalContentWarningInput,
|
composeModalContentWarningInput,
|
||||||
dialogOptionsOption,
|
dialogOptionsOption,
|
||||||
getNthReplyButton, getNthComposeReplyInput, getNthComposeReplyButton, getUrl, sleep, getComposeModalNthMediaListItem
|
getNthReplyButton,
|
||||||
|
getNthComposeReplyInput,
|
||||||
|
getNthComposeReplyButton,
|
||||||
|
getUrl,
|
||||||
|
sleep,
|
||||||
|
getComposeModalNthMediaListItem,
|
||||||
|
composePoll,
|
||||||
|
pollButton,
|
||||||
|
getComposePollNthInput,
|
||||||
|
composeButton,
|
||||||
|
getNthStatusPollResult,
|
||||||
|
getComposePollNthInputInDialog,
|
||||||
|
composeInput,
|
||||||
|
composePollMultipleChoice,
|
||||||
|
composePollMultipleChoiceInDialog,
|
||||||
|
composePollExpiry,
|
||||||
|
composePollExpiryOption,
|
||||||
|
composePollExpiryInDialog
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions'
|
import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions'
|
||||||
|
import { POLL_EXPIRY_DEFAULT } from '../../src/routes/_static/polls'
|
||||||
|
|
||||||
fixture`121-delete-and-redraft.js`
|
fixture`121-delete-and-redraft.js`
|
||||||
.page`http://localhost:4002`
|
.page`http://localhost:4002`
|
||||||
|
@ -172,3 +190,32 @@ test('multiple paragraphs', async t => {
|
||||||
.expect(modalDialog.exists).notOk()
|
.expect(modalDialog.exists).notOk()
|
||||||
.expect(getNthStatusContent(1).innerText).contains(text + '\n\nwoot')
|
.expect(getNthStatusContent(1).innerText).contains(text + '\n\nwoot')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('delete and redraft polls', async t => {
|
||||||
|
await loginAsFoobar(t)
|
||||||
|
await t
|
||||||
|
.click(pollButton)
|
||||||
|
.expect(composePoll.exists).ok()
|
||||||
|
.typeText(composeInput, 'I love this poll', { paste: true })
|
||||||
|
.typeText(getComposePollNthInput(1), 'foo', { paste: true })
|
||||||
|
.typeText(getComposePollNthInput(2), 'bar', { paste: true })
|
||||||
|
.click(composePollExpiry)
|
||||||
|
.click(composePollExpiryOption.withText('6 hours'))
|
||||||
|
.click(composePollMultipleChoice)
|
||||||
|
await sleep(1000)
|
||||||
|
await t
|
||||||
|
.click(composeButton)
|
||||||
|
.expect(getNthStatusContent(1).innerText).contains('I love this poll')
|
||||||
|
.expect(getNthStatusPollResult(1, 1).innerText).eql('0% foo')
|
||||||
|
.expect(getNthStatusPollResult(1, 2).innerText).eql('0% bar')
|
||||||
|
await sleep(1000)
|
||||||
|
await t
|
||||||
|
.click(getNthStatusOptionsButton(1))
|
||||||
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
||||||
|
.expect(composeModalInput.value).eql('I love this poll')
|
||||||
|
.expect(getComposePollNthInputInDialog(1).value).eql('foo')
|
||||||
|
.expect(getComposePollNthInputInDialog(2).value).eql('bar')
|
||||||
|
// there is no way to preserve poll expiry unfortunately
|
||||||
|
.expect(composePollExpiryInDialog.value).eql(POLL_EXPIRY_DEFAULT.toString())
|
||||||
|
.expect(composePollMultipleChoiceInDialog.checked).eql(true)
|
||||||
|
})
|
||||||
|
|
|
@ -65,7 +65,10 @@ export const composeModalPostPrivacyButton = $('.modal-dialog .compose-box-toolb
|
||||||
|
|
||||||
export const composePoll = $('.compose-poll')
|
export const composePoll = $('.compose-poll')
|
||||||
export const composePollMultipleChoice = $('.compose-poll input[type="checkbox"]')
|
export const composePollMultipleChoice = $('.compose-poll input[type="checkbox"]')
|
||||||
|
export const composePollMultipleChoiceInDialog = $('.modal-dialog .compose-poll input[type="checkbox"]')
|
||||||
export const composePollExpiry = $('.compose-poll select')
|
export const composePollExpiry = $('.compose-poll select')
|
||||||
|
export const composePollExpiryOption = $('.compose-poll select option')
|
||||||
|
export const composePollExpiryInDialog = $('.modal-dialog .compose-poll select')
|
||||||
export const composePollAddButton = $('.compose-poll button:last-of-type')
|
export const composePollAddButton = $('.compose-poll button:last-of-type')
|
||||||
|
|
||||||
export const postPrivacyDialogButtonUnlisted = $('[aria-label="Post privacy dialog"] li:nth-child(2) button')
|
export const postPrivacyDialogButtonUnlisted = $('[aria-label="Post privacy dialog"] li:nth-child(2) button')
|
||||||
|
@ -265,6 +268,10 @@ export function getComposePollNthInput (n) {
|
||||||
return $(`.compose-poll input[type="text"]:nth-of-type(${n})`)
|
return $(`.compose-poll input[type="text"]:nth-of-type(${n})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getComposePollNthInputInDialog (n) {
|
||||||
|
return $(`.modal-dialog .compose-poll input[type="text"]:nth-of-type(${n})`)
|
||||||
|
}
|
||||||
|
|
||||||
export function getComposePollRemoveNthButton (n) {
|
export function getComposePollRemoveNthButton (n) {
|
||||||
return $(`.compose-poll button:nth-of-type(${n})`)
|
return $(`.compose-poll button:nth-of-type(${n})`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue