diff --git a/fixtures/dump.sql b/fixtures/dump.sql index 4fc00242..482b18ce 100644 Binary files a/fixtures/dump.sql and b/fixtures/dump.sql differ diff --git a/fixtures/system.tgz b/fixtures/system.tgz index 5d601465..f0208ba7 100644 Binary files a/fixtures/system.tgz and b/fixtures/system.tgz differ diff --git a/routes/_api/utils.js b/routes/_api/utils.js index 7c3ce6d7..73b1a4bd 100644 --- a/routes/_api/utils.js +++ b/routes/_api/utils.js @@ -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) { diff --git a/tests/serverActions.js b/tests/serverActions.js new file mode 100644 index 00000000..742b346f --- /dev/null +++ b/tests/serverActions.js @@ -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) +} diff --git a/tests/spec/32-notifications.js b/tests/spec/32-notifications.js new file mode 100644 index 00000000..cfde9c0f --- /dev/null +++ b/tests/spec/32-notifications.js @@ -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') +})