Pinafore-Web-Client-Frontend/tests/spec/106-follow-requests.js

44 lines
1.9 KiB
JavaScript
Raw Normal View History

import { loginAsFoobar } from '../roles'
2018-03-15 06:14:06 +01:00
import {
accountProfileFollowButton,
getNthStatus,
sleep
} from '../utils'
import {
authorizeFollowRequestAs, getFollowRequestsAs, unfollowAs
2018-03-15 06:14:06 +01:00
} from '../serverActions'
fixture`106-follow-requests.js`
.page`http://localhost:4002`
test('can request to follow an account', async t => {
await unfollowAs('foobar', 'LockedAccount') // reset
await loginAsFoobar(t)
await t
2018-03-15 06:14:06 +01:00
.navigateTo('/accounts/6')
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
2018-03-15 06:14:06 +01:00
.click(accountProfileFollowButton)
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow (follow requested)')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow (follow requested)')
2018-03-15 06:14:06 +01:00
.click(accountProfileFollowButton)
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
2018-03-15 06:14:06 +01:00
.click(accountProfileFollowButton)
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow (follow requested)')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow (follow requested)')
2018-03-15 06:14:06 +01:00
2019-08-03 22:49:37 +02:00
const requests = await getFollowRequestsAs('LockedAccount')
2018-03-16 18:06:02 +01:00
await authorizeFollowRequestAs('LockedAccount', requests.slice(-1)[0].id)
2018-03-15 06:14:06 +01:00
await sleep(2000)
await t.navigateTo('/accounts/6')
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
.expect(getNthStatus(1).innerText).contains('This account is locked')
2018-03-15 06:14:06 +01:00
.click(accountProfileFollowButton)
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
2018-03-15 06:14:06 +01:00
})