test: fix flakey test (#1970)
This commit is contained in:
parent
b2583277eb
commit
b0c694b1bd
|
@ -1,7 +1,8 @@
|
||||||
import {
|
import {
|
||||||
accountProfileFollowButton,
|
accountProfileFollowButton,
|
||||||
accountProfileFollowedBy, accountProfileMoreOptionsButton, communityNavButton, getNthSearchResult,
|
accountProfileFollowedBy, accountProfileMoreOptionsButton, communityNavButton, getNthSearchResult,
|
||||||
getNthStatus, getNthStatusOptionsButton, getNthDialogOptionsOption, getUrl, modalDialog
|
getNthStatus, getNthStatusOptionsButton, getNthDialogOptionsOption, getUrl, modalDialog,
|
||||||
|
sleep
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { Selector as $ } from 'testcafe'
|
import { Selector as $ } from 'testcafe'
|
||||||
import { loginAsFoobar } from '../roles'
|
import { loginAsFoobar } from '../roles'
|
||||||
|
@ -16,23 +17,35 @@ test('Can block and unblock an account from a status', async t => {
|
||||||
await loginAsFoobar(t)
|
await loginAsFoobar(t)
|
||||||
await t
|
await t
|
||||||
.expect(getNthStatus(1).innerText).contains(post, { timeout: 30000 })
|
.expect(getNthStatus(1).innerText).contains(post, { timeout: 30000 })
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(getNthStatusOptionsButton(1))
|
.click(getNthStatusOptionsButton(1))
|
||||||
.expect(getNthDialogOptionsOption(1).innerText).contains('Unfollow @admin')
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Unfollow @admin')
|
||||||
.expect(getNthDialogOptionsOption(2).innerText).contains('Block @admin')
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Block @admin')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(getNthDialogOptionsOption(2))
|
.click(getNthDialogOptionsOption(2))
|
||||||
.expect(modalDialog.exists).notOk()
|
.expect(modalDialog.exists).notOk()
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(communityNavButton)
|
.click(communityNavButton)
|
||||||
.click($('a[href="/blocked"]'))
|
.click($('a[href="/blocked"]'))
|
||||||
.expect(getNthSearchResult(1).innerText).contains('@admin')
|
.expect(getNthSearchResult(1).innerText).contains('@admin')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(getNthSearchResult(1))
|
.click(getNthSearchResult(1))
|
||||||
.expect(getUrl()).contains('/accounts/1')
|
.expect(getUrl()).contains('/accounts/1')
|
||||||
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unblock')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unblock')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(accountProfileFollowButton)
|
.click(accountProfileFollowButton)
|
||||||
.expect(accountProfileFollowedBy.innerText).contains('')
|
.expect(accountProfileFollowedBy.innerText).contains('')
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(accountProfileFollowButton)
|
.click(accountProfileFollowButton)
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
|
||||||
|
@ -44,21 +57,31 @@ test('Can block and unblock an account from the account profile page', async t =
|
||||||
await t
|
await t
|
||||||
.navigateTo('/accounts/5')
|
.navigateTo('/accounts/5')
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(accountProfileMoreOptionsButton)
|
.click(accountProfileMoreOptionsButton)
|
||||||
.expect(getNthDialogOptionsOption(1).innerText).contains('Mention @baz')
|
.expect(getNthDialogOptionsOption(1).innerText).contains('Mention @baz')
|
||||||
.expect(getNthDialogOptionsOption(2).innerText).contains('Follow @baz')
|
.expect(getNthDialogOptionsOption(2).innerText).contains('Follow @baz')
|
||||||
.expect(getNthDialogOptionsOption(3).innerText).contains('Block @baz')
|
.expect(getNthDialogOptionsOption(3).innerText).contains('Block @baz')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(getNthDialogOptionsOption(3))
|
.click(getNthDialogOptionsOption(3))
|
||||||
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
.expect(accountProfileFollowedBy.innerText).match(/blocked/i)
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unblock')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unblock')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unblock')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(accountProfileFollowButton)
|
.click(accountProfileFollowButton)
|
||||||
.expect(accountProfileFollowedBy.innerText).contains('')
|
.expect(accountProfileFollowedBy.innerText).contains('')
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(accountProfileFollowButton)
|
.click(accountProfileFollowButton)
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
|
||||||
|
await sleep(500)
|
||||||
|
await t
|
||||||
.click(accountProfileFollowButton)
|
.click(accountProfileFollowButton)
|
||||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
|
||||||
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
.expect(accountProfileFollowButton.getAttribute('title')).eql('Follow')
|
||||||
|
|
Loading…
Reference in a new issue