1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-12 18:28:03 +01:00
Pinafore-Web-Client-Frontend/tests/spec/008-status-media.js
Sorin Davidoi 77bb784efd feat(media): Blurhash (#1381)
* chore(npm): Install blurhash

* feat(media): Show blurhash

* fix(media/blurhash): Better sensitive video handling

* feat(media): Preference for using blurhash

* chore(utils/blurhash): Add performance marks

* fix(utils/blurhash): Performance marks

* fix(utils/blurhash): Use correct dimension

* refactor(utils/blurhash): Use constant for number of pixels

* refactor(media): Simplify logic for displaying blurhash

* chore(tests/spec): Attempt to adjust sensitivity tests for blurhash

* chore(tests/spec): Update sensitivity tests for blurhash

* chore(tests/spec): Check for sensitive

* fix(media/blurhash): Handle videos

* fix: Video handling

* fix: Videos

* minor refactoring, fix Svelte warning

* fix: Large inline images and videos

* feat(settings): Rename blurhash setting

* refactor: Use toBlob, block media rendering until blurhash ready

* refactor: Move computations to Web Worker

* fix(workers/blurhash): More error handling

* feat(workers/blurhash): Use quick-lru for caching

* fix: Don't create Context2D needlessly

* fix(workers/blurhash): Increase cache size to 100

* fix(workers/blurhash): Don't resolve promise twice

* fix(utils/decode-image): Ignore data URLs

Throws exception which prevents the image from loading.
2019-08-17 10:54:45 -07:00

49 lines
2.4 KiB
JavaScript

import { closeDialogButton, getNthStatus, getNthStatusSelector, modalDialogContents, scrollToStatus } from '../utils'
import { loginAsFoobar } from '../roles'
import { Selector as $ } from 'testcafe'
import { homeTimeline } from '../fixtures'
fixture`008-status-media.js`
.page`http://localhost:4002`
test('shows sensitive images and videos', async t => {
await loginAsFoobar(t)
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()
})
test('click and close image and video modals', async t => {
await loginAsFoobar(t)
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)
await t.expect(modalDialogContents.exists).notOk()
.click($(`${getNthStatusSelector(1 + videoIdx)} .play-video-button`))
.expect(modalDialogContents.exists).ok()
.expect($('.modal-dialog video').getAttribute('src')).contains('mp4')
.expect($('.modal-dialog video').getAttribute('poster')).contains('png')
.click(closeDialogButton)
.expect(modalDialogContents.exists).notOk()
.hover(getNthStatus(1 + kittenIdx - 1))
.hover(getNthStatus(1 + kittenIdx))
.click($(`${getNthStatusSelector(1 + kittenIdx)} .show-image-button`))
.expect(modalDialogContents.exists).ok()
.expect($('.modal-dialog video').getAttribute('src')).contains('mp4')
.expect($('.modal-dialog video').getAttribute('poster')).contains('png')
.click(closeDialogButton)
.expect(modalDialogContents.exists).notOk()
})