2018-02-21 05:08:26 +00:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-03-09 02:08:14 +00:00
|
|
|
import {
|
2018-11-22 06:08:37 +00:00
|
|
|
getNthStatus, getUrl, validateTimeline, getFirstVisibleStatus,
|
|
|
|
goBack, forceOffline, forceOnline, searchNavButton, searchInput, getNthSearchResult, scrollToStatus
|
2018-03-09 02:08:14 +00:00
|
|
|
} from '../utils'
|
2018-05-26 20:51:41 +00:00
|
|
|
import { loginAsFoobar } 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:09:11 +00:00
|
|
|
|
2018-02-21 05:08:26 +00:00
|
|
|
test('Shows a thread', async t => {
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-02-21 05:08:26 +00:00
|
|
|
.click($('a').withText('quux'))
|
|
|
|
|
2019-02-28 16:56:25 +00:00
|
|
|
await scrollToStatus(t, 27)
|
2018-02-21 05:08:26 +00:00
|
|
|
await t
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(27))
|
|
|
|
.click(getNthStatus(27))
|
2018-03-06 06:36:54 +00:00
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2018-02-21 05:08:26 +00:00
|
|
|
|
|
|
|
await validateTimeline(t, quuxThread)
|
|
|
|
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.expect(getNthStatus(25).getAttribute('aria-setsize')).eql('25')
|
2018-02-21 05:08:26 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('Scrolls to proper point in thread', async t => {
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-02-21 05:08:26 +00:00
|
|
|
.click($('a').withText('quux'))
|
2019-02-28 16:56:25 +00:00
|
|
|
.hover(getNthStatus(1))
|
|
|
|
.hover(getNthStatus(3))
|
|
|
|
.hover(getNthStatus(5))
|
|
|
|
.hover(getNthStatus(7))
|
|
|
|
.hover(getNthStatus(9))
|
|
|
|
.hover(getNthStatus(11))
|
|
|
|
.click(getNthStatus(11))
|
2018-03-06 06:36:54 +00:00
|
|
|
.expect(getUrl()).contains('/statuses/')
|
2019-02-28 16:56:25 +00:00
|
|
|
.expect(getNthStatus(17).innerText).contains('unlisted thread 17')
|
|
|
|
.expect(Math.round(getNthStatus(17).boundingClientRect.top))
|
2018-11-18 02:06:49 +00:00
|
|
|
.eql(Math.round($('.main-content').boundingClientRect.top))
|
2018-02-21 05:30:16 +00:00
|
|
|
})
|
2018-03-09 02:08:14 +00:00
|
|
|
|
2018-03-09 02:09:35 +00:00
|
|
|
async function navigateToBazAccount (t) {
|
2018-03-09 02:08:14 +00:00
|
|
|
await t.click(searchNavButton)
|
|
|
|
.expect(getUrl()).contains('/search')
|
2018-08-30 04:42:57 +00:00
|
|
|
.typeText(searchInput, 'baz', { paste: true })
|
2018-03-09 02:08:14 +00:00
|
|
|
.pressKey('enter')
|
|
|
|
.click(getNthSearchResult(1))
|
|
|
|
.expect(getUrl()).contains('/accounts/5')
|
|
|
|
}
|
|
|
|
|
2018-03-09 02:09:35 +00:00
|
|
|
async function validateForkedThread (t) {
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.hover(getNthStatus(2))
|
|
|
|
.click(getNthStatus(3))
|
2018-03-09 02:08:14 +00:00
|
|
|
.expect(getUrl()).contains('/statuses')
|
|
|
|
await validateTimeline(t, bazThreadRelativeTo2B2)
|
|
|
|
await goBack()
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.hover(getNthStatus(4))
|
|
|
|
.hover(getNthStatus(6))
|
|
|
|
.hover(getNthStatus(8))
|
|
|
|
.hover(getNthStatus(10))
|
|
|
|
.click(getNthStatus(10))
|
2018-03-09 02:08:14 +00:00
|
|
|
.expect(getUrl()).contains('/statuses')
|
|
|
|
await validateTimeline(t, bazThreadRelativeTo2b)
|
|
|
|
await goBack()
|
2019-02-28 16:56:25 +00:00
|
|
|
await t.hover(getNthStatus(12))
|
|
|
|
.click(getNthStatus(12))
|
2018-03-09 02:08:14 +00:00
|
|
|
.expect(getUrl()).contains('/statuses')
|
|
|
|
await validateTimeline(t, bazThreadRelativeTo2)
|
|
|
|
}
|
|
|
|
|
|
|
|
test('Forked threads look correct online and offline', async t => {
|
2018-05-26 20:51:41 +00:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-09 02:08:14 +00:00
|
|
|
.hover(getFirstVisibleStatus())
|
|
|
|
await navigateToBazAccount(t)
|
|
|
|
await validateForkedThread(t)
|
2018-03-09 02:37:32 +00:00
|
|
|
await t.navigateTo('/') // clears in-memory cache while still preserving IDB cache
|
2018-03-09 02:08:14 +00:00
|
|
|
.hover(getFirstVisibleStatus())
|
|
|
|
await navigateToBazAccount(t)
|
|
|
|
await forceOffline()
|
|
|
|
await validateForkedThread(t)
|
|
|
|
await forceOnline()
|
2018-03-09 02:09:35 +00:00
|
|
|
})
|