2020-04-26 04:03:39 +02:00
|
|
|
import {
|
|
|
|
closeDialogButton,
|
|
|
|
getNthStatus,
|
|
|
|
getNthStatusMediaButton,
|
|
|
|
getNthStatusSelector,
|
|
|
|
modalDialogContents,
|
|
|
|
scrollToStatus
|
|
|
|
} from '../utils'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 06:54:21 +02:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-11-12 21:59:47 +01:00
|
|
|
import { homeTimeline } from '../fixtures'
|
2018-02-20 18:05:53 +01:00
|
|
|
|
2018-03-07 06:32:51 +01:00
|
|
|
fixture`008-status-media.js`
|
2018-02-20 18:05:53 +01:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
2018-02-20 18:42:55 +01:00
|
|
|
test('shows sensitive images and videos', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 21:59:47 +01:00
|
|
|
|
2019-08-03 22:49:37 +02:00
|
|
|
const kittenIdx = homeTimeline.findIndex(_ => _.spoiler === 'kitten CW')
|
|
|
|
const videoIdx = homeTimeline.findIndex(_ => _.content === 'secret video')
|
2018-11-12 21:59:47 +01:00
|
|
|
|
2019-02-28 17:56:25 +01:00
|
|
|
await scrollToStatus(t, 1 + kittenIdx)
|
2020-04-26 04:03:39 +02:00
|
|
|
await t.expect($(`${getNthStatusSelector(1 + kittenIdx)} .status-media img`).getAttribute('src'))
|
|
|
|
.match(/^blob:http:\/\/localhost/)
|
2019-02-28 17:56:25 +01:00
|
|
|
.click($(`${getNthStatusSelector(1 + kittenIdx)} .status-sensitive-media-button`))
|
2020-04-26 04:03:39 +02:00
|
|
|
.expect($(getNthStatusMediaButton(1 + kittenIdx)).getAttribute('aria-label')).eql('Show image: kitten')
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect($(`${getNthStatusSelector(1 + kittenIdx)} .status-media img`).getAttribute('alt')).eql('kitten')
|
2019-08-17 19:54:45 +02:00
|
|
|
.expect($(`${getNthStatusSelector(1 + kittenIdx)} .status-media img`).getAttribute('src')).match(/^http:\/\//)
|
2019-02-28 17:56:25 +01:00
|
|
|
.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 18:05:53 +01:00
|
|
|
})
|
2018-02-20 18:42:55 +01:00
|
|
|
|
|
|
|
test('click and close image and video modals', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
2018-11-12 21:59:47 +01:00
|
|
|
|
2019-08-03 22:49:37 +02:00
|
|
|
const videoIdx = homeTimeline.findIndex(_ => _.content === "here's a video")
|
|
|
|
const kittenIdx = homeTimeline.findIndex(_ => _.content === "here's an animated kitten gif")
|
2018-11-12 21:59:47 +01:00
|
|
|
|
2019-02-28 17:56:25 +01:00
|
|
|
await scrollToStatus(t, 1 + videoIdx)
|
2018-02-21 18:26:22 +01:00
|
|
|
await t.expect(modalDialogContents.exists).notOk()
|
2020-04-26 04:03:39 +02:00
|
|
|
.expect($(getNthStatusMediaButton(1 + videoIdx)).getAttribute('aria-label'))
|
|
|
|
.eql('Play video: kitten')
|
|
|
|
.click($(getNthStatusMediaButton(1 + videoIdx)))
|
2018-02-20 18:42:55 +01:00
|
|
|
.expect(modalDialogContents.exists).ok()
|
2019-02-24 06:10:15 +01:00
|
|
|
.expect($('.modal-dialog video').getAttribute('src')).contains('mp4')
|
|
|
|
.expect($('.modal-dialog video').getAttribute('poster')).contains('png')
|
2018-02-20 18:42:55 +01:00
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2019-02-28 17:56:25 +01:00
|
|
|
.hover(getNthStatus(1 + kittenIdx - 1))
|
|
|
|
.hover(getNthStatus(1 + kittenIdx))
|
2020-04-26 04:03:39 +02:00
|
|
|
.expect($(getNthStatusMediaButton(1 + kittenIdx)).getAttribute('aria-label'))
|
|
|
|
.eql('Show animated image: kitten')
|
|
|
|
.click($(getNthStatusMediaButton(1 + kittenIdx)))
|
2018-02-20 18:42:55 +01:00
|
|
|
.expect(modalDialogContents.exists).ok()
|
2019-02-24 06:10:15 +01:00
|
|
|
.expect($('.modal-dialog video').getAttribute('src')).contains('mp4')
|
|
|
|
.expect($('.modal-dialog video').getAttribute('poster')).contains('png')
|
2018-02-20 18:42:55 +01:00
|
|
|
.click(closeDialogButton)
|
|
|
|
.expect(modalDialogContents.exists).notOk()
|
2018-02-21 06:30:16 +01:00
|
|
|
})
|