pinafore/tests/spec/102-notifications.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

import { loginAsFoobar } from '../roles'
import {
getNthStatus, getNthStatusSelector, getUrl, homeNavButton, notificationsNavButton,
validateTimeline
} from '../utils'
2018-03-16 18:06:02 +01:00
import { favoriteStatusAs } from '../serverActions'
2018-02-25 06:27:32 +01:00
import { notifications } from '../fixtures'
import { Selector as $ } from 'testcafe'
2018-02-25 06:27:32 +01:00
2018-03-07 06:32:51 +01:00
fixture`102-notifications.js`
2018-02-25 06:27:32 +01:00
.page`http://localhost:4002`
test('shows unread notifications', async t => {
await loginAsFoobar(t)
await t
2018-02-25 06:27:32 +01:00
.hover(getNthStatus(0))
2018-03-07 05:44:05 +01:00
.hover(getNthStatus(2))
.hover(getNthStatus(4))
.hover(getNthStatus(5))
2018-02-25 06:27:32 +01:00
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
let statusId = (await $(`${getNthStatusSelector(5)} .status-relative-date`).getAttribute('href'))
2018-03-07 05:44:05 +01:00
.split('/').slice(-1)[0]
2018-03-16 18:06:02 +01:00
await favoriteStatusAs('admin', statusId)
2018-02-25 06:27:32 +01:00
await t
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1)')
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)')
await validateTimeline(t, [
{
favoritedBy: 'admin',
content: 'this is followers-only'
}
].concat(notifications))
await t
.click(homeNavButton)
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
})