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