1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-11 09:45:24 +01:00
Pinafore-Web-Client-Frontend/tests/spec/102-notifications.js
Nolan Lawson 0022286b46
fix: first stab at i18n, extract English strings, add French (#1904)
* first attempt

* progress

* working

* working

* test timeago

* rm

* get timeago working

* reduce size

* fix whitespace

* more intl stuff

* more effort

* more work

* more progress

* more work

* more intl

* set lang=LOCALE

* flatten

* more work

* add ltr/rtl

* more work

* add comments

* yet more work

* still more work

* more work

* fix tests

* more test and string fixes

* fix test

* fix test

* fix test

* fix some more strings, add test

* fix snackbar

* fix }

* fix typo

* fix english

* measure perf

* start on french

* more work on french

* more french

* more french

* finish french

* fix some missing translations

* update readme

* fix test
2020-11-29 14:13:27 -08:00

63 lines
2.8 KiB
JavaScript

import { loginAsFoobar } from '../roles'
import {
getNthStatus, getNthStatusContent, getTitleText, getUrl, homeNavButton, notificationsNavButton
} from '../utils'
import { favoriteStatusAs, postAs } from '../serverActions'
fixture`102-notifications.js`
.page`http://localhost:4002`
test('shows unread notification', async t => {
const { id } = await postAs('foobar', 'somebody please favorite this to validate me')
await loginAsFoobar(t)
await t
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
.expect(getTitleText()).eql('localhost:3000 · Home')
.expect(getNthStatusContent(1).innerText).contains('somebody please favorite this to validate me', {
timeout: 20000
})
await favoriteStatusAs('admin', id)
await t
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1 notification)', {
timeout: 20000
})
.expect(getTitleText()).eql('(1) localhost:3000 · Home')
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)')
.expect(getTitleText()).eql('localhost:3000 · Notifications')
.expect(getNthStatus(1).innerText).contains('somebody please favorite this to validate me')
.expect(getNthStatus(1).innerText).match(/admin\s+favorited your toot/)
await t
.click(homeNavButton)
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
.expect(getTitleText()).eql('localhost:3000 · Home')
})
test('shows unread notifications, more than one', async t => {
const { id } = await postAs('foobar', 'I need lots of favorites on this one')
await loginAsFoobar(t)
await t
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
.expect(getTitleText()).eql('localhost:3000 · Home')
.expect(getNthStatusContent(1).innerText).contains('I need lots of favorites on this one', {
timeout: 20000
})
await favoriteStatusAs('admin', id)
await favoriteStatusAs('quux', id)
await t
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (2 notifications)', {
timeout: 20000
})
.expect(getTitleText()).eql('(2) localhost:3000 · Home')
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (current page)')
.expect(getTitleText()).eql('localhost:3000 · Notifications')
.expect(getNthStatus(1).innerText).contains('I need lots of favorites on this one')
await t
.click(homeNavButton)
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
.expect(getTitleText()).eql('localhost:3000 · Home')
})