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