pinafore/tests/spec/008-status-media.js

49 lines
2.4 KiB
JavaScript
Raw Normal View History

import { closeDialogButton, getNthStatus, getNthStatusSelector, modalDialogContents, scrollToStatus } from '../utils'
import { loginAsFoobar } from '../roles'
import { Selector as $ } from 'testcafe'
import { homeTimeline } from '../fixtures'
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 => {
await loginAsFoobar(t)
2019-08-03 21:49:37 +01:00
const kittenIdx = homeTimeline.findIndex(_ => _.spoiler === 'kitten CW')
const videoIdx = homeTimeline.findIndex(_ => _.content === 'secret video')
await scrollToStatus(t, 1 + kittenIdx)
await t.expect($(`${getNthStatusSelector(1 + kittenIdx)} .status-media img`).getAttribute('src')).match(/^blob:http:\/\/localhost/)
.click($(`${getNthStatusSelector(1 + kittenIdx)} .status-sensitive-media-button`))
.expect($(`${getNthStatusSelector(1 + kittenIdx)} .status-media img`).getAttribute('alt')).eql('kitten')
.expect($(`${getNthStatusSelector(1 + kittenIdx)} .status-media img`).getAttribute('src')).match(/^http:\/\//)
.hover(getNthStatus(1 + videoIdx))
.expect($(`${getNthStatusSelector(1 + videoIdx)} .status-media .play-video-button`).exists).notOk()
.click($(`${getNthStatusSelector(1 + videoIdx)} .status-sensitive-media-button`))
.expect($(`${getNthStatusSelector(1 + 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 => {
await loginAsFoobar(t)
2019-08-03 21:49:37 +01:00
const videoIdx = homeTimeline.findIndex(_ => _.content === "here's a video")
const kittenIdx = homeTimeline.findIndex(_ => _.content === "here's an animated kitten gif")
await scrollToStatus(t, 1 + videoIdx)
2018-02-21 17:26:22 +00:00
await t.expect(modalDialogContents.exists).notOk()
.click($(`${getNthStatusSelector(1 + videoIdx)} .play-video-button`))
2018-02-20 17:42:55 +00:00
.expect(modalDialogContents.exists).ok()
.expect($('.modal-dialog video').getAttribute('src')).contains('mp4')
.expect($('.modal-dialog video').getAttribute('poster')).contains('png')
2018-02-20 17:42:55 +00:00
.click(closeDialogButton)
.expect(modalDialogContents.exists).notOk()
.hover(getNthStatus(1 + kittenIdx - 1))
.hover(getNthStatus(1 + kittenIdx))
.click($(`${getNthStatusSelector(1 + kittenIdx)} .show-image-button`))
2018-02-20 17:42:55 +00:00
.expect(modalDialogContents.exists).ok()
.expect($('.modal-dialog video').getAttribute('src')).contains('mp4')
.expect($('.modal-dialog video').getAttribute('poster')).contains('png')
2018-02-20 17:42:55 +00:00
.click(closeDialogButton)
.expect(modalDialogContents.exists).notOk()
2018-02-21 05:30:16 +00:00
})