2018-03-25 20:24:38 +01:00
|
|
|
import {
|
2018-04-21 22:57:02 +01:00
|
|
|
composeInput, getNthAutosuggestionResult, getNthComposeReplyInput, getNthReplyButton, getNthStatus, sleep
|
2018-03-25 20:24:38 +01:00
|
|
|
} from '../utils'
|
2018-04-20 14:26:36 +01:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-05-26 21:51:41 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-03-25 20:24:38 +01:00
|
|
|
|
|
|
|
fixture`018-compose-autosuggest.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
2018-04-21 22:57:02 +01:00
|
|
|
const timeout = 30000
|
|
|
|
|
2018-03-25 20:24:38 +01:00
|
|
|
test('autosuggests user handles', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-25 20:24:38 +01:00
|
|
|
.hover(composeInput)
|
2018-04-21 22:57:02 +01:00
|
|
|
await sleep(1000)
|
|
|
|
await t
|
2018-03-25 20:24:38 +01:00
|
|
|
.typeText(composeInput, 'hey @qu')
|
2018-08-30 05:42:57 +01:00
|
|
|
.click(getNthAutosuggestionResult(1), { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.expect(composeInput.value).eql('hey @quux ')
|
|
|
|
.typeText(composeInput, 'and also @adm')
|
2018-08-30 05:42:57 +01:00
|
|
|
.click(getNthAutosuggestionResult(1), { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.expect(composeInput.value).eql('hey @quux and also @admin ')
|
|
|
|
.typeText(composeInput, 'and also @AdM')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains('@admin', { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.pressKey('tab')
|
|
|
|
.expect(composeInput.value).eql('hey @quux and also @admin and also @admin ')
|
|
|
|
.typeText(composeInput, 'and @QU')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains('@quux', { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.pressKey('enter')
|
|
|
|
.expect(composeInput.value).eql('hey @quux and also @admin and also @admin and @quux ')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('autosuggests custom emoji', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-25 20:24:38 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, ':blob')
|
|
|
|
.click(getNthAutosuggestionResult(1))
|
|
|
|
.expect(composeInput.value).eql(':blobnom: ')
|
|
|
|
.typeText(composeInput, 'and :blob')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains(':blobnom:', { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.expect(getNthAutosuggestionResult(2).innerText).contains(':blobpats:')
|
|
|
|
.expect(getNthAutosuggestionResult(3).innerText).contains(':blobpeek:')
|
|
|
|
.pressKey('down')
|
|
|
|
.pressKey('down')
|
|
|
|
.pressKey('enter')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(composeInput.value).eql(':blobnom: and :blobpeek: ', { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.typeText(composeInput, 'and also :blobpa')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains(':blobpats:', { timeout })
|
2018-03-25 20:24:38 +01:00
|
|
|
.pressKey('tab')
|
|
|
|
.expect(composeInput.value).eql(':blobnom: and :blobpeek: and also :blobpats: ')
|
|
|
|
})
|
2018-04-18 02:38:36 +01:00
|
|
|
|
|
|
|
test('autosuggest custom emoji works with regular emoji - keyboard', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-18 02:38:36 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, '\ud83c\udf4d :blobno')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains(':blobnom:', { timeout })
|
2018-04-18 02:38:36 +01:00
|
|
|
.pressKey('enter')
|
|
|
|
.expect(composeInput.value).eql('\ud83c\udf4d :blobnom: ')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('autosuggest custom emoji works with regular emoji - clicking', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-18 02:38:36 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, '\ud83c\udf4d :blobno')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains(':blobnom:', { timeout })
|
2018-04-18 02:38:36 +01:00
|
|
|
.click(getNthAutosuggestionResult(1))
|
|
|
|
.expect(composeInput.value).eql('\ud83c\udf4d :blobnom: ')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('autosuggest handles works with regular emoji - keyboard', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-18 02:38:36 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, '\ud83c\udf4d @quu')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains('@quux', { timeout })
|
2018-04-18 02:38:36 +01:00
|
|
|
.pressKey('enter')
|
|
|
|
.expect(composeInput.value).eql('\ud83c\udf4d @quux ')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('autosuggest handles works with regular emoji - clicking', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-18 02:38:36 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, '\ud83c\udf4d @quu')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains('@quux', { timeout })
|
2018-04-18 02:38:36 +01:00
|
|
|
.click(getNthAutosuggestionResult(1))
|
|
|
|
.expect(composeInput.value).eql('\ud83c\udf4d @quux ')
|
|
|
|
})
|
2018-04-20 14:26:36 +01:00
|
|
|
|
|
|
|
test('autosuggest only shows for one input', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-20 14:26:36 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, '@quu')
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.click(getNthReplyButton(1))
|
|
|
|
.selectText(getNthComposeReplyInput(1))
|
2018-04-20 14:26:36 +01:00
|
|
|
.pressKey('delete')
|
2019-02-28 16:56:25 +00:00
|
|
|
.typeText(getNthComposeReplyInput(1), 'uu')
|
2018-04-20 14:26:36 +01:00
|
|
|
.expect($('.compose-autosuggest.shown').exists).notOk()
|
|
|
|
})
|
2018-04-21 22:57:02 +01:00
|
|
|
|
|
|
|
test('autosuggest only shows for one input part 2', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-21 22:57:02 +01:00
|
|
|
.hover(composeInput)
|
|
|
|
.typeText(composeInput, '@adm')
|
2018-08-30 05:42:57 +01:00
|
|
|
.expect($('.compose-autosuggest.shown').exists).ok({ timeout })
|
2018-04-21 22:57:02 +01:00
|
|
|
.expect(getNthAutosuggestionResult(1).innerText).contains('@admin')
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.click(getNthReplyButton(1))
|
|
|
|
.selectText(getNthComposeReplyInput(1))
|
2018-04-21 22:57:02 +01:00
|
|
|
.pressKey('delete')
|
2019-02-28 16:56:25 +00:00
|
|
|
.typeText(getNthComposeReplyInput(1), '@dd')
|
2018-04-21 22:57:02 +01:00
|
|
|
await sleep(1000)
|
|
|
|
await t.pressKey('backspace')
|
|
|
|
.expect($('.compose-autosuggest.shown').exists).notOk()
|
|
|
|
})
|