2018-05-26 20:51:41 +00:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 04:54:21 +00:00
|
|
|
import {
|
2018-12-30 22:51:03 +00:00
|
|
|
getNthStatus, getNthStatusContent, getTitleText, getUrl, homeNavButton, notificationsNavButton
|
2018-06-09 04:54:21 +00:00
|
|
|
} from '../utils'
|
2018-11-12 20:59:47 +00:00
|
|
|
import { favoriteStatusAs, postAs } from '../serverActions'
|
2018-02-25 05:27:32 +00:00
|
|
|
|
2018-03-07 05:32:51 +00:00
|
|
|
fixture`102-notifications.js`
|
2018-02-25 05:27:32 +00:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
2018-12-30 22:51:03 +00:00
|
|
|
test('shows unread notification', async t => {
|
2019-08-03 20:49:37 +00:00
|
|
|
const { id } = await postAs('foobar', 'somebody please favorite this to validate me')
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-02-25 05:27:32 +00:00
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('Home · localhost:3000')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('somebody please favorite this to validate me', {
|
2018-12-30 22:51:03 +00:00
|
|
|
timeout: 20000
|
|
|
|
})
|
2018-11-12 20:59:47 +00:00
|
|
|
await favoriteStatusAs('admin', id)
|
2018-02-25 05:27:32 +00:00
|
|
|
await t
|
2018-12-30 22:51:03 +00:00
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1 notification)', {
|
|
|
|
timeout: 20000
|
|
|
|
})
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('(1) Home · localhost:3000')
|
2018-02-25 05:27:32 +00:00
|
|
|
.click(notificationsNavButton)
|
|
|
|
.expect(getUrl()).contains('/notifications')
|
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)')
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('Notifications · localhost:3000')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).innerText).contains('somebody please favorite this to validate me')
|
2020-11-29 22:13:27 +00:00
|
|
|
.expect(getNthStatus(1).innerText).match(/admin\s+favorited your toot/)
|
2018-02-25 05:27:32 +00:00
|
|
|
await t
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('Home · localhost:3000')
|
2018-02-25 05:27:32 +00:00
|
|
|
})
|
2018-12-30 22:51:03 +00:00
|
|
|
|
|
|
|
test('shows unread notifications, more than one', async t => {
|
2019-08-03 20:49:37 +00:00
|
|
|
const { id } = await postAs('foobar', 'I need lots of favorites on this one')
|
2018-12-30 22:51:03 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('Home · localhost:3000')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('I need lots of favorites on this one', {
|
2018-12-30 22:51:03 +00:00
|
|
|
timeout: 20000
|
|
|
|
})
|
|
|
|
await favoriteStatusAs('admin', id)
|
|
|
|
await favoriteStatusAs('quux', id)
|
|
|
|
await t
|
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (2 notifications)', {
|
|
|
|
timeout: 20000
|
|
|
|
})
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('(2) Home · localhost:3000')
|
2018-12-30 22:51:03 +00:00
|
|
|
.click(notificationsNavButton)
|
|
|
|
.expect(getUrl()).contains('/notifications')
|
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)')
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('Notifications · localhost:3000')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).innerText).contains('I need lots of favorites on this one')
|
2018-12-30 22:51:03 +00:00
|
|
|
await t
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
2022-11-27 15:49:18 +00:00
|
|
|
.expect(getTitleText()).eql('Home · localhost:3000')
|
2018-12-30 22:51:03 +00:00
|
|
|
})
|