diff --git a/src/routes/_components/status/Status.html b/src/routes/_components/status/Status.html
index 123389e1..b7ecfdc4 100644
--- a/src/routes/_components/status/Status.html
+++ b/src/routes/_components/status/Status.html
@@ -21,7 +21,7 @@
{#if !showContent}
{/if}
- {#if content && (showContent || contentPreloaded)}
+ {#if content && (showContent || preloadHiddenContent)}
{/if}
{#if showCard }
@@ -30,8 +30,8 @@
{#if showMedia }
{/if}
- {#if showPoll}
-
+ {#if showPoll && (showContent || preloadHiddenContent)}
+
{/if}
{#if isStatusInOwnThread}
@@ -147,7 +147,7 @@
scheduleIdleTask(() => {
// Perf optimization: lazily load the StatusContent when the user is idle so that
// it's fast when they click the "show more" button
- this.set({ contentPreloaded: true })
+ this.set({ preloadHiddenContent: true })
})
}
},
@@ -171,7 +171,7 @@
data: () => ({
notification: undefined,
replyVisibility: undefined,
- contentPreloaded: false,
+ preloadHiddenContent: false,
enableShortcuts: null
}),
store: () => store,
diff --git a/src/routes/_components/status/StatusPoll.html b/src/routes/_components/status/StatusPoll.html
index 93258fd5..c0762b0f 100644
--- a/src/routes/_components/status/StatusPoll.html
+++ b/src/routes/_components/status/StatusPoll.html
@@ -65,6 +65,11 @@
border: 1px solid var(--main-border);
border-radius: 2px;
transition: opacity 0.2s linear;
+ display: none;
+ }
+
+ .poll.shown {
+ display: block;
}
.poll.status-in-own-thread {
@@ -309,12 +314,13 @@
),
formDisabled: ({ choices }) => !choices.length,
votesText: ({ votesCount }) => `${votesCount} ${votesCount === 1 ? 'vote' : 'votes'}`,
- computedClass: ({ isStatusInNotification, isStatusInOwnThread, loading }) => (
+ computedClass: ({ isStatusInNotification, isStatusInOwnThread, loading, shown }) => (
classname(
'poll',
isStatusInNotification && 'status-in-notification',
isStatusInOwnThread && 'status-in-own-thread',
- loading && 'poll-loading'
+ loading && 'poll-loading',
+ shown && 'shown'
)
)
},
diff --git a/tests/serverActions.js b/tests/serverActions.js
index 8f72d009..7bd6e4d5 100644
--- a/tests/serverActions.js
+++ b/tests/serverActions.js
@@ -71,8 +71,8 @@ export async function updateUserDisplayNameAs (username, displayName) {
return updateCredentials(instanceName, users[username].accessToken, { display_name: displayName })
}
-export async function createPollAs (username, content, options, multiple) {
- return postStatus(instanceName, users[username].accessToken, content, null, null, false, null, 'public', {
+export async function createPollAs (username, content, options, multiple, spoilerText) {
+ return postStatus(instanceName, users[username].accessToken, content, null, null, false, spoilerText, 'public', {
options,
multiple,
expires_in: POLL_EXPIRY_DEFAULT
diff --git a/tests/spec/126-polls.js b/tests/spec/126-polls.js
index 80287293..785ef767 100644
--- a/tests/spec/126-polls.js
+++ b/tests/spec/126-polls.js
@@ -7,7 +7,7 @@ import {
sleep,
getNthStatusPollRefreshButton,
getNthStatusPollVoteCount,
- getNthStatusRelativeDate, getUrl, goBack
+ getNthStatusRelativeDate, getUrl, goBack, getNthStatusSpoiler, getNthShowOrHideButton
} from '../utils'
import { loginAsFoobar } from '../roles'
import { createPollAs, voteOnPollAs } from '../serverActions'
@@ -105,3 +105,19 @@ test('Poll results refresh everywhere', async t => {
.expect(getNthStatusPollResult(1, 2).innerText).eql('0% no')
.expect(getNthStatusPollVoteCount(1).innerText).eql('1 vote')
})
+
+test('Polls with content warnings', async t => {
+ await createPollAs('admin', 'hidden poll!', ['oui', 'non'], false, 'this poll is hidden')
+ await sleep(2000)
+ await loginAsFoobar(t)
+ await t
+ .expect(getNthStatusSpoiler(1).innerText).contains('this poll is hidden')
+ .expect(getNthStatusPollForm(1).visible).notOk()
+ .expect(getNthStatusContent(1).visible).notOk()
+ .click(getNthShowOrHideButton(1))
+ .expect(getNthStatusPollForm(1).visible).ok()
+ .expect(getNthStatusContent(1).visible).ok()
+ .click(getNthShowOrHideButton(1))
+ .expect(getNthStatusPollForm(1).visible).notOk()
+ .expect(getNthStatusContent(1).visible).notOk()
+})