2018-12-01 23:09:08 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
|
|
|
import {
|
|
|
|
generalSettingsButton,
|
2019-08-17 19:54:45 +02:00
|
|
|
getNthStatus, getNthStatusMediaImg, getNthStatusSensitiveMediaButton, homeNavButton, markMediaSensitiveInput,
|
2018-12-01 23:09:08 +01:00
|
|
|
scrollToStatus, settingsNavButton, neverMarkMediaSensitiveInput
|
|
|
|
} from '../utils'
|
2019-03-31 18:21:57 +02:00
|
|
|
|
2018-12-01 23:09:08 +01:00
|
|
|
import { homeTimeline } from '../fixtures'
|
|
|
|
|
|
|
|
fixture`023-mark-media-as-sensitive.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
async function checkSensitivityForStatus (t, idx, sensitive) {
|
|
|
|
if (sensitive) {
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect(getNthStatusSensitiveMediaButton(1 + idx).exists).ok()
|
2019-08-17 19:54:45 +02:00
|
|
|
.expect(getNthStatusMediaImg(1 + idx).getAttribute('src')).match(/^blob:http:\/\/localhost/)
|
2018-12-01 23:09:08 +01:00
|
|
|
} else {
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect(getNthStatusSensitiveMediaButton(1 + idx).exists).notOk()
|
2019-08-17 19:54:45 +02:00
|
|
|
.expect(getNthStatusMediaImg(1 + idx).getAttribute('src')).match(/^http:\/\//)
|
2018-12-01 23:09:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function checkSensitivity (t, shouldBeSensitive) {
|
2019-08-03 22:49:37 +02:00
|
|
|
const sensitiveKittenIdx = homeTimeline.findIndex(_ => _.spoiler === 'kitten CW')
|
|
|
|
const sensitiveVideoIdx = homeTimeline.findIndex(_ => _.content === 'secret video')
|
|
|
|
const videoIdx = homeTimeline.findIndex(_ => _.content === "here's a video")
|
|
|
|
const sensitiveAnimatedKittenIdx = homeTimeline.findIndex(_ => _.content === "here's a secret animated kitten gif")
|
|
|
|
const animatedKittenIdx = homeTimeline.findIndex(_ => _.content === "here's an animated kitten gif")
|
2018-12-01 23:09:08 +01:00
|
|
|
|
2019-02-28 17:56:25 +01:00
|
|
|
await t.hover(getNthStatus(1))
|
2018-12-01 23:09:08 +01:00
|
|
|
|
2019-08-03 22:49:37 +02:00
|
|
|
const expected = [
|
|
|
|
[sensitiveKittenIdx, shouldBeSensitive(true)],
|
|
|
|
[sensitiveVideoIdx, shouldBeSensitive(true)],
|
|
|
|
[videoIdx, shouldBeSensitive(false)],
|
|
|
|
[sensitiveAnimatedKittenIdx, shouldBeSensitive(true)],
|
|
|
|
[animatedKittenIdx, shouldBeSensitive(false)]
|
2018-12-01 23:09:08 +01:00
|
|
|
]
|
|
|
|
|
2019-08-03 22:49:37 +02:00
|
|
|
for (const [idx, sensitive] of expected) {
|
2019-02-28 17:56:25 +01:00
|
|
|
await scrollToStatus(t, 1 + sensitiveKittenIdx)
|
2018-12-01 23:09:08 +01:00
|
|
|
await checkSensitivityForStatus(t, idx, sensitive)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function changeSetting (t, input, checked) {
|
|
|
|
await t
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(input)
|
|
|
|
if (checked) {
|
|
|
|
await t.expect(input.checked).ok()
|
|
|
|
} else {
|
|
|
|
await t.expect(input.checked).notOk()
|
|
|
|
}
|
|
|
|
await t.click(homeNavButton)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function doMarkMediaAsSensitive (t, checked) {
|
|
|
|
await changeSetting(t, markMediaSensitiveInput, checked)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function doNeverMarkMediaAsSensitive (t, checked) {
|
|
|
|
await changeSetting(t, neverMarkMediaSensitiveInput, checked)
|
|
|
|
}
|
|
|
|
|
|
|
|
test('default sensitive settings', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await checkSensitivity(t, sensitive => sensitive)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('always mark media sensitive', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await doMarkMediaAsSensitive(t, true)
|
|
|
|
await checkSensitivity(t, () => true)
|
|
|
|
// cleanup
|
|
|
|
await doMarkMediaAsSensitive(t, false)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('never mark media sensitive', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await doNeverMarkMediaAsSensitive(t, true)
|
|
|
|
await checkSensitivity(t, () => false)
|
|
|
|
// cleanup
|
|
|
|
await doNeverMarkMediaAsSensitive(t, false)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('settings are mutually exclusive', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(generalSettingsButton)
|
|
|
|
.click(markMediaSensitiveInput)
|
|
|
|
.expect(markMediaSensitiveInput.checked).ok()
|
|
|
|
.expect(neverMarkMediaSensitiveInput.checked).notOk()
|
|
|
|
.click(neverMarkMediaSensitiveInput)
|
|
|
|
.expect(markMediaSensitiveInput.checked).notOk()
|
|
|
|
.expect(neverMarkMediaSensitiveInput.checked).ok()
|
|
|
|
.click(markMediaSensitiveInput)
|
|
|
|
.expect(markMediaSensitiveInput.checked).ok()
|
|
|
|
.expect(neverMarkMediaSensitiveInput.checked).notOk()
|
|
|
|
.click(markMediaSensitiveInput)
|
|
|
|
.expect(markMediaSensitiveInput.checked).notOk()
|
|
|
|
.expect(neverMarkMediaSensitiveInput.checked).notOk()
|
|
|
|
})
|