pinafore/tests/spec/113-block-unblock.js

86 wiersze
3.4 KiB
JavaScript
Czysty Zwykły widok Historia

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