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