2018-02-24 23:49:28 +01:00
|
|
|
import {
|
|
|
|
getFavoritesCount,
|
|
|
|
getNthFavoriteButton, getNthFavorited, getNthStatus, getUrl, homeNavButton, notificationsNavButton,
|
2018-11-22 07:08:37 +01:00
|
|
|
scrollToBottom, scrollToTop, sleep
|
2018-02-24 23:49:28 +01:00
|
|
|
} from '../utils'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-11-12 21:59:47 +01:00
|
|
|
import { indexWhere } from '../../routes/_utils/arrays'
|
|
|
|
import { homeTimeline } from '../fixtures'
|
2018-02-24 23:49:28 +01:00
|
|
|
|
2018-03-11 06:05:00 +01:00
|
|
|
fixture`100-favorite-unfavorite.js`
|
2018-02-24 23:49:28 +01:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('favorites a status', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-02-24 23:49:28 +01:00
|
|
|
.hover(getNthStatus(4))
|
|
|
|
.expect(getNthFavorited(4)).eql('false')
|
|
|
|
.click(getNthFavoriteButton(4))
|
|
|
|
.expect(getNthFavorited(4)).eql('true')
|
|
|
|
|
|
|
|
// 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-24 23:49:28 +01:00
|
|
|
await t
|
|
|
|
.hover(getNthStatus(4))
|
|
|
|
.expect(getNthFavorited(4)).eql('true')
|
|
|
|
.click(notificationsNavButton)
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(getNthFavorited(4)).eql('true')
|
|
|
|
.click(notificationsNavButton)
|
|
|
|
.expect(getUrl()).contains('/notifications')
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
2018-02-26 08:38:06 +01:00
|
|
|
.hover(getNthStatus(4))
|
2018-02-24 23:49:28 +01:00
|
|
|
.expect(getNthFavorited(4)).eql('true')
|
|
|
|
.click(getNthFavoriteButton(4))
|
|
|
|
.expect(getNthFavorited(4)).eql('false')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('unfavorites a status', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-02-24 23:49:28 +01:00
|
|
|
.expect(getNthFavorited(1)).eql('true')
|
|
|
|
.click(getNthFavoriteButton(1))
|
|
|
|
.expect(getNthFavorited(1)).eql('false')
|
|
|
|
|
|
|
|
// 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-24 23:49:28 +01:00
|
|
|
await t
|
|
|
|
.expect(getNthFavorited(1)).eql('false')
|
|
|
|
.click(notificationsNavButton)
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(getNthFavorited(1)).eql('false')
|
|
|
|
.click(notificationsNavButton)
|
|
|
|
.navigateTo('/')
|
|
|
|
.expect(getNthFavorited(1)).eql('false')
|
|
|
|
.click(getNthFavoriteButton(1))
|
|
|
|
.expect(getNthFavorited(1)).eql('true')
|
|
|
|
})
|
|
|
|
|
2018-02-25 03:20:33 +01:00
|
|
|
test('Keeps the correct favorites count', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 21:59:47 +01:00
|
|
|
let idx = indexWhere(homeTimeline, _ => _.content === 'this is unlisted')
|
2018-05-26 22:51:41 +02:00
|
|
|
await t
|
2018-11-12 21:59:47 +01:00
|
|
|
.hover(getNthStatus(idx))
|
|
|
|
.click(getNthFavoriteButton(idx))
|
|
|
|
.expect(getNthFavorited(idx)).eql('true')
|
|
|
|
.click(getNthStatus(idx))
|
2018-02-24 23:49:28 +01:00
|
|
|
.expect(getUrl()).contains('/status')
|
|
|
|
.expect(getNthFavorited(0)).eql('true')
|
|
|
|
.expect(getFavoritesCount()).eql(2)
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(getUrl()).eql('http://localhost:4002/')
|
2018-11-12 21:59:47 +01:00
|
|
|
.hover(getNthStatus(idx))
|
|
|
|
.click(getNthFavoriteButton(idx))
|
|
|
|
.expect(getNthFavorited(idx)).eql('false')
|
|
|
|
.click(getNthStatus(idx))
|
2018-02-24 23:49:28 +01:00
|
|
|
.expect(getUrl()).contains('/status')
|
|
|
|
.expect(getNthFavorited(0)).eql('false')
|
|
|
|
.expect(getFavoritesCount()).eql(1)
|
|
|
|
})
|