diff --git a/src/routes/_actions/deleteAndRedraft.js b/src/routes/_actions/deleteAndRedraft.js index 738e69e1..a66adc76 100644 --- a/src/routes/_actions/deleteAndRedraft.js +++ b/src/routes/_actions/deleteAndRedraft.js @@ -22,7 +22,8 @@ export async function deleteAndRedraft (status) { poll: status.poll && { multiple: !!status.poll.multiple, options: (status.poll.options || []).map(option => option.title) - } + }, + sensitive: !!status.sensitive }) const showComposeDialog = await dialogPromise showComposeDialog() diff --git a/tests/serverActions.js b/tests/serverActions.js index 18724c1d..8f72d009 100644 --- a/tests/serverActions.js +++ b/tests/serverActions.js @@ -36,10 +36,10 @@ export async function postWithSpoilerAndPrivacyAs (username, text, spoiler, priv 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) 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) { diff --git a/tests/spec/121-delete-and-redraft.js b/tests/spec/121-delete-and-redraft.js index 8d288399..167d0249 100644 --- a/tests/spec/121-delete-and-redraft.js +++ b/tests/spec/121-delete-and-redraft.js @@ -29,7 +29,7 @@ import { composePollMultipleChoiceInDialog, composePollExpiry, composePollExpiryOption, - composePollExpiryInDialog + composePollExpiryInDialog, composeModalMediaSensitiveCheckbox, getNthStatusSensitiveMediaButton, getNthStatusAndImage } from '../utils' import { postAs, postEmptyStatusWithMediaAs, postWithSpoilerAndPrivacyAs } from '../serverActions' 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')) .expect(modalDialog.hasAttribute('aria-hidden')).notOk() .expect(composeModalInput.value).eql('') + .expect(composeModalMediaSensitiveCheckbox.checked).notOk() .expect(composeModalPostPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)') .expect(getComposeModalNthMediaListItem(1).getAttribute('aria-label')).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(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() +}) diff --git a/tests/utils.js b/tests/utils.js index b4b744b6..02fef108 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -62,6 +62,7 @@ export const composeModalComposeButton = $('.modal-dialog .compose-box-button') export const composeModalContentWarningInput = $('.modal-dialog .content-warning-input') 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 composeModalMediaSensitiveCheckbox = $('.modal-dialog .compose-media-sensitive input') export const composePoll = $('.compose-poll') export const composePollMultipleChoice = $('.compose-poll input[type="checkbox"]')