2018-08-19 23:23:40 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-08-20 02:03:26 +01:00
|
|
|
import {
|
2018-08-20 03:31:54 +01:00
|
|
|
avatarInComposeBox,
|
|
|
|
displayNameInComposeBox, generalSettingsButton, getNthStatus, getNthStatusSelector, getUrl, homeNavButton,
|
2018-08-20 02:03:26 +01:00
|
|
|
removeEmojiFromDisplayNamesInput,
|
|
|
|
settingsNavButton,
|
|
|
|
sleep
|
|
|
|
} from '../utils'
|
2018-08-19 23:23:40 +01:00
|
|
|
import { updateUserDisplayNameAs } from '../serverActions'
|
|
|
|
import { Selector as $ } from 'testcafe'
|
|
|
|
|
|
|
|
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
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('foobar ')
|
|
|
|
.expect($('.compose-box-display-name img').getAttribute('alt')).eql(':blobpats:')
|
|
|
|
.click(displayNameInComposeBox)
|
|
|
|
.expect(getUrl()).contains('/accounts/2')
|
|
|
|
.expect($(`${getNthStatusSelector(0)} .status-author-name img`).getAttribute('alt')).eql(':blobpats:')
|
|
|
|
})
|
|
|
|
|
|
|
|
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 02:03:26 +01:00
|
|
|
|
|
|
|
test('Can remove emoji from user display names', async t => {
|
|
|
|
await updateUserDisplayNameAs('foobar', '🌈 foo :blobpats: 🌈')
|
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('🌈 foo 🌈')
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2018-08-20 03:31:54 +01:00
|
|
|
.expect(avatarInComposeBox.getAttribute('aria-label')).eql('Profile for 🌈 foo :blobpats: 🌈')
|
2018-08-20 02:03:26 +01:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('foo')
|
|
|
|
.expect($('.compose-box-display-name img').exists).notOk()
|
2018-08-20 03:31:54 +01:00
|
|
|
.expect(avatarInComposeBox.getAttribute('aria-label')).eql('Profile for foo')
|
2018-08-20 02:03:26 +01:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('🌈 foo 🌈')
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2018-08-20 03:31:54 +01:00
|
|
|
.expect(avatarInComposeBox.getAttribute('aria-label')).eql('Profile for 🌈 foo :blobpats: 🌈')
|
2018-08-20 02:03:26 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Cannot remove emoji from user display names if result would be empty', async t => {
|
|
|
|
await updateUserDisplayNameAs('foobar', '🌈 :blobpats: 🌈')
|
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('🌈 🌈')
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2018-08-20 03:31:54 +01:00
|
|
|
.expect(avatarInComposeBox.getAttribute('aria-label')).eql('Profile for 🌈 :blobpats: 🌈')
|
2018-08-20 02:03:26 +01:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('🌈 🌈')
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2018-08-20 03:31:54 +01:00
|
|
|
.expect(avatarInComposeBox.getAttribute('aria-label')).eql('Profile for 🌈 :blobpats: 🌈')
|
2018-08-20 02:03:26 +01:00
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(displayNameInComposeBox.innerText).eql('🌈 🌈')
|
|
|
|
.expect($('.compose-box-display-name img').exists).ok()
|
2018-08-20 03:31:54 +01:00
|
|
|
.expect(avatarInComposeBox.getAttribute('aria-label')).eql('Profile for 🌈 :blobpats: 🌈')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Check status aria labels for de-emojified text', async t => {
|
|
|
|
await updateUserDisplayNameAs('foobar', '🌈 foo :blobpats: 🌈')
|
|
|
|
await sleep(1000)
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(displayNameInComposeBox)
|
|
|
|
.expect(getNthStatus(0).getAttribute('aria-label')).eql('Status by 🌈 foo :blobpats: 🌈')
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).ok()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.click(displayNameInComposeBox)
|
|
|
|
.expect(getNthStatus(0).getAttribute('aria-label')).eql('Status by foo')
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(removeEmojiFromDisplayNamesInput)
|
|
|
|
.expect(removeEmojiFromDisplayNamesInput.checked).notOk()
|
|
|
|
.click(homeNavButton)
|
|
|
|
.click(displayNameInComposeBox)
|
|
|
|
.expect(getNthStatus(0).getAttribute('aria-label')).eql('Status by 🌈 foo :blobpats: 🌈')
|
2018-08-20 02:03:26 +01:00
|
|
|
})
|
2018-08-20 04:25:28 +01: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 🕹📺')
|
|
|
|
})
|