semaphore/tests/spec/009-threads.js

83 lines
2.6 KiB
JavaScript
Raw Normal View History

2018-02-21 05:08:26 +00:00
import { Selector as $ } from 'testcafe'
2018-03-09 02:08:14 +00:00
import {
getNthStatus, getUrl, validateTimeline, scrollToBottomOfTimeline, getFirstVisibleStatus,
goBack, forceOffline, forceOnline, homeNavButton, searchNavButton, searchInput, getNthSearchResult
} from '../utils'
2018-02-21 05:08:26 +00:00
import { foobarRole } from '../roles'
2018-03-09 02:08:14 +00:00
import { bazThreadRelativeTo2, bazThreadRelativeTo2b, bazThreadRelativeTo2B2, quuxThread } from '../fixtures'
2018-02-21 05:08:26 +00:00
2018-03-07 05:32:51 +00:00
fixture`009-threads.js`
2018-02-21 05:08:26 +00:00
.page`http://localhost:4002`
2018-03-09 02:08:14 +00:00
/*
2018-02-21 05:08:26 +00:00
test('Shows a thread', async t => {
await t.useRole(foobarRole)
.click($('a').withText('quux'))
await scrollToBottomOfTimeline(t)
await t
.click(getNthStatus(26))
2018-03-06 06:36:54 +00:00
.expect(getUrl()).contains('/statuses/')
2018-02-21 05:08:26 +00:00
await validateTimeline(t, quuxThread)
await t.expect(getNthStatus(24).getAttribute('aria-setsize')).eql('25')
})
test('Scrolls to proper point in thread', async t => {
await t.useRole(foobarRole)
.click($('a').withText('quux'))
.hover(getNthStatus(0))
.hover(getNthStatus(2))
.hover(getNthStatus(4))
.hover(getNthStatus(6))
.hover(getNthStatus(8))
.hover(getNthStatus(10))
.click(getNthStatus(10))
2018-03-06 06:36:54 +00:00
.expect(getUrl()).contains('/statuses/')
2018-02-21 05:08:26 +00:00
.expect(getNthStatus(16).innerText).contains('unlisted thread 17')
.expect(Math.round(getNthStatus(16).boundingClientRect.top))
.eql(Math.round($('.container').boundingClientRect.top))
2018-02-21 05:30:16 +00:00
})
2018-03-09 02:08:14 +00:00
*/
async function navigateToBazAccount(t) {
await t.click(searchNavButton)
.expect(getUrl()).contains('/search')
.typeText(searchInput, 'baz', {paste: true})
.pressKey('enter')
.click(getNthSearchResult(1))
.expect(getUrl()).contains('/accounts/5')
}
async function validateForkedThread(t) {
await t.hover(getNthStatus(1))
.click(getNthStatus(2))
.expect(getUrl()).contains('/statuses')
await validateTimeline(t, bazThreadRelativeTo2B2)
await goBack()
await t.hover(getNthStatus(3))
.hover(getNthStatus(5))
.hover(getNthStatus(7))
.hover(getNthStatus(9))
.click(getNthStatus(9))
.expect(getUrl()).contains('/statuses')
await validateTimeline(t, bazThreadRelativeTo2b)
await goBack()
await t.hover(getNthStatus(11))
.click(getNthStatus(11))
.expect(getUrl()).contains('/statuses')
await validateTimeline(t, bazThreadRelativeTo2)
}
test('Forked threads look correct online and offline', async t => {
await t.useRole(foobarRole)
.hover(getFirstVisibleStatus())
await navigateToBazAccount(t)
await validateForkedThread(t)
await t.navigateTo('/')
.hover(getFirstVisibleStatus())
await navigateToBazAccount(t)
await forceOffline()
await validateForkedThread(t)
await forceOnline()
})