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-07 08:14:19 +01:00
|
|
|
getNthReplyButton, getNthComposeReplyInput, getNthComposeReplyButton, getUrl, sleep, getComposeModalNthMediaListItem
|
2018-12-04 07:23:29 +00:00
|
|
|
} from '../utils'
|
|
|
|
import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions'
|
|
|
|
|
|
|
|
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('')
|
|
|
|
.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-07 19:43:29 +01:00
|
|
|
test.skip('delete and redraft reply within thread', async t => { // TODO: flaky test
|
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 => {
|
|
|
|
let text = 'hey ho\n\ndouble newline!\njust one newline\njust another newline\n\nanother double newline!'
|
|
|
|
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
|
|
|
})
|