2018-04-12 06:55:11 +01:00
|
|
|
import {
|
|
|
|
composeButton, composeContentWarning, composeInput, contentWarningButton,
|
2018-06-09 05:54:21 +01:00
|
|
|
getNthShowOrHideButton, getNthStatus, getNthStatusSelector
|
2018-04-12 06:55:11 +01:00
|
|
|
} from '../utils'
|
2018-05-26 21:51:41 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 05:54:21 +01:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-04-12 06:55:11 +01:00
|
|
|
|
|
|
|
fixture`110-compose-content-warnings.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('content warnings are posted', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 05:42:57 +01:00
|
|
|
.typeText(composeInput, 'hello this is a toot', { paste: true })
|
2018-04-12 06:55:11 +01:00
|
|
|
.click(contentWarningButton)
|
2018-08-30 05:42:57 +01:00
|
|
|
.typeText(composeContentWarning, 'CW', { paste: true })
|
2018-04-12 06:55:11 +01:00
|
|
|
.click(composeButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-spoiler`).innerText).contains('CW', { timeout: 30000 })
|
|
|
|
.click(getNthShowOrHideButton(1))
|
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-content`).innerText).contains('hello this is a toot')
|
|
|
|
.click(getNthShowOrHideButton(1))
|
|
|
|
.expect(getNthStatus(1).innerText).notContains('hello this is a toot')
|
2018-04-12 06:55:11 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('content warnings are not posted if removed', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 05:42:57 +01:00
|
|
|
.typeText(composeInput, 'hi this is another toot', { paste: true })
|
2018-04-12 06:55:11 +01:00
|
|
|
.click(contentWarningButton)
|
2018-08-30 05:42:57 +01:00
|
|
|
.typeText(composeContentWarning, 'content warning!', { paste: true })
|
2018-04-12 06:55:11 +01:00
|
|
|
.click(contentWarningButton)
|
|
|
|
.expect(composeContentWarning.exists).notOk()
|
|
|
|
.click(composeButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).innerText).contains('hi this is another toot', { timeout: 30000 })
|
|
|
|
.expect(getNthStatus(1).innerText).notContains('content warning!')
|
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-content`).innerText).contains('hi this is another toot')
|
2018-04-12 06:55:11 +01:00
|
|
|
})
|
2018-04-14 23:50:06 +01:00
|
|
|
|
|
|
|
test('content warnings can have emoji', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2020-06-29 07:12:14 +01:00
|
|
|
.typeText(composeInput, 'I can: :blobnom: ')
|
2018-04-14 23:50:06 +01:00
|
|
|
.click(contentWarningButton)
|
|
|
|
.typeText(composeContentWarning, 'can you feel the :blobpats: tonight')
|
|
|
|
.click(composeButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).innerText).contains('can you feel the', { timeout: 30000 })
|
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-spoiler img.inline-custom-emoji`).getAttribute('alt')).eql(':blobpats:')
|
|
|
|
.click(getNthShowOrHideButton(1))
|
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-content img.inline-custom-emoji`).getAttribute('alt')).eql(':blobnom:')
|
2018-04-14 23:50:06 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('no XSS in content warnings or text', async t => {
|
2019-08-20 03:08:59 +01:00
|
|
|
const pwned1 = '<script>alert("pwned!")</script>'
|
|
|
|
const pwned2 = '<script>alert("pwned from CW!")</script>'
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-14 23:50:06 +01:00
|
|
|
.typeText(composeInput, pwned1)
|
|
|
|
.click(contentWarningButton)
|
|
|
|
.typeText(composeContentWarning, pwned2)
|
|
|
|
.click(composeButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-spoiler`).innerText).contains(pwned2)
|
|
|
|
.click(getNthShowOrHideButton(1))
|
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-content`).innerText).contains(pwned1)
|
2018-04-14 23:50:06 +01:00
|
|
|
})
|