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