2018-11-25 09:20:58 +00:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-12-01 19:53:20 +00:00
|
|
|
import {
|
|
|
|
generalSettingsButton,
|
|
|
|
getNthShowOrHideButton,
|
2022-12-02 20:54:03 +00:00
|
|
|
getNthStatus, getNthStatusAndSensitiveButton, getNthStatusRelativeDateTime, homeNavButton,
|
2018-12-01 19:53:20 +00:00
|
|
|
notificationsNavButton,
|
|
|
|
scrollToStatus,
|
|
|
|
settingsNavButton
|
|
|
|
} from '../utils'
|
|
|
|
import { Selector as $ } from 'testcafe'
|
2019-03-31 16:21:57 +00:00
|
|
|
|
2018-11-25 09:20:58 +00:00
|
|
|
import { homeTimeline } from '../fixtures'
|
|
|
|
|
|
|
|
fixture`022-status-aria-label.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('basic aria-labels for statuses', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
/quux, pinned toot 1, .+ ago, @quux, Unlisted, Boosted by admin/i
|
|
|
|
)
|
2021-04-03 00:01:08 +00:00
|
|
|
.expect(getNthStatusRelativeDateTime(1).getAttribute('aria-label')).match(
|
|
|
|
/.* ago - click to show thread/i
|
|
|
|
)
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatus(2).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
/admin, @foobar notification of unlisted message, .* ago, @admin, Unlisted/i
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('aria-labels for CWed statuses', async t => {
|
|
|
|
await loginAsFoobar(t)
|
2019-08-03 20:49:37 +00:00
|
|
|
const kittenIdx = homeTimeline.findIndex(_ => _.spoiler === 'kitten CW')
|
2019-02-28 16:56:25 +00:00
|
|
|
await scrollToStatus(t, 1 + kittenIdx)
|
2018-11-25 09:20:58 +00:00
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1 + kittenIdx))
|
|
|
|
.expect(getNthStatus(1 + kittenIdx).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
/foobar, Content warning: kitten CW, .* ago, @foobar, Public/i
|
|
|
|
)
|
2022-12-02 20:54:03 +00:00
|
|
|
// toggle the CW button
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthShowOrHideButton(1 + kittenIdx))
|
|
|
|
.expect(getNthStatus(1 + kittenIdx).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
/foobar, here's a kitten with a CW, .* ago, @foobar, Public/i
|
|
|
|
)
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthShowOrHideButton(1 + kittenIdx))
|
|
|
|
.expect(getNthStatus(1 + kittenIdx).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
/foobar, Content warning: kitten CW, .* ago, @foobar, Public/i
|
|
|
|
)
|
2022-12-02 20:54:03 +00:00
|
|
|
// toggle the "show sensitive media" button
|
|
|
|
.click(getNthStatusAndSensitiveButton(1 + kittenIdx, 1))
|
|
|
|
.expect(getNthStatus(1 + kittenIdx).getAttribute('aria-label')).match(
|
|
|
|
/foobar, Content warning: kitten CW, has media, kitten, .* ago, @foobar, Public/i
|
|
|
|
)
|
|
|
|
.click(getNthStatusAndSensitiveButton(1 + kittenIdx, 1))
|
|
|
|
.expect(getNthStatus(1 + kittenIdx).getAttribute('aria-label')).match(
|
|
|
|
/foobar, Content warning: kitten CW, .* ago, @foobar, Public/i
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('aria-labels for two media attachments', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
const twoKittensIdx = homeTimeline.findIndex(_ => _.content === 'here\'s 2 kitten photos')
|
|
|
|
await scrollToStatus(t, 1 + twoKittensIdx)
|
|
|
|
await t
|
|
|
|
.hover(getNthStatus(1 + twoKittensIdx))
|
|
|
|
.expect(getNthStatus(1 + twoKittensIdx).getAttribute('aria-label')).match(
|
|
|
|
/foobar, here's 2 kitten photos, has media, kitten, kitten, .* ago, @foobar, Public/i
|
|
|
|
)
|
2018-11-25 09:20:58 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('aria-labels for notifications', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(notificationsNavButton)
|
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2020-11-29 22:13:27 +00:00
|
|
|
/admin favorited your toot, foobar, this is unlisted, .* ago, @foobar, Unlisted/i
|
2018-11-25 09:20:58 +00:00
|
|
|
)
|
|
|
|
.hover(getNthStatus(2))
|
|
|
|
.expect(getNthStatus(2).getAttribute('aria-label')).match(
|
2020-11-29 22:13:27 +00:00
|
|
|
/admin boosted your toot, foobar, this is unlisted, .* ago, @foobar, Unlisted/i
|
2018-11-25 09:20:58 +00:00
|
|
|
)
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(3))
|
|
|
|
.expect(getNthStatus(3).getAttribute('aria-label')).match(
|
|
|
|
/admin, @foobar notification of unlisted message, .* ago, @admin, Unlisted/i
|
2018-11-25 09:20:58 +00:00
|
|
|
)
|
|
|
|
await scrollToStatus(t, 5)
|
|
|
|
await t
|
|
|
|
.hover(getNthStatus(5))
|
|
|
|
.expect(getNthStatus(5).getAttribute('aria-label')).match(
|
2019-02-28 16:56:25 +00:00
|
|
|
/admin, @foobar notification of direct message, .* ago, @admin, Direct/i
|
|
|
|
)
|
|
|
|
await scrollToStatus(t, 6)
|
|
|
|
await t
|
|
|
|
.hover(getNthStatus(6))
|
|
|
|
.expect(getNthStatus(6).getAttribute('aria-label')).match(
|
2018-11-25 09:20:58 +00:00
|
|
|
/quux followed you, @quux/i
|
|
|
|
)
|
|
|
|
})
|
2018-12-01 19:53:20 +00:00
|
|
|
|
|
|
|
test('can shorten aria-labels', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click($('#choice-disable-long-aria-labels'))
|
|
|
|
.click(homeNavButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2020-11-29 22:13:27 +00:00
|
|
|
/Unlisted toot by quux/
|
2018-12-01 19:53:20 +00:00
|
|
|
)
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click($('#choice-disable-long-aria-labels'))
|
|
|
|
.click(homeNavButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.expect(getNthStatus(1).getAttribute('aria-label')).match(
|
2018-12-01 19:53:20 +00:00
|
|
|
/quux, pinned toot 1, .+ ago, @quux, Unlisted, Boosted by admin/i
|
|
|
|
)
|
|
|
|
})
|