add test for notifications

This commit is contained in:
Nolan Lawson 2018-02-24 21:27:32 -08:00
parent 00ccf35777
commit 81174e636b
5 changed files with 41 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,10 +1,9 @@
const isLocalhost = process.browser && process.env.NODE_ENV !== 'production' &&
(document.location.hostname === 'localhost' ||
document.location.hostname === '127.0.0.1')
const isLocalhost = !process.browser ||
location.hostname === 'localhost' ||
location.hostname === '127.0.0.1'
function targetIsLocalhost (instanceName) {
return process.browser && process.env.NODE_ENV !== 'production' &&
(instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:'))
return instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
}
export function basename (instanceName) {

9
tests/serverActions.js Normal file
View file

@ -0,0 +1,9 @@
import { favoriteStatus } from '../routes/_api/favorite'
import fetch from 'node-fetch'
global.fetch = fetch
const accessToken = 'a306d698185db24b12385a5432817551d7ac94bdcbe23233d4e5eff70f6408c4'
export async function favoriteStatusAsAdmin (statusId) {
return favoriteStatus('localhost:3000', accessToken, statusId)
}

View file

@ -0,0 +1,28 @@
import { foobarRole } from '../roles'
import { getNthStatus, getUrl, homeNavButton, notificationsNavButton, validateTimeline } from '../utils'
import { favoriteStatusAsAdmin } from '../serverActions'
import { notifications } from '../fixtures'
fixture`32-notifications.js`
.page`http://localhost:4002`
test('shows unread notifications', async t => {
await t.useRole(foobarRole)
.hover(getNthStatus(0))
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
await favoriteStatusAsAdmin('99548061995124415')
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')
})