2018-05-26 20:51:41 +00:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-04-29 19:28:44 +00:00
|
|
|
import {
|
2018-08-30 01:10:09 +00:00
|
|
|
avatarInComposeBox, closeDialogButton, composeInput, getNthDialogOptionsOption, getNthPinnedStatus,
|
|
|
|
getNthPinnedStatusFavoriteButton,
|
|
|
|
getNthStatus, getNthStatusContent,
|
2018-11-22 06:08:37 +00:00
|
|
|
getNthStatusOptionsButton, getUrl, homeNavButton, postStatusButton, scrollToTop, scrollToBottom,
|
2018-08-30 01:10:09 +00:00
|
|
|
settingsNavButton, sleep
|
2018-04-29 19:28:44 +00:00
|
|
|
} from '../utils'
|
|
|
|
import { users } from '../users'
|
2018-08-30 01:10:09 +00:00
|
|
|
import { postAs } from '../serverActions'
|
2018-04-29 19:28:44 +00:00
|
|
|
|
|
|
|
fixture`117-pin-unpin.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('Can pin statuses', async t => {
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 04:42:57 +00:00
|
|
|
.typeText(composeInput, 'I am going to pin this', { paste: true })
|
2018-05-26 20:51:41 +00:00
|
|
|
.click(postStatusButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(1).innerText).contains('I am going to pin this')
|
2018-05-26 20:51:41 +00:00
|
|
|
.click(avatarInComposeBox)
|
2018-04-29 19:28:44 +00:00
|
|
|
.expect(getUrl()).contains(`/accounts/${users.foobar.id}`)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthPinnedStatus(1).getAttribute('aria-setsize')).eql('1')
|
|
|
|
.expect(getNthPinnedStatus(1).innerText).contains('this is unlisted')
|
|
|
|
.expect(getNthStatus(1).innerText).contains('I am going to pin this')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-04-29 19:28:44 +00:00
|
|
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Delete')
|
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Pin to profile')
|
|
|
|
.click(getNthDialogOptionsOption(2))
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthPinnedStatus(1).getAttribute('aria-setsize')).eql('2')
|
|
|
|
.expect(getNthPinnedStatus(1).innerText).contains('I am going to pin this')
|
|
|
|
.expect(getNthPinnedStatus(2).innerText).contains('this is unlisted')
|
|
|
|
.expect(getNthStatus(1).innerText).contains('I am going to pin this')
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-04-29 19:28:44 +00:00
|
|
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Delete')
|
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Unpin from profile')
|
|
|
|
.click(getNthDialogOptionsOption(2))
|
|
|
|
.expect(getUrl()).contains(`/accounts/${users.foobar.id}`)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthPinnedStatus(1).getAttribute('aria-setsize')).eql('1')
|
|
|
|
.expect(getNthPinnedStatus(1).innerText).contains('this is unlisted')
|
|
|
|
.expect(getNthStatus(1).innerText).contains('I am going to pin this')
|
2018-04-29 19:28:44 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Can favorite a pinned status', async t => {
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-29 19:28:44 +00:00
|
|
|
.click(avatarInComposeBox)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthPinnedStatus(1).getAttribute('aria-setsize')).eql('1')
|
2019-11-18 02:23:32 +00:00
|
|
|
.expect(getNthPinnedStatusFavoriteButton(1).getAttribute('aria-label')).eql('Favorite')
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthPinnedStatusFavoriteButton(1))
|
2019-11-18 02:23:32 +00:00
|
|
|
.expect(getNthPinnedStatusFavoriteButton(1).getAttribute('aria-label')).eql('Unfavorite')
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthPinnedStatusFavoriteButton(1))
|
2019-11-18 02:23:32 +00:00
|
|
|
.expect(getNthPinnedStatusFavoriteButton(1).getAttribute('aria-label')).eql('Favorite')
|
2018-04-29 19:28:44 +00:00
|
|
|
})
|
2018-08-30 01:10:09 +00:00
|
|
|
|
|
|
|
test('Saved pinned/unpinned state of status', async t => {
|
|
|
|
const timeout = 20000
|
|
|
|
await postAs('foobar', 'hey I am going to pin and unpin this')
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey I am going to pin and unpin this', { timeout })
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-08-30 01:10:09 +00:00
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Pin to profile')
|
|
|
|
.click(getNthDialogOptionsOption(2))
|
|
|
|
await sleep(1)
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-08-30 01:10:09 +00:00
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Unpin from profile')
|
|
|
|
.click(closeDialogButton)
|
|
|
|
|
|
|
|
// 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-08-30 01:10:09 +00:00
|
|
|
|
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey I am going to pin and unpin this', { timeout })
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-08-30 01:10:09 +00:00
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Unpin from profile', { timeout })
|
|
|
|
// navigate to another page and back to force another unrender
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(homeNavButton)
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatusContent(1).innerText).contains('hey I am going to pin and unpin this', { timeout })
|
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-08-30 01:10:09 +00:00
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Unpin from profile', { timeout })
|
|
|
|
})
|