2018-02-21 18:26:22 +01:00
|
|
|
import {
|
2018-03-16 04:31:58 +01:00
|
|
|
getNthStatus, scrollToStatus, closeDialogButton, modalDialogContents, getActiveElementClass, goBack, getUrl,
|
2018-04-17 18:44:28 +02:00
|
|
|
goBackButton, getActiveElementInnerText, getNthReplyButton, getActiveElementInsideNthStatus, focus,
|
2018-11-24 09:41:36 +01:00
|
|
|
getNthStatusSelector, getActiveElementTagName
|
2018-02-21 18:26:22 +01:00
|
|
|
} from '../utils'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 06:54:21 +02:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-11-12 21:59:47 +01:00
|
|
|
import { indexWhere } from '../../routes/_utils/arrays'
|
|
|
|
import { homeTimeline } from '../fixtures'
|
2018-02-21 18:26:22 +01:00
|
|
|
|
2018-03-07 06:32:51 +01:00
|
|
|
fixture`010-focus.js`
|
2018-02-21 18:26:22 +01:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('modal preserves focus', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 21:59:47 +01:00
|
|
|
|
|
|
|
let idx = indexWhere(homeTimeline, _ => _.content === "here's a video")
|
|
|
|
|
|
|
|
await scrollToStatus(t, idx)
|
2018-04-17 18:44:28 +02:00
|
|
|
// explicitly hover-focus-click
|
2018-11-12 21:59:47 +01:00
|
|
|
await t.hover($(`${getNthStatusSelector(idx)} .play-video-button`))
|
|
|
|
await focus(`${getNthStatusSelector(idx)} .play-video-button`)()
|
|
|
|
await t.click($(`${getNthStatusSelector(idx)} .play-video-button`))
|
2018-02-21 18:26:22 +01:00
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2018-03-16 07:01:38 +01:00
|
|
|
.expect(getActiveElementClass()).contains('play-video-button')
|
2018-11-12 21:59:47 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql(idx.toString())
|
2018-02-21 18:26:22 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('timeline preserves focus', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
2018-04-17 18:44:28 +02:00
|
|
|
// explicitly hover-focus-click
|
|
|
|
await t.hover(getNthStatus(0))
|
|
|
|
await focus(getNthStatusSelector(0))()
|
|
|
|
await t.click(getNthStatus(0))
|
2018-03-06 07:36:54 +01:00
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2018-02-21 18:26:22 +01:00
|
|
|
|
|
|
|
await goBack()
|
2018-03-16 04:31:58 +01:00
|
|
|
await t.expect(getUrl()).eql('http://localhost:4002/')
|
2018-03-16 07:01:38 +01:00
|
|
|
.expect(getActiveElementClass()).contains('status-article status-in-timeline')
|
2018-03-17 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('0')
|
2018-03-16 04:31:58 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('timeline link preserves focus', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 06:42:57 +02:00
|
|
|
.expect(getNthStatus(0).exists).ok({ timeout: 20000 })
|
2018-06-09 06:54:21 +02:00
|
|
|
.click($(`${getNthStatusSelector(0)} .status-header a`))
|
2018-03-16 04:31:58 +01:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
2018-03-21 04:28:53 +01:00
|
|
|
.expect(getNthStatus(0).exists).ok()
|
2018-03-16 04:31:58 +01:00
|
|
|
.expect(getActiveElementInnerText()).eql('admin')
|
2018-06-09 06:54:21 +02:00
|
|
|
.click($(`${getNthStatusSelector(0)} .status-sidebar`))
|
2018-03-17 02:48:24 +01:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
|
|
|
.expect(getActiveElementClass()).contains('status-sidebar')
|
2018-03-17 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('0')
|
2018-03-16 04:31:58 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('notification timeline preserves focus', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-16 04:31:58 +01:00
|
|
|
.navigateTo('/notifications')
|
|
|
|
await scrollToStatus(t, 5)
|
2018-06-09 06:54:21 +02:00
|
|
|
await t.click($(`${getNthStatusSelector(5)} .status-header a`))
|
2018-03-16 04:31:58 +01:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/notifications')
|
2018-03-21 04:28:53 +01:00
|
|
|
.expect(getNthStatus(0).exists).ok()
|
2018-03-16 04:31:58 +01:00
|
|
|
.expect(getActiveElementInnerText()).eql('quux')
|
2018-03-17 03:04:48 +01:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('5')
|
|
|
|
})
|
|
|
|
|
2018-03-21 04:28:53 +01:00
|
|
|
test('thread preserves focus', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-21 04:28:53 +01:00
|
|
|
.navigateTo('/accounts/3')
|
|
|
|
await scrollToStatus(t, 2)
|
|
|
|
await t.click(getNthStatus(2))
|
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2018-06-09 06:54:21 +02:00
|
|
|
.click($(`${getNthStatusSelector(24)} .status-sidebar`))
|
2018-03-21 04:28:53 +01:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).contains('/statuses/')
|
|
|
|
.expect(getNthStatus(24).exists).ok()
|
|
|
|
.expect(getActiveElementClass()).contains('status-sidebar')
|
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('24')
|
|
|
|
.click(getNthStatus(23))
|
2018-06-09 06:54:21 +02:00
|
|
|
.expect($(`${getNthStatusSelector(23)} .status-absolute-date`).exists).ok()
|
2018-03-21 04:28:53 +01:00
|
|
|
await goBack()
|
2018-06-09 06:54:21 +02:00
|
|
|
await t.expect($(`${getNthStatusSelector(24)} .status-absolute-date`).exists).ok()
|
2018-03-21 04:28:53 +01:00
|
|
|
.expect(getActiveElementClass()).contains('status-article status-in-timeline')
|
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('23')
|
|
|
|
})
|
|
|
|
|
2018-03-17 03:04:48 +01:00
|
|
|
test('reply preserves focus and moves focus to the text input', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 06:42:57 +02:00
|
|
|
.expect(getNthStatus(1).exists).ok({ timeout: 20000 })
|
2018-03-17 03:04:48 +01:00
|
|
|
.click(getNthReplyButton(1))
|
|
|
|
.expect(getActiveElementClass()).contains('compose-box-input')
|
2018-02-21 18:26:22 +01:00
|
|
|
})
|
2018-04-17 18:42:10 +02:00
|
|
|
|
2018-11-24 09:41:36 +01:00
|
|
|
test('focus main content element on index page load', async t => {
|
|
|
|
await t.expect(getActiveElementTagName()).match(/body/i)
|
2018-04-17 18:42:10 +02:00
|
|
|
})
|