pinafore/tests/spec/101-reblog-unreblog.js

92 lines
3 KiB
JavaScript
Raw Normal View History

2018-02-25 02:20:33 +00:00
import {
2018-11-22 06:08:37 +00:00
getNthReblogButton, getNthReblogged, getNthStatus, getNthStatusContent, getReblogsCount, getUrl, homeNavButton,
notificationsNavButton, scrollToBottom, scrollToTop, sleep
2018-02-25 02:20:33 +00:00
} from '../utils'
import { loginAsFoobar } from '../roles'
2018-11-22 06:08:37 +00:00
import { postAs, reblogStatusAs } from '../serverActions'
2018-02-25 02:20:33 +00:00
2018-03-07 05:32:51 +00:00
fixture`101-reblog-unreblog.js`
2018-02-25 02:20:33 +00:00
.page`http://localhost:4002`
test('reblogs a status', async t => {
2018-11-22 06:08:37 +00:00
await postAs('foobar', 'hello this should be reblogged')
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.expect(getNthStatusContent(1).innerText).contains('should be reblogged')
.expect(getNthReblogged(1)).eql('false')
.click(getNthReblogButton(1))
.expect(getNthReblogged(1)).eql('true')
2018-02-25 02:20:33 +00:00
// scroll down and back up to force an unrender
2018-11-22 06:08:37 +00:00
await scrollToBottom()
await sleep(1)
await scrollToTop()
2018-02-25 02:20:33 +00:00
await t
.hover(getNthStatus(1))
.expect(getNthReblogged(1)).eql('true')
2018-02-25 02:20:33 +00:00
.click(notificationsNavButton)
.click(homeNavButton)
.expect(getNthReblogged(1)).eql('true')
2018-02-25 02:20:33 +00:00
.click(notificationsNavButton)
.expect(getUrl()).contains('/notifications')
.click(homeNavButton)
.expect(getUrl()).eql('http://localhost:4002/')
.expect(getNthReblogged(1)).eql('true')
.click(getNthReblogButton(1))
.expect(getNthReblogged(1)).eql('false')
2018-02-25 02:20:33 +00:00
})
test('unreblogs a status', async t => {
2018-11-22 06:08:37 +00:00
await postAs('foobar', 'woot i wanna reblog this')
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.expect(getNthStatusContent(1).innerText).contains('woot i wanna')
.expect(getNthReblogged(1)).eql('false')
.click(getNthReblogButton(1))
.expect(getNthReblogged(1)).eql('true')
.click(getNthReblogButton(1))
.expect(getNthReblogged(1)).eql('false')
2018-02-25 02:20:33 +00:00
// scroll down and back up to force an unrender
2018-11-22 06:08:37 +00:00
await scrollToBottom()
await sleep(1)
await scrollToTop()
2018-02-25 02:20:33 +00:00
await t
.hover(getNthStatus(1))
.expect(getNthReblogged(1)).eql('false')
2018-02-25 02:20:33 +00:00
.click(notificationsNavButton)
.click(homeNavButton)
.expect(getNthReblogged(1)).eql('false')
2018-02-25 02:20:33 +00:00
.click(notificationsNavButton)
.navigateTo('/')
.expect(getNthReblogged(1)).eql('false')
.click(getNthReblogButton(1))
.expect(getNthReblogged(1)).eql('true')
2018-02-25 02:20:33 +00:00
})
test('Keeps the correct reblogs count', async t => {
2019-08-03 20:49:37 +00:00
const { id } = await postAs('foobar', 'this will be reblogged')
2018-11-22 06:08:37 +00:00
await reblogStatusAs('foobar', id)
await reblogStatusAs('admin', id)
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.expect(getNthStatusContent(1).innerText).contains('this will be reblogged')
.expect(getNthReblogged(1)).eql('true')
.click(getNthStatus(1))
2018-02-25 02:20:33 +00:00
.expect(getUrl()).contains('/status')
.expect(getNthReblogged(1)).eql('true')
2018-02-25 02:20:33 +00:00
.expect(getReblogsCount()).eql(2)
.click(homeNavButton)
.expect(getUrl()).eql('http://localhost:4002/')
.hover(getNthStatus(1))
.click(getNthReblogButton(1))
.expect(getNthReblogged(1)).eql('false')
.click(getNthStatus(1))
2018-02-25 02:20:33 +00:00
.expect(getUrl()).contains('/status')
.expect(getNthReblogged(1)).eql('false')
2018-02-25 02:20:33 +00:00
.expect(getReblogsCount()).eql(1)
})