2018-03-01 03:45:29 +01:00
|
|
|
import {
|
2020-06-29 08:12:14 +02:00
|
|
|
composeButton,
|
|
|
|
composeInput,
|
|
|
|
composeLengthIndicator,
|
|
|
|
emojiButton,
|
|
|
|
emojiSearchInput,
|
|
|
|
firstEmojiInPicker,
|
|
|
|
getComposeSelectionStart,
|
|
|
|
getNthStatusContent,
|
|
|
|
getUrl,
|
|
|
|
homeNavButton,
|
|
|
|
notificationsNavButton,
|
|
|
|
sleep,
|
2018-04-19 05:43:13 +02:00
|
|
|
times
|
2018-03-01 03:45:29 +01:00
|
|
|
} from '../utils'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-03-01 03:45:29 +01:00
|
|
|
|
2018-03-07 06:32:51 +01:00
|
|
|
fixture`012-compose.js`
|
2018-03-01 03:45:29 +01:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('shows compose limits', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-01 03:45:29 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.expect(composeLengthIndicator.innerText).eql('500')
|
2018-03-23 01:55:35 +01:00
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
2018-03-01 03:45:29 +01:00
|
|
|
.typeText(composeInput, 'typing some text')
|
|
|
|
.expect(composeLengthIndicator.innerText).eql('484')
|
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
2018-08-30 06:42:57 +02:00
|
|
|
.typeText(composeInput, times(50, () => 'hello world').join(' '), { replace: true, paste: true })
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeLengthIndicator.innerText).eql('-99')
|
|
|
|
.expect(composeButton.getAttribute('disabled')).eql('')
|
2018-08-30 06:42:57 +02:00
|
|
|
.typeText(composeInput, 'hello world', { replace: true })
|
2018-03-01 03:45:29 +01:00
|
|
|
.click(notificationsNavButton)
|
|
|
|
.expect(getUrl()).contains('/notifications')
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
|
|
|
.expect(composeInput.value).eql('hello world')
|
|
|
|
.expect(composeLengthIndicator.innerText).eql('489')
|
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
|
|
|
.selectText(composeInput)
|
|
|
|
.pressKey('delete')
|
|
|
|
.expect(composeInput.value).eql('')
|
|
|
|
.expect(composeLengthIndicator.innerText).eql('500')
|
2018-03-23 01:55:35 +01:00
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
2018-03-01 03:45:29 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('shows compose limits for URLs/handles', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeLengthIndicator.innerText).eql('500')
|
2018-03-23 01:55:35 +01:00
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
2018-03-01 03:45:29 +01:00
|
|
|
.typeText(composeInput, 'hello world ' +
|
|
|
|
'http://foo.bar.baz.whatever.example.com/hello ' +
|
2018-08-30 06:42:57 +02:00
|
|
|
'@reallylongnamethatstretchesonandon@foo.example.com', { paste: true })
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeLengthIndicator.innerText).eql('429')
|
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('shows compose limits for emoji', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-01 03:45:29 +01:00
|
|
|
.typeText(composeInput, 'hello world \ud83c\ude01 \ud83d\udc6a')
|
|
|
|
.expect(composeLengthIndicator.innerText).eql('485')
|
|
|
|
.expect(composeButton.hasAttribute('disabled')).notOk()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('shows compose limits for custom emoji', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-01 03:45:29 +01:00
|
|
|
.typeText(composeInput, 'hello world ')
|
|
|
|
.click(emojiButton)
|
2018-12-18 09:43:51 +01:00
|
|
|
.typeText(emojiSearchInput, 'blobnom')
|
2020-06-29 08:12:14 +02:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
|
|
|
.click(firstEmojiInPicker)
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeInput.value).eql('hello world :blobnom: ')
|
|
|
|
.expect(composeLengthIndicator.innerText).eql('478')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('inserts custom emoji correctly', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-01 03:45:29 +01:00
|
|
|
.typeText(composeInput, 'hello world')
|
|
|
|
.selectText(composeInput, 6, 6)
|
|
|
|
.expect(getComposeSelectionStart()).eql(6)
|
|
|
|
.click(emojiButton)
|
2018-12-18 09:43:51 +01:00
|
|
|
.typeText(emojiSearchInput, 'blobpats')
|
2020-06-29 08:12:14 +02:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
|
|
|
.click(firstEmojiInPicker)
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeInput.value).eql('hello :blobpats: world')
|
|
|
|
.selectText(composeInput, 0, 0)
|
|
|
|
.expect(getComposeSelectionStart()).eql(0)
|
|
|
|
.click(emojiButton)
|
2018-12-18 09:43:51 +01:00
|
|
|
.typeText(emojiSearchInput, 'blobnom')
|
2020-06-29 08:12:14 +02:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
|
|
|
.click(firstEmojiInPicker)
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeInput.value).eql(':blobnom: hello :blobpats: world')
|
|
|
|
.typeText(composeInput, ' foobar ')
|
|
|
|
.click(emojiButton)
|
2018-12-18 09:43:51 +01:00
|
|
|
.typeText(emojiSearchInput, 'blobpeek')
|
2020-06-29 08:12:14 +02:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
|
|
|
.click(firstEmojiInPicker)
|
2018-03-01 03:45:29 +01:00
|
|
|
.expect(composeInput.value).eql(':blobnom: hello :blobpats: world foobar :blobpeek: ')
|
|
|
|
})
|
2018-03-01 06:03:21 +01:00
|
|
|
|
|
|
|
test('inserts emoji without typing anything', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
2019-02-28 17:56:38 +01:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
2018-03-01 06:03:21 +01:00
|
|
|
.click(emojiButton)
|
2020-06-29 08:12:14 +02:00
|
|
|
.click(firstEmojiInPicker)
|
|
|
|
.expect(composeInput.value).eql(':blobnom: ')
|
2019-02-28 17:56:38 +01:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
2019-03-24 00:23:20 +01:00
|
|
|
.click(emojiButton)
|
2020-06-29 08:12:14 +02:00
|
|
|
.click(firstEmojiInPicker)
|
|
|
|
.expect(composeInput.value).eql(':blobnom: :blobnom: ')
|
2018-03-01 06:03:21 +01:00
|
|
|
})
|
2018-08-27 03:54:59 +02:00
|
|
|
|
2018-12-18 09:43:51 +01:00
|
|
|
test('inserts native emoji without typing anything', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(emojiButton)
|
2019-02-28 17:56:38 +01:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
|
|
|
.expect(emojiSearchInput.value).eql('')
|
|
|
|
.typeText(emojiSearchInput, 'pineapple', { paste: true })
|
|
|
|
await sleep(1000)
|
|
|
|
await t
|
2020-06-29 08:12:14 +02:00
|
|
|
.click(firstEmojiInPicker)
|
2018-12-18 09:43:51 +01:00
|
|
|
.expect(composeInput.value).eql('\ud83c\udf4d ')
|
|
|
|
.click(emojiButton)
|
2019-02-28 17:56:38 +01:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
|
|
|
.expect(emojiSearchInput.value).eql('')
|
|
|
|
.typeText(emojiSearchInput, 'elephant', { paste: true })
|
|
|
|
await sleep(1000)
|
|
|
|
await t
|
2020-06-29 08:12:14 +02:00
|
|
|
.click(firstEmojiInPicker)
|
2018-12-18 09:43:51 +01:00
|
|
|
.expect(composeInput.value).eql('\ud83d\udc18 \ud83c\udf4d ')
|
|
|
|
})
|
|
|
|
|
2018-08-27 03:54:59 +02:00
|
|
|
test('cannot post an empty status', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('pinned toot 1')
|
2018-08-27 03:54:59 +02:00
|
|
|
.click(composeButton)
|
|
|
|
await sleep(2)
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('pinned toot 1')
|
2018-08-27 03:54:59 +02:00
|
|
|
})
|