2018-04-15 03:47:55 +02:00
|
|
|
import {
|
|
|
|
accountProfileFollowButton,
|
|
|
|
accountProfileFollowedBy, accountProfileMoreOptionsButton, communityNavButton, getNthSearchResult,
|
2021-02-23 05:36:59 +01:00
|
|
|
getNthStatus, getNthStatusOptionsButton, getNthDialogOptionsOption, getUrl, modalDialog,
|
|
|
|
sleep
|
2018-04-15 03:47:55 +02:00
|
|
|
} from '../utils'
|
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2019-11-09 23:25:26 +01:00
|
|
|
import { postAs, unfollowAs } from '../serverActions'
|
2018-04-15 03:47:55 +02:00
|
|
|
|
|
|
|
fixture`113-block-unblock.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('Can block and unblock an account from a status', async t => {
|
2019-08-03 22:49:37 +02:00
|
|
|
const post = 'a very silly statement that should probably get me blocked'
|
2018-04-15 03:47:55 +02:00
|
|
|
await postAs('admin', post)
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect(getNthStatus(1).innerText).contains(post, { timeout: 30000 })
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.click(getNthStatusOptionsButton(1))
|
2018-04-15 03:47:55 +02:00
|
|
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Unfollow @admin')
|
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Block @admin')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(getNthDialogOptionsOption(2))
|
|
|
|
.expect(modalDialog.exists).notOk()
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(communityNavButton)
|
|
|
|
.click($('a[href="/blocked"]'))
|
|
|
|
.expect(getNthSearchResult(1).innerText).contains('@admin')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(getNthSearchResult(1))
|
|
|
|
.expect(getUrl()).contains('/accounts/1')
|
|
|
|
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unblock')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowedBy.innerText).contains('')
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 07:18:48 +02:00
|
|
|
.click(accountProfileFollowButton)
|
2019-11-18 03:23:32 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
|
2018-04-15 03:47:55 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Can block and unblock an account from the account profile page', async t => {
|
2019-11-09 23:25:26 +01:00
|
|
|
await unfollowAs('foobar', 'baz') // reset
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.navigateTo('/accounts/5')
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(accountProfileMoreOptionsButton)
|
|
|
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Mention @baz')
|
2018-04-15 07:18:48 +02:00
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Follow @baz')
|
|
|
|
.expect(getNthDialogOptionsOption(3).innerText).contains('Block @baz')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 07:18:48 +02:00
|
|
|
.click(getNthDialogOptionsOption(3))
|
2018-04-15 03:47:55 +02:00
|
|
|
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unblock')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowedBy.innerText).contains('')
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(accountProfileFollowButton)
|
2019-11-18 03:23:32 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
|
2021-02-23 05:36:59 +01:00
|
|
|
await sleep(500)
|
|
|
|
await t
|
2018-04-15 03:47:55 +02:00
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
2019-11-09 23:25:26 +01:00
|
|
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
2018-04-15 03:47:55 +02:00
|
|
|
})
|