pinafore/tests/spec/107-streaming-gap.js

115 lines
3.9 KiB
JavaScript
Raw Normal View History

import { loginAsFoobar } from '../roles'
2018-03-19 17:09:05 +00:00
import {
2019-07-21 22:31:26 +00:00
forceOffline,
forceOnline,
getNthStatus,
homeNavButton,
localTimelineNavButton,
notificationBadge,
notificationsNavButton,
sleep,
times,
validateTimeline
2018-03-19 17:09:05 +00:00
} from '../utils'
import {
postAs
} from '../serverActions'
fixture`107-streaming-gap.js`
.page`http://localhost:4002`
2019-07-21 22:31:26 +00:00
const timeout = 30000
2018-03-19 17:09:05 +00:00
2019-07-21 22:31:26 +00:00
test('fills timeline gap while away from local timeline', async t => {
await loginAsFoobar(t)
await t
2018-03-19 17:09:05 +00:00
.click(localTimelineNavButton)
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
2018-03-19 17:09:05 +00:00
await postAs('admin', 'heyo')
await t.expect(getNthStatus(1).innerText).contains('heyo', { timeout })
2018-03-19 17:09:05 +00:00
.click(homeNavButton)
.hover(getNthStatus(1))
2018-03-19 17:09:05 +00:00
await postAs('admin', 'posted this while you were away!')
await t.expect(getNthStatus(1).innerText).contains('posted this while you were away!', { timeout })
2018-03-19 17:09:05 +00:00
.click(localTimelineNavButton)
.expect(getNthStatus(1).innerText).contains('posted this while you were away!', { timeout })
.expect(getNthStatus(2).innerText).contains('heyo', { timeout })
2019-07-21 22:31:26 +00:00
await sleep(2000)
2018-03-19 17:09:05 +00:00
await postAs('admin', 'posted this while you were watching')
await t.expect(getNthStatus(1).innerText).contains('posted this while you were watching', { timeout })
2018-03-19 17:09:05 +00:00
})
2019-07-21 22:31:26 +00:00
test('fills timeline gap while away from home timeline', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
await postAs('admin', 'hello world')
await t.expect(getNthStatus(1).innerText).contains('hello world', { timeout })
await forceOffline()
await sleep(1000)
await postAs('admin', 'posted this while you were offline')
await sleep(1000)
await forceOnline()
await t.expect(getNthStatus(1).innerText).contains('posted this while you were offline', { timeout })
})
test('fills timeline gap while away from notifications timeline', async t => {
await loginAsFoobar(t)
await t
.click(notificationsNavButton)
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
await postAs('admin', '@foobar yo yo yo')
await t.expect(getNthStatus(1).innerText).contains('yo yo yo', { timeout })
await forceOffline()
await sleep(1000)
await postAs('admin', '@foobar mentioning you while you are offline!')
await sleep(1000)
await forceOnline()
await t.expect(getNthStatus(1).innerText).contains('mentioning you while you are offline!', { timeout })
})
test('fills timeline gap while away from notifications timeline - badge updates', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
await postAs('admin', '@foobar hi hi hi')
await t.expect(getNthStatus(1).innerText).contains('hi hi hi', { timeout })
await forceOffline()
await sleep(1000)
await postAs('admin', '@foobar sneaky mention!')
await sleep(1000)
await forceOnline()
await t
.expect(notificationBadge.innerText).eql('1', { timeout })
.click(notificationsNavButton)
.expect(notificationBadge.exists).notOk()
.expect(getNthStatus(1).innerText).contains('sneaky mention!', { timeout })
})
test('fills a large gap while away from home timeline', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
await postAs('admin', 'hello hello world')
await t.expect(getNthStatus(1).innerText).contains('hello hello world', { timeout })
await forceOffline()
await sleep(1000)
const GAP_SIZE = 60
for (let i = 0; i < GAP_SIZE; i++) {
await postAs('admin', `posted while offline #${i + 1}`)
}
await sleep(1000)
await forceOnline()
await t.expect(getNthStatus(1).innerText).contains(`posted while offline #${GAP_SIZE}`, {
timeout: timeout * 2
})
const expected = times(GAP_SIZE, i => ({ content: `posted while offline #${GAP_SIZE - i}` }))
.concat([{ content: 'hello hello world' }])
await validateTimeline(t, expected)
})