2018-02-21 17:26:22 +00:00
|
|
|
import {
|
2019-09-25 06:31:56 +01:00
|
|
|
getNthStatus,
|
|
|
|
scrollToStatus,
|
|
|
|
closeDialogButton,
|
|
|
|
modalDialogContents,
|
|
|
|
goBack,
|
|
|
|
getUrl,
|
|
|
|
goBackButton,
|
|
|
|
getActiveElementInnerText,
|
|
|
|
getNthReplyButton,
|
|
|
|
getActiveElementInsideNthStatus,
|
|
|
|
focus,
|
|
|
|
getNthStatusSelector,
|
|
|
|
getActiveElementTagName,
|
|
|
|
getActiveElementClassList,
|
|
|
|
getNthStatusSensitiveMediaButton,
|
2022-11-27 21:22:13 +00:00
|
|
|
getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton, getActiveElementId
|
2018-02-21 17:26:22 +00:00
|
|
|
} from '../utils'
|
2018-05-26 21:51:41 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 05:54:21 +01:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2019-03-31 17:21:57 +01:00
|
|
|
|
2018-11-12 20:59:47 +00:00
|
|
|
import { homeTimeline } from '../fixtures'
|
2018-02-21 17:26:22 +00:00
|
|
|
|
2018-03-07 05:32:51 +00:00
|
|
|
fixture`010-focus.js`
|
2018-02-21 17:26:22 +00:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('modal preserves focus', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 20:59:47 +00:00
|
|
|
|
2019-08-03 21:49:37 +01:00
|
|
|
const idx = homeTimeline.findIndex(_ => _.content === "here's a video")
|
2018-11-12 20:59:47 +00:00
|
|
|
|
2019-02-28 16:56:25 +00:00
|
|
|
await scrollToStatus(t, 1 + idx)
|
2018-04-17 17:44:28 +01:00
|
|
|
// explicitly hover-focus-click
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.hover($(`${getNthStatusSelector(1 + idx)} .play-video-button`))
|
|
|
|
await focus(`${getNthStatusSelector(1 + idx)} .play-video-button`)()
|
|
|
|
await t.click($(`${getNthStatusSelector(1 + idx)} .play-video-button`))
|
2018-02-21 17:26:22 +00:00
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2019-02-23 17:47:36 +00:00
|
|
|
.expect(getActiveElementClassList()).contains('play-video-button')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql((idx + 1).toString())
|
2018-02-21 17:26:22 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('timeline preserves focus', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
2018-04-17 17:44:28 +01:00
|
|
|
// explicitly hover-focus-click
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.hover(getNthStatus(1))
|
|
|
|
await focus(getNthStatusSelector(1))()
|
|
|
|
await t.click(getNthStatus(1))
|
2018-03-06 06:36:54 +00:00
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2018-02-21 17:26:22 +00:00
|
|
|
|
|
|
|
await goBack()
|
2018-03-16 03:31:58 +00:00
|
|
|
await t.expect(getUrl()).eql('http://localhost:4002/')
|
2019-02-23 17:47:36 +00:00
|
|
|
.expect(getActiveElementClassList()).contains('status-article')
|
|
|
|
.expect(getActiveElementClassList()).contains('status-in-timeline')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('1')
|
2018-03-16 03:31:58 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('timeline link preserves focus', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).exists).ok({ timeout: 20000 })
|
2022-11-27 21:22:13 +00:00
|
|
|
.click($(`${getNthStatusSelector(1)} .status-header-author`))
|
2018-03-16 03:31:58 +00:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).exists).ok()
|
2018-03-16 03:31:58 +00:00
|
|
|
.expect(getActiveElementInnerText()).eql('admin')
|
2019-02-28 16:56:25 +00:00
|
|
|
.click($(`${getNthStatusSelector(1)} .status-sidebar`))
|
2018-03-17 01:48:24 +00:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
2019-02-23 17:47:36 +00:00
|
|
|
.expect(getActiveElementClassList()).contains('status-sidebar')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('1')
|
2018-03-16 03:31:58 +00:00
|
|
|
})
|
|
|
|
|
2022-11-27 21:22:13 +00:00
|
|
|
test('timeline link preserves focus - reblogger avatar', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(getNthStatus(1).exists).ok({ timeout: 20000 })
|
|
|
|
|
|
|
|
const avatar = `${getNthStatusSelector(1)} .status-header-avatar a`
|
|
|
|
const id = await $(avatar).getAttribute('id')
|
|
|
|
await t
|
|
|
|
.click($(avatar))
|
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
|
|
|
.expect(getNthStatus(1).exists).ok()
|
|
|
|
.expect(getActiveElementId()).eql(id)
|
|
|
|
})
|
|
|
|
|
2018-03-16 03:31:58 +00:00
|
|
|
test('notification timeline preserves focus', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-16 03:31:58 +00:00
|
|
|
.navigateTo('/notifications')
|
2019-02-28 16:56:25 +00:00
|
|
|
await scrollToStatus(t, 6)
|
2022-11-27 21:22:13 +00:00
|
|
|
await t.click($(`${getNthStatusSelector(6)} .status-header-author`))
|
2018-03-16 03:31:58 +00:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
2019-02-24 00:09:48 +00:00
|
|
|
.expect(getUrl()).contains('/notifications')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).exists).ok()
|
2018-03-16 03:31:58 +00:00
|
|
|
.expect(getActiveElementInnerText()).eql('quux')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('6')
|
2018-03-17 02:04:48 +00:00
|
|
|
})
|
|
|
|
|
2019-02-23 17:47:36 +00:00
|
|
|
test('thread preserves focus', async t => {
|
2019-02-23 20:32:10 +00:00
|
|
|
const timeout = 30000
|
|
|
|
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-21 03:28:53 +00:00
|
|
|
.navigateTo('/accounts/3')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).exists).ok({ timeout })
|
|
|
|
.hover(getNthStatus(1))
|
|
|
|
await scrollToStatus(t, 3)
|
|
|
|
await t.click(getNthStatus(3))
|
2018-03-21 03:28:53 +00:00
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2019-02-28 16:56:25 +00:00
|
|
|
.click($(`${getNthStatusSelector(25)} .status-sidebar`))
|
2018-03-21 03:28:53 +00:00
|
|
|
.expect(getUrl()).contains('/accounts/')
|
|
|
|
.click(goBackButton)
|
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(25).exists).ok()
|
2019-02-23 17:47:36 +00:00
|
|
|
.expect(getActiveElementClassList()).contains('status-sidebar')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('25')
|
|
|
|
.hover(getNthStatus(24))
|
|
|
|
.click(getNthStatus(24))
|
|
|
|
.expect($(`${getNthStatusSelector(24)} .status-absolute-date`).exists).ok({ timeout })
|
2018-03-21 03:28:53 +00:00
|
|
|
await goBack()
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.expect($(`${getNthStatusSelector(25)} .status-absolute-date`).exists).ok({ timeout })
|
2019-02-23 20:32:10 +00:00
|
|
|
.expect(getActiveElementClassList()).contains('status-article', { timeout })
|
|
|
|
.expect(getActiveElementClassList()).contains('status-in-timeline', { timeout })
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getActiveElementInsideNthStatus()).eql('24', { timeout })
|
2018-03-21 03:28:53 +00:00
|
|
|
})
|
|
|
|
|
2018-03-17 02:04:48 +00:00
|
|
|
test('reply preserves focus and moves focus to the text input', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(2).exists).ok({ timeout: 20000 })
|
|
|
|
.click(getNthReplyButton(2))
|
2019-02-23 17:47:36 +00:00
|
|
|
.expect(getActiveElementClassList()).contains('compose-box-input')
|
2018-02-21 17:26:22 +00:00
|
|
|
})
|
2018-04-17 17:42:10 +01:00
|
|
|
|
2018-11-24 08:41:36 +00:00
|
|
|
test('focus main content element on index page load', async t => {
|
|
|
|
await t.expect(getActiveElementTagName()).match(/body/i)
|
2018-04-17 17:42:10 +01:00
|
|
|
})
|
2019-09-25 06:31:56 +01:00
|
|
|
|
|
|
|
test('clicking sensitive button returns focus to sensitive button', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
const sensitiveKittenIdx = homeTimeline.findIndex(_ => _.spoiler === 'kitten CW')
|
|
|
|
await scrollToStatus(t, sensitiveKittenIdx + 1)
|
|
|
|
await t
|
|
|
|
.click(getNthStatusSensitiveMediaButton(sensitiveKittenIdx + 1))
|
|
|
|
.expect(getActiveElementAriaLabel()).eql('Hide sensitive media')
|
|
|
|
.click(getNthStatusSensitiveMediaButton(sensitiveKittenIdx + 1))
|
|
|
|
.expect(getActiveElementAriaLabel()).eql('Show sensitive media')
|
|
|
|
})
|
2019-12-01 01:43:31 +00:00
|
|
|
|
|
|
|
test('preserves focus two levels deep', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.click($('.status-author-name').withText(('admin')))
|
|
|
|
.expect(getUrl()).contains('/accounts/1')
|
|
|
|
.click(getNthStatus(1))
|
|
|
|
.expect(getUrl()).contains('status')
|
|
|
|
await goBack()
|
|
|
|
await t
|
|
|
|
.expect(getUrl()).contains('/accounts/1')
|
|
|
|
.expect(getActiveElementClassList()).contains('status-article')
|
|
|
|
await goBack()
|
|
|
|
await t
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
|
|
|
.expect(getActiveElementClassList()).contains('status-author-name')
|
|
|
|
})
|
2019-12-09 02:03:26 +00:00
|
|
|
|
|
|
|
test('preserves focus on settings page', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click($('a[href="/settings/instances"]'))
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings/instances')
|
|
|
|
.click($('a[href="/settings/instances/add"]'))
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings/instances/add')
|
|
|
|
await goBack()
|
|
|
|
await t
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings/instances')
|
|
|
|
.expect(getActiveElementHref()).eql('/settings/instances/add')
|
|
|
|
await goBack()
|
|
|
|
await t
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings')
|
|
|
|
.expect(getActiveElementHref()).eql('/settings/instances')
|
|
|
|
.click($('a[href="/settings/instances"]'))
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings/instances')
|
|
|
|
.click($('a.settings-nav-item[href="/settings"]'))
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings')
|
|
|
|
await goBack()
|
|
|
|
await t
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/settings/instances')
|
|
|
|
.expect(getActiveElementHref()).eql('/settings')
|
|
|
|
.expect(getActiveElementClassList()).contains('settings-nav-item')
|
|
|
|
})
|
2019-12-13 16:31:05 +00:00
|
|
|
|
|
|
|
test('preserves focus on community page', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(communityNavButton)
|
|
|
|
.expect(getUrl()).contains('/community')
|
|
|
|
.click($('a[href="/federated"]'))
|
|
|
|
.expect(getUrl()).contains('/federated')
|
|
|
|
await goBack()
|
|
|
|
await t
|
|
|
|
.expect(getActiveElementHref()).eql('/federated')
|
|
|
|
})
|