pinafore/tests/spec/005-status-types.js

48 lines
3.2 KiB
JavaScript
Raw Normal View History

import { getNthStatus, getNthStatusSelector } from '../utils'
import { loginAsFoobar } from '../roles'
import { Selector as $ } from 'testcafe'
2018-02-20 03:24:22 +01:00
2018-03-07 06:32:51 +01:00
fixture`005-status-types.js`
2018-02-20 03:25:59 +01:00
.page`http://localhost:4002`
2018-02-20 03:24:22 +01:00
test('shows direct vs followers-only vs regular', async t => {
await loginAsFoobar(t)
await t
2018-02-21 06:08:26 +01:00
.expect(getNthStatus(1).getAttribute('aria-label')).eql('Status by admin')
.expect($(`${getNthStatusSelector(1)} .status-content`).innerText).contains('notification of unlisted message')
.expect($(`${getNthStatusSelector(1)} .status-toolbar button:nth-child(2)`).getAttribute('aria-label'))
2018-04-19 05:43:13 +02:00
.eql('Boost')
.expect($(`${getNthStatusSelector(1)} .status-toolbar button:nth-child(2)`).hasAttribute('disabled')).notOk()
2018-02-21 06:08:26 +01:00
.expect(getNthStatus(2).getAttribute('aria-label')).eql('Status by admin')
.expect($(`${getNthStatusSelector(2)} .status-content`).innerText).contains('notification of followers-only message')
.expect($(`${getNthStatusSelector(2)} .status-toolbar button:nth-child(2)`).getAttribute('aria-label'))
2018-04-19 05:43:13 +02:00
.eql('Cannot be boosted because this is followers-only')
.expect($(`${getNthStatusSelector(2)} .status-toolbar button:nth-child(2)`).hasAttribute('disabled')).ok()
2018-02-21 06:08:26 +01:00
.expect(getNthStatus(3).getAttribute('aria-label')).eql('Direct message by admin')
.expect($(`${getNthStatusSelector(3)} .status-content`).innerText).contains('notification of direct message')
.expect($(`${getNthStatusSelector(3)} .status-toolbar button:nth-child(2)`).getAttribute('aria-label'))
2018-04-19 05:43:13 +02:00
.eql('Cannot be boosted because this is a direct message')
.expect($(`${getNthStatusSelector(3)} .status-toolbar button:nth-child(2)`).hasAttribute('disabled')).ok()
2018-02-20 03:24:22 +01:00
})
test('shows direct vs followers-only vs regular in notifications', async t => {
await loginAsFoobar(t)
await t
2018-02-20 03:24:22 +01:00
.navigateTo('/notifications')
2018-02-21 06:08:26 +01:00
.expect(getNthStatus(2).getAttribute('aria-label')).eql('Status by admin')
.expect($(`${getNthStatusSelector(2)} .status-content`).innerText).contains('notification of unlisted message')
.expect($(`${getNthStatusSelector(2)} .status-toolbar button:nth-child(2)`).getAttribute('aria-label'))
2018-02-20 03:24:22 +01:00
.eql('Boost')
.expect($(`${getNthStatusSelector(2)} .status-toolbar button:nth-child(2)`).hasAttribute('disabled')).notOk()
2018-02-21 06:08:26 +01:00
.expect(getNthStatus(3).getAttribute('aria-label')).eql('Status by admin')
.expect($(`${getNthStatusSelector(3)} .status-content`).innerText).contains('notification of followers-only message')
.expect($(`${getNthStatusSelector(3)} .status-toolbar button:nth-child(2)`).getAttribute('aria-label'))
2018-02-20 03:24:22 +01:00
.eql('Cannot be boosted because this is followers-only')
.expect($(`${getNthStatusSelector(3)} .status-toolbar button:nth-child(2)`).hasAttribute('disabled')).ok()
2018-02-21 06:08:26 +01:00
.expect(getNthStatus(4).getAttribute('aria-label')).eql('Direct message by admin')
.expect($(`${getNthStatusSelector(4)} .status-content`).innerText).contains('notification of direct message')
.expect($(`${getNthStatusSelector(4)} .status-toolbar button:nth-child(2)`).getAttribute('aria-label'))
2018-02-20 03:24:22 +01:00
.eql('Cannot be boosted because this is a direct message')
.expect($(`${getNthStatusSelector(4)} .status-toolbar button:nth-child(2)`).hasAttribute('disabled')).ok()
2018-02-20 03:24:22 +01:00
})