fix: fix aria-labels on relative timestamps (#2028)

This commit is contained in:
Nolan Lawson 2021-04-02 17:01:08 -07:00 committed by GitHub
parent d0c9be0c09
commit c815292b0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -41,8 +41,8 @@
// just a duplicate link in the focus order. // just a duplicate link in the focus order.
$disableTapOnStatus ? '0' : '-1' $disableTapOnStatus ? '0' : '-1'
), ),
createdAtLabel: ({ formattedDate }) => ( createdAtLabel: ({ shortInlineFormattedDate }) => (
formatIntl('intl.clickToShowThread', { time: formattedDate }) formatIntl('intl.clickToShowThread', { time: shortInlineFormattedDate })
) )
} }
} }

View file

@ -2,7 +2,7 @@ import { loginAsFoobar } from '../roles'
import { import {
generalSettingsButton, generalSettingsButton,
getNthShowOrHideButton, getNthShowOrHideButton,
getNthStatus, homeNavButton, getNthStatus, getNthStatusRelativeDateTime, homeNavButton,
notificationsNavButton, notificationsNavButton,
scrollToStatus, scrollToStatus,
settingsNavButton settingsNavButton
@ -21,6 +21,9 @@ test('basic aria-labels for statuses', async t => {
.expect(getNthStatus(1).getAttribute('aria-label')).match( .expect(getNthStatus(1).getAttribute('aria-label')).match(
/quux, pinned toot 1, .+ ago, @quux, Unlisted, Boosted by admin/i /quux, pinned toot 1, .+ ago, @quux, Unlisted, Boosted by admin/i
) )
.expect(getNthStatusRelativeDateTime(1).getAttribute('aria-label')).match(
/.* ago - click to show thread/i
)
.hover(getNthStatus(1)) .hover(getNthStatus(1))
.expect(getNthStatus(2).getAttribute('aria-label')).match( .expect(getNthStatus(2).getAttribute('aria-label')).match(
/admin, @foobar notification of unlisted message, .* ago, @admin, Unlisted/i /admin, @foobar notification of unlisted message, .* ago, @admin, Unlisted/i

View file

@ -466,6 +466,10 @@ export function getNthStatusRelativeDate (n) {
return $(`${getNthStatusSelector(n)} .status-relative-date`) return $(`${getNthStatusSelector(n)} .status-relative-date`)
} }
export function getNthStatusRelativeDateTime (n) {
return $(`${getNthStatusSelector(n)} .status-relative-date time`)
}
export function getNthStatusMediaImg (n) { export function getNthStatusMediaImg (n) {
return $(`${getNthStatusSelector(n)} .status-media img`) return $(`${getNthStatusSelector(n)} .status-media img`)
} }