2018-12-04 07:23:29 +00:00
|
|
|
import { loginAsFoobar } from '../roles'
|
|
|
|
import {
|
|
|
|
composeModalComposeButton,
|
|
|
|
getNthStatus,
|
|
|
|
getNthStatusContent,
|
|
|
|
getNthStatusOptionsButton,
|
|
|
|
modalDialog,
|
|
|
|
composeModalInput,
|
|
|
|
getNthStatusMediaImg,
|
|
|
|
composeModalPostPrivacyButton,
|
2018-12-13 07:45:52 +00:00
|
|
|
getComposeModalNthMediaAltInput,
|
|
|
|
getNthStatusSpoiler,
|
|
|
|
composeModalContentWarningInput,
|
|
|
|
dialogOptionsOption,
|
2019-07-20 04:08:17 +01:00
|
|
|
getNthReplyButton,
|
|
|
|
getNthComposeReplyInput,
|
|
|
|
getNthComposeReplyButton,
|
|
|
|
getUrl,
|
|
|
|
sleep,
|
|
|
|
getComposeModalNthMediaListItem,
|
|
|
|
composePoll,
|
|
|
|
pollButton,
|
|
|
|
getComposePollNthInput,
|
|
|
|
composeButton,
|
|
|
|
getNthStatusPollResult,
|
|
|
|
getComposePollNthInputInDialog,
|
|
|
|
composeInput,
|
|
|
|
composePollMultipleChoice,
|
|
|
|
composePollMultipleChoiceInDialog,
|
|
|
|
composePollExpiry,
|
|
|
|
composePollExpiryOption,
|
2019-09-17 08:19:53 +01:00
|
|
|
composePollExpiryInDialog, composeModalMediaSensitiveCheckbox, getNthStatusSensitiveMediaButton, getNthStatusAndImage
|
2018-12-04 07:23:29 +00:00
|
|
|
} from '../utils'
|
|
|
|
import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions'
|
2019-07-20 04:08:17 +01:00
|
|
|
import { POLL_EXPIRY_DEFAULT } from '../../src/routes/_static/polls'
|
2018-12-04 07:23:29 +00:00
|
|
|
|
|
|
|
fixture`121-delete-and-redraft.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('basic delete and redraft', async t => {
|
|
|
|
await postAs('foobar', 'hey ho this is grate')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey ho this is grate')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-12-04 07:23:29 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.expect(composeModalInput.value).contains('hey ho this is grate')
|
|
|
|
.expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
|
|
|
|
.typeText(composeModalInput, 'hey ho this is great', { replace: true, paste: true })
|
|
|
|
.click(composeModalComposeButton)
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey ho this is great')
|
2018-12-04 07:23:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('image with empty text delete and redraft', async t => {
|
|
|
|
await postEmptyStatusWithMediaAs('foobar', 'kitten2.jpg', 'what a kitteh')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusMediaImg(1).getAttribute('alt')).eql('what a kitteh')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-12-04 07:23:29 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.expect(composeModalInput.value).eql('')
|
2019-09-17 08:19:53 +01:00
|
|
|
.expect(composeModalMediaSensitiveCheckbox.checked).notOk()
|
2018-12-04 07:23:29 +00:00
|
|
|
.expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getComposeModalNthMediaListItem(1).getAttribute('aria-label')).eql('what a kitteh')
|
2018-12-04 07:23:29 +00:00
|
|
|
.expect(getComposeModalNthMediaAltInput(1).value).eql('what a kitteh')
|
|
|
|
.typeText(composeModalInput, 'I love this kitteh', { replace: true, paste: true })
|
|
|
|
.click(composeModalComposeButton)
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('I love this kitteh')
|
|
|
|
.expect(getNthStatusMediaImg(1).getAttribute('alt')).eql('what a kitteh')
|
2018-12-04 07:23:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('image with no alt delete and redraft', async t => {
|
|
|
|
await postEmptyStatusWithMediaAs('foobar', 'kitten3.jpg', '')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusMediaImg(1).getAttribute('alt')).eql('')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-12-04 07:23:29 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.expect(composeModalInput.value).eql('')
|
|
|
|
.expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getComposeModalNthMediaListItem(1).getAttribute('aria-label')).eql('media')
|
2018-12-04 07:23:29 +00:00
|
|
|
.expect(getComposeModalNthMediaAltInput(1).value).eql('')
|
|
|
|
.typeText(composeModalInput, 'oops forgot an alt', { replace: true, paste: true })
|
|
|
|
.typeText(getComposeModalNthMediaAltInput(1), 'lovely kitteh', { replace: true, paste: true })
|
|
|
|
.click(composeModalComposeButton)
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('oops forgot an alt')
|
|
|
|
.expect(getNthStatusMediaImg(1).getAttribute('alt')).eql('lovely kitteh')
|
2018-12-04 07:23:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('privacy and spoiler delete and redraft', async t => {
|
|
|
|
await postWithSpoilerAndPrivacyAs('foobar', 'this is hidden', 'click to see!', 'private')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusSpoiler(1).innerText).contains('click to see!')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-12-04 07:23:29 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.expect(composeModalInput.value).eql('this is hidden')
|
|
|
|
.expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Followers-only)')
|
|
|
|
.expect(composeModalContentWarningInput.value).eql('click to see!')
|
|
|
|
.typeText(composeModalContentWarningInput, 'no really, you should click this!', { replace: true, paste: true })
|
|
|
|
.click(composeModalComposeButton)
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusSpoiler(1).innerText).contains('no really, you should click this!')
|
2018-12-04 07:23:29 +00:00
|
|
|
})
|
2018-12-13 07:45:52 +00:00
|
|
|
|
|
|
|
test('delete and redraft reply', async t => {
|
|
|
|
await postAs('admin', 'hey hello')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey hello')
|
|
|
|
.click(getNthReplyButton(1))
|
|
|
|
.typeText(getNthComposeReplyInput(1), 'hello there admin', { paste: true })
|
|
|
|
.click(getNthComposeReplyButton(1))
|
|
|
|
.expect(getNthStatus(1).innerText).contains('@admin hello there admin')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-12-13 07:45:52 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.typeText(composeModalInput, ' oops forgot to say thank you')
|
|
|
|
.click(composeModalComposeButton)
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).match(/@admin hello there admin\s+oops forgot to say thank you/, {
|
2018-12-13 07:45:52 +00:00
|
|
|
timeout: 30000
|
|
|
|
})
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthStatus(1))
|
2018-12-13 07:45:52 +00:00
|
|
|
.expect(getUrl()).match(/statuses/)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey hello')
|
|
|
|
.expect(getNthStatusContent(2).innerText).match(/@admin hello there admin\s+oops forgot to say thank you/)
|
2018-12-13 07:45:52 +00:00
|
|
|
})
|
|
|
|
|
2019-07-09 04:51:30 +01:00
|
|
|
test('delete and redraft reply within thread', async t => {
|
2018-12-13 07:45:52 +00:00
|
|
|
await postAs('admin', 'this is a thread')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusContent(1).innerText).contains('this is a thread')
|
|
|
|
.click(getNthStatus(1))
|
2018-12-13 07:45:52 +00:00
|
|
|
.expect(getUrl()).match(/statuses/)
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2019-06-22 21:21:19 +01:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('this is a thread', { timeout: 30000 })
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthReplyButton(1))
|
2019-06-22 21:21:19 +01:00
|
|
|
await sleep(2000)
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.typeText(getNthComposeReplyInput(1), 'heyo', { paste: true })
|
|
|
|
.click(getNthComposeReplyButton(1))
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2019-06-22 21:21:19 +01:00
|
|
|
.expect(getNthStatus(2).innerText).contains('@admin heyo', { timeout: 30000 })
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthStatusOptionsButton(2))
|
2019-06-22 21:21:19 +01:00
|
|
|
await sleep(2000)
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2018-12-13 07:45:52 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2019-06-22 21:21:19 +01:00
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk({ timeout: 30000 })
|
2019-07-07 19:43:29 +01:00
|
|
|
await sleep(2000)
|
|
|
|
await t
|
2018-12-13 07:45:52 +00:00
|
|
|
.typeText(composeModalInput, ' update!', { paste: true })
|
2019-06-22 21:21:19 +01:00
|
|
|
await sleep(2000)
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2018-12-13 07:45:52 +00:00
|
|
|
.click(composeModalComposeButton)
|
2019-03-31 18:56:03 +01:00
|
|
|
await t
|
2019-06-22 21:21:19 +01:00
|
|
|
.expect(modalDialog.exists).notOk({ timeout: 20000 })
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(2).innerText).match(/@admin heyo\s+update!/, {
|
2018-12-13 07:45:52 +00:00
|
|
|
timeout: 30000
|
|
|
|
})
|
|
|
|
})
|
2018-12-19 08:57:56 +00:00
|
|
|
|
|
|
|
test('multiple paragraphs', async t => {
|
2019-08-03 21:49:37 +01:00
|
|
|
const text = 'hey ho\n\ndouble newline!\njust one newline\njust another newline\n\nanother double newline!'
|
2018-12-19 08:57:56 +00:00
|
|
|
await postAs('foobar', text)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatusContent(1).innerText).contains(text)
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-12-19 08:57:56 +00:00
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.expect(composeModalInput.value).eql(text)
|
|
|
|
.typeText(composeModalInput, '\n\nwoot', { paste: true })
|
|
|
|
.click(composeModalComposeButton)
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains(text + '\n\nwoot')
|
2018-12-19 08:57:56 +00:00
|
|
|
})
|
2019-07-20 04:08:17 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
2019-09-17 08:19:53 +01:00
|
|
|
|
|
|
|
test('delete and redraft sensitive', async t => {
|
|
|
|
await postEmptyStatusWithMediaAs('foobar', 'kitten2.jpg', 'what a sensitive kitteh', true)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.click(getNthStatusSensitiveMediaButton(1))
|
|
|
|
.expect(getNthStatusAndImage(1, 1).getAttribute('alt')).eql('what a sensitive kitteh')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
|
|
|
.click(dialogOptionsOption.withText('Delete and redraft'))
|
|
|
|
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
|
|
|
|
.expect(composeModalMediaSensitiveCheckbox.checked).ok()
|
|
|
|
})
|