From 690812f27cf79646fd6020bc659192ec5beddb1c Mon Sep 17 00:00:00 2001 From: tusooa Date: Tue, 18 Feb 2025 17:42:50 -0500 Subject: [PATCH] Fix draft saving and add tests --- changelog.d/draft-save.fix | 1 + changelog.d/post-more-actions-label.fix | 1 + .../post_status_form/post_status_form.js | 10 +- .../post_status_form/post_status_form.vue | 1 + src/i18n/en.json | 3 +- test/fixtures/mock_store.js | 52 ++++++ test/fixtures/setup_test.js | 132 ++++++++++++++ test/unit/specs/components/draft.spec.js | 166 ++++++++++++++++++ 8 files changed, 364 insertions(+), 2 deletions(-) create mode 100644 changelog.d/draft-save.fix create mode 100644 changelog.d/post-more-actions-label.fix create mode 100644 test/fixtures/mock_store.js create mode 100644 test/fixtures/setup_test.js create mode 100644 test/unit/specs/components/draft.spec.js diff --git a/changelog.d/draft-save.fix b/changelog.d/draft-save.fix new file mode 100644 index 000000000..7e3097e04 --- /dev/null +++ b/changelog.d/draft-save.fix @@ -0,0 +1 @@ +Fix draft saving when auto-save is off diff --git a/changelog.d/post-more-actions-label.fix b/changelog.d/post-more-actions-label.fix new file mode 100644 index 000000000..c3441d10a --- /dev/null +++ b/changelog.d/post-more-actions-label.fix @@ -0,0 +1 @@ +Add text label for more actions button in post status form diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index f9eb1bdcd..87c88d8f7 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -376,6 +376,14 @@ const PostStatusForm = { this.newStatus.hasPoll ) && this.saveable }, + hasEmptyDraft () { + return this.newStatus.id && !( + this.newStatus.status || + this.newStatus.spoilerText || + this.newStatus.files?.length || + this.newStatus.hasPoll + ) + }, ...mapGetters(['mergedConfig']), ...mapState(useInterfaceStore, { mobileLayout: store => store.mobileLayout @@ -784,7 +792,7 @@ const PostStatusForm = { this.$emit('draft-done') } }) - } else if (this.newStatus.id) { + } else if (this.hasEmptyDraft) { // There is a draft, but there is nothing in it, clear it return this.abandonDraft() .then(() => { diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 260a89cb7..303413b55 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -322,6 +322,7 @@ trigger="click" placement="bottom" :offset="{ y: 5 }" + :trigger-attrs="{ 'aria-label': $t('post_status.more_post_actions') }" >