2018-08-19 22:23:40 +00:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-08-20 01:03:26 +00:00
|
|
|
import {
|
2018-11-25 09:20:58 +00:00
|
|
|
displayNameInComposeBox,
|
|
|
|
generalSettingsButton,
|
|
|
|
getNthStatus,
|
|
|
|
getNthStatusSelector,
|
|
|
|
getUrl,
|
|
|
|
homeNavButton,
|
2018-08-20 01:03:26 +00:00
|
|
|
removeEmojiFromDisplayNamesInput,
|
|
|
|
settingsNavButton,
|
|
|
|
sleep
|
|
|
|
} from '../utils'
|
2018-11-25 09:20:58 +00:00
|
|
|
import { postAs, updateUserDisplayNameAs } from '../serverActions'
|
2018-08-19 22:23:40 +00:00
|
|
|
import { Selector as $ } from 'testcafe'
|
|
|
|
|
2019-04-20 16:12:30 +00:00
|
|
|
const rainbow = String.fromCodePoint(0x1F308)
|
|
|
|
|
2018-08-19 22:23:40 +00:00
|
|
|
fixture`118-display-name-custom-emoji.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('Can put custom emoji in display name', async t => {
|
|
|
|
await updateUserDisplayNameAs('foobar', 'foobar :blobpats:')
|
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-11-04 01:40:20 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).match(/\s*foobar\s*/)
|
2018-08-19 22:23:40 +00:00
|
|
|
.expect($('.compose-box-display-name img').getAttribute('alt')).eql(':blobpats:')
|
|
|
|
.click(displayNameInComposeBox)
|
|
|
|
.expect(getUrl()).contains('/accounts/2')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect($(`${getNthStatusSelector(1)} .status-author-name img`).getAttribute('alt')).eql(':blobpats:')
|
2018-08-19 22:23:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Cannot XSS using display name HTML', async t => {
|
|
|
|
await updateUserDisplayNameAs('foobar', '<script>alert("pwn")</script>')
|
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('<script>alert("pwn")</script>')
|
|
|
|
})
|
2018-08-20 01:03:26 +00:00
|
|
|
|
|
|
|
test('Can remove emoji from user display names', async t => {
|
2019-04-20 16:12:30 +00:00
|
|
|
await updateUserDisplayNameAs('foobar', `${rainbow} foo :blobpats: ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2019-04-20 16:12:30 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).eql(`${rainbow} foo ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect($('.compose-box-display-name img').exists).notOk()
|
2019-04-20 16:12:30 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).eql('foo')
|
2018-08-20 01:03:26 +00:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2019-04-20 16:12:30 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).eql(`${rainbow} foo ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Cannot remove emoji from user display names if result would be empty', async t => {
|
2019-04-20 16:12:30 +00:00
|
|
|
await updateUserDisplayNameAs('foobar', `${rainbow} :blobpats: ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-04-20 16:12:30 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).eql(`${rainbow} ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
2019-04-20 16:12:30 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).eql(`${rainbow} ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
2019-04-20 16:12:30 +00:00
|
|
|
.expect(displayNameInComposeBox.innerText).eql(`${rainbow} ${rainbow}`)
|
2018-08-20 01:03:26 +00:00
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2018-08-20 02:31:54 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Check status aria labels for de-emojified text', async t => {
|
2018-11-25 09:20:58 +00:00
|
|
|
await updateUserDisplayNameAs('foobar', `${rainbow} foo :blobpats: ${rainbow}`)
|
|
|
|
await postAs('foobar', 'hey ho lotsa emojos')
|
2018-08-20 02:31:54 +00:00
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(displayNameInComposeBox)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
new RegExp(`${rainbow} foo :blobpats: ${rainbow}, hey ho lotsa emojos, (.* ago|just now), @foobar, Public`, 'i')
|
|
|
|
)
|
2018-08-20 02:31:54 +00:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.click(displayNameInComposeBox)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
new RegExp(`foo, hey ho lotsa emojos, (.* ago|just now), @foobar, Public`, 'i')
|
|
|
|
)
|
2018-08-20 02:31:54 +00:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.click(displayNameInComposeBox)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
new RegExp(`${rainbow} foo :blobpats: ${rainbow}, hey ho lotsa emojos, (.* ago|just now), @foobar, Public`, 'i')
|
|
|
|
)
|
2018-08-20 01:03:26 +00:00
|
|
|
})
|
2018-08-20 03:25:28 +00:00
|
|
|
|
|
|
|
test('Check some odd emoji', async t => {
|
|
|
|
await updateUserDisplayNameAs('foobar', 'foo 🕹📺')
|
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('foo 🕹📺')
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('foo')
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('foo 🕹📺')
|
2018-12-01 08:10:30 +00:00
|
|
|
|
|
|
|
// clean up after all these tests are done
|
|
|
|
await updateUserDisplayNameAs('foobar', 'foobar')
|
2018-08-20 03:25:28 +00:00
|
|
|
})
|