fix modifying replies to statuses

This commit is contained in:
Nolan Lawson 2018-04-08 13:42:31 -07:00
parent e7b1b2ba31
commit ee8cda5d66
4 changed files with 81 additions and 11 deletions

View File

@ -70,14 +70,14 @@ export async function clickSelectedAutosuggestionUsername (realm) {
export function setReplySpoiler (realm, spoiler) {
let contentWarning = store.getComposeData(realm, 'contentWarning')
let contentWarningShown = store.getComposeData(realm, 'contentWarningShown')
if (typeof contentWarningShown === 'undefined' && !contentWarning) {
// user hasn't interacted with the CW yet
if (typeof contentWarningShown !== 'undefined' || contentWarning) {
return // user has already interacted with the CW
}
store.setComposeData(realm, {
contentWarning: spoiler,
contentWarningShown: true
})
}
}
const PRIVACY_LEVEL = {
'direct': 1,
@ -89,6 +89,10 @@ const PRIVACY_LEVEL = {
export function setReplyVisibility (realm, replyVisibility) {
// return the most private between the user's preferred default privacy
// and the privacy of the status they're replying to
let postPrivacy = store.getComposeData(realm, 'postPrivacy')
if (typeof postPrivacy !== 'undefined') {
return // user has already set the postPrivacy
}
let verifyCredentials = store.get('currentVerifyCredentials')
let defaultVisibility = verifyCredentials.source.privacy
let visibility = PRIVACY_LEVEL[replyVisibility] < PRIVACY_LEVEL[defaultVisibility]

View File

@ -1,4 +1,4 @@
import { postPrivacyButton } from '../utils'
import { getNthPostPrivacyOptionInDialog, postPrivacyButton } from '../utils'
import { foobarRole } from '../roles'
fixture`014-compose-post-privacy.js`
@ -8,9 +8,9 @@ test('Changes post privacy', async t => {
await t.useRole(foobarRole)
.expect(postPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
.click(postPrivacyButton)
.click('.generic-dialog-list li:nth-child(2) button')
.click(getNthPostPrivacyOptionInDialog(2))
.expect(postPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Unlisted)')
.click(postPrivacyButton)
.click('.generic-dialog-list li:nth-child(1) button')
.click(getNthPostPrivacyOptionInDialog(1))
.expect(postPrivacyButton.getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
})

View File

@ -1,7 +1,9 @@
import {
composeInput,
getNthComposeReplyInput, getNthPostPrivacyButton, getNthReplyButton,
getNthStatus, getUrl, homeNavButton, notificationsNavButton
getNthComposeReplyInput, getNthPostPrivacyButton, getNthPostPrivacyOptionInDialog, getNthReplyButton,
getNthReplyContentWarningButton,
getNthReplyContentWarningInput, getNthReplyPostPrivacyButton,
getNthStatus, getUrl, homeNavButton, notificationsNavButton, scrollToStatus
} from '../utils'
import { foobarRole } from '../roles'
@ -58,3 +60,51 @@ test('replies have same privacy as replied-to status by default', async t => {
.expect(getNthPostPrivacyButton(7).getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
.click(getNthReplyButton(7))
})
test('replies have same CW as replied-to status', async t => {
await t.useRole(foobarRole)
await scrollToStatus(t, 7)
await t.click(getNthReplyButton(7))
.expect(getNthReplyContentWarningInput(7).value).eql('kitten CW')
.click(getNthStatus(7))
.click(getNthReplyButton(0))
.expect(getNthReplyContentWarningInput(0).value).eql('kitten CW')
})
test('replies save deletions of CW', async t => {
await t.useRole(foobarRole)
await scrollToStatus(t, 7)
await t.click(getNthReplyButton(7))
.expect(getNthReplyContentWarningInput(7).value).eql('kitten CW')
.click(getNthReplyContentWarningButton(7))
.expect(getNthReplyContentWarningInput(7).exists).notOk()
.click(getNthStatus(7))
.click(getNthReplyButton(0))
.expect(getNthReplyContentWarningInput(0).exists).notOk()
})
test('replies save changes to CW', async t => {
await t.useRole(foobarRole)
await scrollToStatus(t, 7)
await t.click(getNthReplyButton(7))
.expect(getNthReplyContentWarningInput(7).value).eql('kitten CW')
.typeText(getNthReplyContentWarningInput(7), ' yolo', {paste: true})
.expect(getNthReplyContentWarningInput(7).value).eql('kitten CW yolo')
.click(getNthStatus(7))
.click(getNthReplyButton(0))
.expect(getNthReplyContentWarningInput(0).value).eql('kitten CW yolo')
})
test('replies save changes to post privacy', async t => {
await t.useRole(foobarRole)
.hover(getNthStatus(0))
.hover(getNthStatus(1))
.click(getNthReplyButton(1))
.expect(getNthPostPrivacyButton(1).getAttribute('aria-label')).eql('Adjust privacy (currently Unlisted)')
.click(getNthReplyPostPrivacyButton(1))
.click(getNthPostPrivacyOptionInDialog(1))
.expect(getNthPostPrivacyButton(1).getAttribute('aria-label')).eql('Adjust privacy (currently Public)')
.click(getNthStatus(1))
.click(getNthReplyButton(0))
.expect(getNthPostPrivacyButton(0).getAttribute('aria-label')).eql('Adjust privacy (currently Unlisted)')
})

View File

@ -140,6 +140,22 @@ export function getNthReplyButton (n) {
return getNthStatus(n).find('.status-toolbar button:nth-child(1)')
}
export function getNthReplyContentWarningInput (n) {
return getNthStatus(n).find('.content-warning-input')
}
export function getNthReplyContentWarningButton (n) {
return getNthStatus(n).find('.compose-box-toolbar button:nth-child(4)')
}
export function getNthReplyPostPrivacyButton (n) {
return getNthStatus(n).find('.compose-box-toolbar button:nth-child(3)')
}
export function getNthPostPrivacyOptionInDialog (n) {
return $(`.generic-dialog-list li:nth-child(${n}) button`)
}
export function getNthFavoriteButton (n) {
return getNthStatus(n).find('.status-toolbar button:nth-child(3)')
}