2018-06-09 05:54:21 +01:00
|
|
|
import { closeDialogButton, getNthStatus, getNthStatusSelector, modalDialogContents, scrollToStatus } from '../utils'
|
2018-05-26 21:51:41 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 05:54:21 +01:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-11-12 20:59:47 +00:00
|
|
|
import { homeTimeline } from '../fixtures'
|
2018-12-11 15:31:48 +00:00
|
|
|
import { indexWhere } from '../../src/routes/_utils/arrays'
|
2018-02-20 17:05:53 +00:00
|
|
|
|
2018-03-07 05:32:51 +00:00
|
|
|
fixture`008-status-media.js`
|
2018-02-20 17:05:53 +00:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
2018-02-20 17:42:55 +00:00
|
|
|
test('shows sensitive images and videos', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 20:59:47 +00:00
|
|
|
|
|
|
|
let kittenIdx = indexWhere(homeTimeline, _ => _.spoiler === 'kitten CW')
|
|
|
|
let videoIdx = indexWhere(homeTimeline, _ => _.content === 'secret video')
|
|
|
|
|
|
|
|
await scrollToStatus(t, kittenIdx)
|
|
|
|
await t.expect($(`${getNthStatusSelector(kittenIdx)} .status-media img`).exists).notOk()
|
|
|
|
.click($(`${getNthStatusSelector(kittenIdx)} .status-sensitive-media-button`))
|
|
|
|
.expect($(`${getNthStatusSelector(kittenIdx)} .status-media img`).getAttribute('alt')).eql('kitten')
|
|
|
|
.expect($(`${getNthStatusSelector(kittenIdx)} .status-media img`).hasAttribute('src')).ok()
|
|
|
|
.hover(getNthStatus(videoIdx))
|
|
|
|
.expect($(`${getNthStatusSelector(videoIdx)} .status-media .play-video-button`).exists).notOk()
|
|
|
|
.click($(`${getNthStatusSelector(videoIdx)} .status-sensitive-media-button`))
|
|
|
|
.expect($(`${getNthStatusSelector(videoIdx)} .status-media .play-video-button`).exists).ok()
|
2018-02-20 17:05:53 +00:00
|
|
|
})
|
2018-02-20 17:42:55 +00:00
|
|
|
|
|
|
|
test('click and close image and video modals', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 20:59:47 +00:00
|
|
|
|
|
|
|
let videoIdx = indexWhere(homeTimeline, _ => _.content === "here's a video")
|
|
|
|
let kittenIdx = indexWhere(homeTimeline, _ => _.content === "here's an animated kitten gif")
|
|
|
|
|
|
|
|
await scrollToStatus(t, videoIdx)
|
2018-02-21 17:26:22 +00:00
|
|
|
await t.expect(modalDialogContents.exists).notOk()
|
2018-11-12 20:59:47 +00:00
|
|
|
.click($(`${getNthStatusSelector(videoIdx)} .play-video-button`))
|
2018-02-20 17:42:55 +00:00
|
|
|
.expect(modalDialogContents.exists).ok()
|
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2018-11-12 20:59:47 +00:00
|
|
|
.hover(getNthStatus(kittenIdx - 1))
|
|
|
|
.hover(getNthStatus(kittenIdx))
|
|
|
|
.click($(`${getNthStatusSelector(kittenIdx)} .show-image-button`))
|
2018-02-20 17:42:55 +00:00
|
|
|
.expect(modalDialogContents.exists).ok()
|
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2018-02-21 05:30:16 +00:00
|
|
|
})
|