pinafore/tests/spec/114-mute-unmute.js
Nolan Lawson edc014cf8c
fix: more consistent toggle button aria-label/title (#1626)
* fix: more consistent toggle button aria-label/title

fixes #1624

* fixup

* fix test
2019-11-09 17:25:26 -05:00

67 lines
2.4 KiB
JavaScript

import {
accountProfileFollowButton,
accountProfileMoreOptionsButton,
communityNavButton,
getNthSearchResult,
getNthStatus,
getNthStatusOptionsButton,
getNthDialogOptionsOption,
getUrl,
modalDialog,
closeDialogButton,
confirmationDialogOKButton, sleep
} from '../utils'
import { Selector as $ } from 'testcafe'
import { loginAsFoobar } from '../roles'
import { postAs } from '../serverActions'
fixture`114-mute-unmute.js`
.page`http://localhost:4002`
test('Can mute and unmute an account', async t => {
await loginAsFoobar(t)
const post = 'blah blah blah'
await postAs('admin', post)
await t.expect(getNthStatus(1).innerText).contains(post, { timeout: 20000 })
.click(getNthStatusOptionsButton(1))
.expect(getNthDialogOptionsOption(1).innerText).contains('Unfollow @admin')
.expect(getNthDialogOptionsOption(2).innerText).contains('Block @admin')
.expect(getNthDialogOptionsOption(3).innerText).contains('Mute @admin')
await sleep(1000)
await t
.click(getNthDialogOptionsOption(3))
await sleep(1000)
await t
.click(confirmationDialogOKButton)
.expect(modalDialog.exists).notOk()
await sleep(1000)
await t
.click(communityNavButton)
.click($('a[href="/muted"]'))
.expect(getNthSearchResult(1).innerText).contains('@admin')
.click(getNthSearchResult(1))
.expect(getUrl()).contains('/accounts/1')
.click(accountProfileMoreOptionsButton)
.expect(getNthDialogOptionsOption(1).innerText).contains('Mention @admin')
.expect(getNthDialogOptionsOption(2).innerText).contains('Unfollow @admin')
.expect(getNthDialogOptionsOption(3).innerText).contains('Block @admin')
.expect(getNthDialogOptionsOption(4).innerText).contains('Unmute @admin')
await sleep(1000)
await t
.click(getNthDialogOptionsOption(4))
await sleep(1000)
await t
.click(accountProfileMoreOptionsButton)
.expect(getNthDialogOptionsOption(1).innerText).contains('Mention @admin')
.expect(getNthDialogOptionsOption(2).innerText).contains('Unfollow @admin')
.expect(getNthDialogOptionsOption(3).innerText).contains('Block @admin')
.expect(getNthDialogOptionsOption(4).innerText).contains('Mute @admin')
await sleep(1000)
await t
.click(closeDialogButton)
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Follow')
.expect(accountProfileFollowButton.getAttribute('title')).eql('Unfollow')
.expect(accountProfileFollowButton.getAttribute('aria-pressed')).eql('true')
})