fix: delete-and-redraft preserves sensitive status (#1496)

fixes #1494
This commit is contained in:
Nolan Lawson 2019-09-17 00:19:53 -07:00 committed by GitHub
parent 09167a18f2
commit 08992f836a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 4 deletions

View file

@ -22,7 +22,8 @@ export async function deleteAndRedraft (status) {
poll: status.poll && { poll: status.poll && {
multiple: !!status.poll.multiple, multiple: !!status.poll.multiple,
options: (status.poll.options || []).map(option => option.title) options: (status.poll.options || []).map(option => option.title)
} },
sensitive: !!status.sensitive
}) })
const showComposeDialog = await dialogPromise const showComposeDialog = await dialogPromise
showComposeDialog() showComposeDialog()

View file

@ -36,10 +36,10 @@ export async function postWithSpoilerAndPrivacyAs (username, text, spoiler, priv
null, null, true, spoiler, privacy) null, null, true, spoiler, privacy)
} }
export async function postEmptyStatusWithMediaAs (username, filename, alt) { export async function postEmptyStatusWithMediaAs (username, filename, alt, sensitive) {
const mediaResponse = await submitMedia(users[username].accessToken, filename, alt) const mediaResponse = await submitMedia(users[username].accessToken, filename, alt)
return postStatus(instanceName, users[username].accessToken, '', return postStatus(instanceName, users[username].accessToken, '',
null, [mediaResponse.id], false, null, 'public') null, [mediaResponse.id], !!sensitive, null, 'public')
} }
export async function postReplyAs (username, text, inReplyTo) { export async function postReplyAs (username, text, inReplyTo) {

View file

@ -29,7 +29,7 @@ import {
composePollMultipleChoiceInDialog, composePollMultipleChoiceInDialog,
composePollExpiry, composePollExpiry,
composePollExpiryOption, composePollExpiryOption,
composePollExpiryInDialog composePollExpiryInDialog, composeModalMediaSensitiveCheckbox, getNthStatusSensitiveMediaButton, getNthStatusAndImage
} from '../utils' } from '../utils'
import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions' import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions'
import { POLL_EXPIRY_DEFAULT } from '../../src/routes/_static/polls' import { POLL_EXPIRY_DEFAULT } from '../../src/routes/_static/polls'
@ -64,6 +64,7 @@ test('image with empty text delete and redraft', async t => {
.click(dialogOptionsOption.withText('Delete and redraft')) .click(dialogOptionsOption.withText('Delete and redraft'))
.expect(modalDialog.hasAttribute('aria-hidden')).notOk() .expect(modalDialog.hasAttribute('aria-hidden')).notOk()
.expect(composeModalInput.value).eql('') .expect(composeModalInput.value).eql('')
.expect(composeModalMediaSensitiveCheckbox.checked).notOk()
.expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)') .expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
.expect(getComposeModalNthMediaListItem(1).getAttribute('aria-label')).eql('what a kitteh') .expect(getComposeModalNthMediaListItem(1).getAttribute('aria-label')).eql('what a kitteh')
.expect(getComposeModalNthMediaAltInput(1).value).eql('what a kitteh') .expect(getComposeModalNthMediaAltInput(1).value).eql('what a kitteh')
@ -219,3 +220,16 @@ test('delete and redraft polls', async t => {
.expect(composePollExpiryInDialog.value).eql(POLL_EXPIRY_DEFAULT.toString()) .expect(composePollExpiryInDialog.value).eql(POLL_EXPIRY_DEFAULT.toString())
.expect(composePollMultipleChoiceInDialog.checked).eql(true) .expect(composePollMultipleChoiceInDialog.checked).eql(true)
}) })
test('delete and redraft sensitive', async t => {
await postEmptyStatusWithMediaAs('foobar', 'kitten2.jpg', 'what a sensitive kitteh', true)
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.click(getNthStatusSensitiveMediaButton(1))
.expect(getNthStatusAndImage(1, 1).getAttribute('alt')).eql('what a sensitive kitteh')
.click(getNthStatusOptionsButton(1))
.click(dialogOptionsOption.withText('Delete and redraft'))
.expect(modalDialog.hasAttribute('aria-hidden')).notOk()
.expect(composeModalMediaSensitiveCheckbox.checked).ok()
})

View file

@ -62,6 +62,7 @@ export const composeModalComposeButton = $('.modal-dialog .compose-box-button')
export const composeModalContentWarningInput = $('.modal-dialog .content-warning-input') export const composeModalContentWarningInput = $('.modal-dialog .content-warning-input')
export const composeModalEmojiButton = $('.modal-dialog .compose-box-toolbar button:nth-child(1)') export const composeModalEmojiButton = $('.modal-dialog .compose-box-toolbar button:nth-child(1)')
export const composeModalPostPrivacyButton = $('.modal-dialog .compose-box-toolbar button:nth-child(4)') export const composeModalPostPrivacyButton = $('.modal-dialog .compose-box-toolbar button:nth-child(4)')
export const composeModalMediaSensitiveCheckbox = $('.modal-dialog .compose-media-sensitive input')
export const composePoll = $('.compose-poll') export const composePoll = $('.compose-poll')
export const composePollMultipleChoice = $('.compose-poll input[type="checkbox"]') export const composePollMultipleChoice = $('.compose-poll input[type="checkbox"]')