2018-04-15 01:47:55 +00:00
|
|
|
import {
|
|
|
|
accountProfileFollowButton,
|
|
|
|
accountProfileFollowedBy, accountProfileMoreOptionsButton, communityNavButton, getNthSearchResult,
|
|
|
|
getNthStatus, getNthStatusOptionsButton, getNthDialogOptionsOption, getUrl, modalDialog
|
|
|
|
} from '../utils'
|
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-05-26 20:51:41 +00:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-04-15 01:47:55 +00:00
|
|
|
import { postAs } from '../serverActions'
|
|
|
|
|
|
|
|
fixture`113-block-unblock.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('Can block and unblock an account from a status', async t => {
|
|
|
|
let post = 'a very silly statement that should probably get me blocked'
|
|
|
|
await postAs('admin', post)
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 04:42:57 +00:00
|
|
|
.expect(getNthStatus(0).innerText).contains(post, { timeout: 30000 })
|
2018-04-15 01:47:55 +00:00
|
|
|
.click(getNthStatusOptionsButton(0))
|
|
|
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Unfollow @admin')
|
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Block @admin')
|
|
|
|
.click(getNthDialogOptionsOption(2))
|
|
|
|
.expect(modalDialog.exists).notOk()
|
|
|
|
.click(communityNavButton)
|
|
|
|
.click($('a[href="/blocked"]'))
|
|
|
|
.expect(getNthSearchResult(1).innerText).contains('@admin')
|
|
|
|
.click(getNthSearchResult(1))
|
|
|
|
.expect(getUrl()).contains('/accounts/1')
|
|
|
|
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowedBy.innerText).contains('')
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
2018-04-15 05:18:48 +00:00
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
2018-04-15 01:47:55 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Can block and unblock an account from the account profile page', async t => {
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-04-15 01:47:55 +00:00
|
|
|
.navigateTo('/accounts/5')
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
|
|
|
.click(accountProfileMoreOptionsButton)
|
|
|
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Mention @baz')
|
2018-04-15 05:18:48 +00:00
|
|
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Follow @baz')
|
|
|
|
.expect(getNthDialogOptionsOption(3).innerText).contains('Block @baz')
|
|
|
|
.click(getNthDialogOptionsOption(3))
|
2018-04-15 01:47:55 +00:00
|
|
|
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowedBy.innerText).contains('')
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
|
|
|
.click(accountProfileFollowButton)
|
|
|
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
|
|
|
})
|