diff --git a/changelog.d/reply-quote-config.fix b/changelog.d/reply-quote-config.fix new file mode 100644 index 000000000..b6ac4e5e9 --- /dev/null +++ b/changelog.d/reply-quote-config.fix @@ -0,0 +1 @@ +Fix reply form crash when quote-reply settings are unavailable diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6dfe48925..b5feb8e11 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -381,7 +381,11 @@ const PostStatusForm = { }, }, defaultQuotable() { - if (!this.quotingAvailable || !this.isReply) { + if ( + !this.quotingAvailable || + !this.isReply || + !useMergedConfigStore().mergedConfig.quoteReply + ) { return false } diff --git a/src/components/status_action_buttons/status_action_buttons.js b/src/components/status_action_buttons/status_action_buttons.js index 6962cce1b..8bdd87277 100644 --- a/src/components/status_action_buttons/status_action_buttons.js +++ b/src/components/status_action_buttons/status_action_buttons.js @@ -16,7 +16,7 @@ library.add(faEllipsisH) const StatusActionButtons = { props: ['status', 'replying'], - emits: ['toggleReplying'], + emits: ['toggleReplying', 'onSuccess', 'onError'], data() { return { showPin: false, diff --git a/test/unit/specs/components/post_status_form.spec.js b/test/unit/specs/components/post_status_form.spec.js new file mode 100644 index 000000000..8f3d6d80f --- /dev/null +++ b/test/unit/specs/components/post_status_form.spec.js @@ -0,0 +1,61 @@ +import { createTestingPinia } from '@pinia/testing' +import { mount } from '@vue/test-utils' +import { setActivePinia } from 'pinia' + +import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' +import { mountOpts } from '../../../fixtures/setup_test' + +import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' + +const currentUser = { + id: 'current-user', + default_scope: 'public', + locked: false, +} + +const repliedUser = { + id: 'replied-user', + screen_name: 'replied', +} + +const repliedStatus = { + id: 'status-1', + visibility: 'public', + user: repliedUser, +} + +const replyMountOpts = () => + mountOpts({ + props: { + replyTo: repliedStatus.id, + repliedUser, + attentions: [], + copyMessageScope: repliedStatus.visibility, + disableDraft: true, + }, + afterStore(store) { + store.state.users.currentUser = currentUser + store.state.statuses.allStatusesObject = { + [repliedStatus.id]: repliedStatus, + } + }, + }) + +describe('PostStatusForm', () => { + beforeEach(() => { + setActivePinia(createTestingPinia()) + }) + + it('initializes a reply form when quoteReply is unset', () => { + useInstanceCapabilitiesStore().quotingAvailable = true + + const wrapper = mount(PostStatusForm, replyMountOpts()) + + expect(wrapper.vm.newStatus.type).to.equal('reply') + expect(wrapper.vm.newStatus.quote).to.eql({ + id: '', + url: '', + thread: false, + }) + }) +})