2018-04-10 02:30:15 +01:00
|
|
|
import {
|
2019-09-17 08:19:59 +01:00
|
|
|
composeContentWarning,
|
|
|
|
composeInput, composeMediaSensitiveCheckbox, contentWarningButton,
|
2019-07-07 08:14:19 +01:00
|
|
|
getNthDeleteMediaButton,
|
|
|
|
getNthMedia,
|
|
|
|
getNthMediaAltInput,
|
|
|
|
getNthMediaListItem,
|
|
|
|
homeNavButton,
|
|
|
|
mediaButton,
|
|
|
|
settingsNavButton,
|
|
|
|
sleep,
|
2018-04-10 02:30:15 +01:00
|
|
|
uploadKittenImage
|
|
|
|
} from '../utils'
|
2018-05-26 21:51:41 +01:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-03-03 05:55:04 +00:00
|
|
|
|
2018-03-07 05:32:51 +00:00
|
|
|
fixture`013-compose-media.js`
|
2018-03-03 05:55:04 +00:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('inserts media', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-03 05:55:04 +00:00
|
|
|
.expect(mediaButton.hasAttribute('disabled')).notOk()
|
|
|
|
await (uploadKittenImage(1)())
|
2019-07-07 08:14:19 +01:00
|
|
|
await t.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
2018-03-03 05:55:04 +00:00
|
|
|
await (uploadKittenImage(2)())
|
2019-07-07 08:14:19 +01:00
|
|
|
await t.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-03-03 05:55:04 +00:00
|
|
|
.expect(mediaButton.hasAttribute('disabled')).notOk()
|
|
|
|
await (uploadKittenImage(3)())
|
2019-07-07 08:14:19 +01:00
|
|
|
await t.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
|
|
|
.expect(getNthMediaListItem(3).getAttribute('aria-label')).eql('kitten3.jpg')
|
2018-03-03 05:55:04 +00:00
|
|
|
.expect(mediaButton.hasAttribute('disabled')).notOk()
|
|
|
|
await (uploadKittenImage(4)())
|
2019-07-07 08:14:19 +01:00
|
|
|
await t.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
|
|
|
.expect(getNthMediaListItem(3).getAttribute('aria-label')).eql('kitten3.jpg')
|
|
|
|
.expect(getNthMediaListItem(4).getAttribute('aria-label')).eql('kitten4.jpg')
|
2018-03-03 05:55:04 +00:00
|
|
|
.expect(mediaButton.getAttribute('disabled')).eql('')
|
2018-03-03 18:27:14 +00:00
|
|
|
.click(getNthDeleteMediaButton(4))
|
|
|
|
.click(getNthDeleteMediaButton(3))
|
|
|
|
.click(getNthDeleteMediaButton(2))
|
|
|
|
.click(getNthDeleteMediaButton(1))
|
2018-03-11 19:10:59 +00:00
|
|
|
.expect(mediaButton.hasAttribute('disabled')).notOk()
|
2018-03-03 05:55:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('removes media', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-03-14 03:00:35 +00:00
|
|
|
.expect(mediaButton.exists).ok()
|
2018-03-03 05:55:04 +00:00
|
|
|
await (uploadKittenImage(1)())
|
2019-07-07 08:14:19 +01:00
|
|
|
await t.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
2018-03-03 05:55:04 +00:00
|
|
|
await (uploadKittenImage(2)())
|
2019-07-07 08:14:19 +01:00
|
|
|
await t.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-03-03 18:27:14 +00:00
|
|
|
.click(getNthDeleteMediaButton(2))
|
2018-03-03 05:55:04 +00:00
|
|
|
.expect(getNthMedia(2).exists).notOk()
|
|
|
|
.expect(getNthMedia(1).exists).ok()
|
2018-03-03 19:26:10 +00:00
|
|
|
.click(getNthDeleteMediaButton(1))
|
|
|
|
.expect(getNthMedia(2).exists).notOk()
|
|
|
|
})
|
|
|
|
|
2018-08-27 02:54:59 +01:00
|
|
|
test('does not add URLs as media is added/removed', async t => {
|
2018-05-26 21:51:41 +01:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-27 02:54:59 +01:00
|
|
|
.typeText(composeInput, 'this is a toot')
|
2018-03-14 03:00:35 +00:00
|
|
|
.expect(mediaButton.exists).ok()
|
2018-03-03 19:26:10 +00:00
|
|
|
await (uploadKittenImage(1)())
|
2021-02-16 00:45:41 +00:00
|
|
|
await sleep(500)
|
2018-08-27 02:54:59 +01:00
|
|
|
await t.expect(composeInput.value).eql('this is a toot')
|
2018-03-03 19:26:10 +00:00
|
|
|
await (uploadKittenImage(1)())
|
2021-02-16 00:45:41 +00:00
|
|
|
await sleep(500)
|
2018-08-27 02:54:59 +01:00
|
|
|
await t.expect(composeInput.value).eql('this is a toot')
|
2018-03-03 19:26:10 +00:00
|
|
|
.click(getNthDeleteMediaButton(1))
|
2018-08-27 02:54:59 +01:00
|
|
|
.expect(composeInput.value).eql('this is a toot')
|
2018-03-03 19:26:10 +00:00
|
|
|
.click(getNthDeleteMediaButton(1))
|
2018-08-27 02:54:59 +01:00
|
|
|
.expect(composeInput.value).eql('this is a toot')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('keeps media descriptions as media is removed', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(mediaButton.exists).ok()
|
|
|
|
await (uploadKittenImage(1)())
|
|
|
|
await t
|
|
|
|
.typeText(getNthMediaAltInput(1), 'kitten numero uno')
|
|
|
|
await (uploadKittenImage(2)())
|
|
|
|
await t
|
|
|
|
.typeText(getNthMediaAltInput(2), 'kitten numero dos')
|
|
|
|
.expect(getNthMediaAltInput(1).value).eql('kitten numero uno')
|
|
|
|
.expect(getNthMediaAltInput(2).value).eql('kitten numero dos')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-08-27 02:54:59 +01:00
|
|
|
.click(getNthDeleteMediaButton(1))
|
|
|
|
.expect(getNthMediaAltInput(1).value).eql('kitten numero dos')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-08-27 02:54:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
test('keeps media in local storage', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(mediaButton.exists).ok()
|
|
|
|
await (uploadKittenImage(1)())
|
|
|
|
await t
|
|
|
|
.typeText(getNthMediaAltInput(1), 'kitten numero uno')
|
|
|
|
await (uploadKittenImage(2)())
|
|
|
|
await t
|
|
|
|
.typeText(getNthMediaAltInput(2), 'kitten numero dos')
|
|
|
|
await t
|
|
|
|
.typeText(composeInput, 'hello hello')
|
|
|
|
.expect(composeInput.value).eql('hello hello')
|
|
|
|
.expect(getNthMediaAltInput(1).value).eql('kitten numero uno')
|
|
|
|
.expect(getNthMediaAltInput(2).value).eql('kitten numero dos')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-08-27 02:54:59 +01:00
|
|
|
await sleep(1)
|
|
|
|
await t
|
|
|
|
.click(settingsNavButton)
|
|
|
|
.click(homeNavButton)
|
|
|
|
.expect(composeInput.value).eql('hello hello')
|
|
|
|
.expect(getNthMediaAltInput(1).value).eql('kitten numero uno')
|
|
|
|
.expect(getNthMediaAltInput(2).value).eql('kitten numero dos')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-08-27 02:54:59 +01:00
|
|
|
.navigateTo('/')
|
|
|
|
.expect(composeInput.value).eql('hello hello')
|
|
|
|
.expect(getNthMediaAltInput(1).value).eql('kitten numero uno')
|
|
|
|
.expect(getNthMediaAltInput(2).value).eql('kitten numero dos')
|
2019-07-07 08:14:19 +01:00
|
|
|
.expect(getNthMediaListItem(1).getAttribute('aria-label')).eql('kitten1.jpg')
|
|
|
|
.expect(getNthMediaListItem(2).getAttribute('aria-label')).eql('kitten2.jpg')
|
2018-03-03 05:55:04 +00:00
|
|
|
})
|
2019-09-17 08:19:59 +01:00
|
|
|
|
|
|
|
test('resets sensitive settings when deleting media', async t => {
|
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
|
|
|
.expect(mediaButton.exists).ok()
|
|
|
|
await (uploadKittenImage(1)())
|
|
|
|
await t
|
|
|
|
.click(composeMediaSensitiveCheckbox)
|
|
|
|
.expect(composeMediaSensitiveCheckbox.checked).ok()
|
|
|
|
await (uploadKittenImage(2)())
|
|
|
|
await t
|
|
|
|
.expect(composeMediaSensitiveCheckbox.checked).ok()
|
|
|
|
.click(getNthDeleteMediaButton(2))
|
|
|
|
.expect(getNthMedia(2).exists).notOk()
|
|
|
|
.expect(composeMediaSensitiveCheckbox.checked).ok()
|
|
|
|
.click(getNthDeleteMediaButton(1))
|
|
|
|
.expect(getNthMedia(1).exists).notOk()
|
|
|
|
await (uploadKittenImage(1)())
|
|
|
|
await t
|
|
|
|
.expect(composeMediaSensitiveCheckbox.checked).notOk()
|
|
|
|
.click(contentWarningButton)
|
|
|
|
.typeText(composeContentWarning, 'warn warn warn', { paste: true })
|
|
|
|
.expect(composeMediaSensitiveCheckbox.checked).ok()
|
|
|
|
.click(getNthDeleteMediaButton(1))
|
|
|
|
.expect(getNthMedia(1).exists).notOk()
|
|
|
|
await (uploadKittenImage(1)())
|
|
|
|
await t
|
|
|
|
.expect(composeMediaSensitiveCheckbox.checked).ok()
|
|
|
|
})
|