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