FEATURE: Multiple Draft Topics (#30790)

Allows users to save multiple topic and personal message drafts,
allowing more flexibility around content creation.

The "New Topic" button will now always start a fresh topic. Drafts can
be resumed from the drafts dropdown menu or using the "My Drafts" link
in the sidebar.

Since drafts require a unique `draft_key` and `user_id` combination, we
have updated the format of the draft key for both topics and personal
messages. They will now have a prefix like "new_topic_" or
"new_message_" with the timestamp of when the composer was first opened
appended.
This commit is contained in:
David Battersby
2025-01-29 10:23:26 +04:00
committed by GitHub
parent 29e48a6478
commit c64b5d6d7a
25 changed files with 132 additions and 275 deletions

View File

@ -81,41 +81,17 @@ describe "Composer - discard draft modal", type: :system do
it "destroys draft" do
visit "/new-topic"
composer.fill_title("this is a test topic")
composer.fill_content("a b c d e f g")
wait_for(timeout: 5) { Draft.count == 1 }
composer.close
expect(discard_draft_modal).to be_open
discard_draft_modal.click_save
discard_draft_modal.click_discard
wait_for(timeout: 5) { Draft.last != nil }
draft_key = Draft.last.draft_key
visit "/new-topic"
expect(dialog).to be_open
expect(page).to have_content(I18n.t("js.drafts.abandon.confirm"))
dialog.click_danger
wait_for(timeout: 5) { Draft.find_by(draft_key: draft_key) == nil }
end
it "resumes draft when using /new-message" do
visit "/new-message"
composer.fill_content("a b c d e f g")
composer.close
expect(discard_draft_modal).to be_open
discard_draft_modal.click_save
visit "/new-message"
expect(dialog).to be_open
expect(page).to have_content(I18n.t("js.drafts.abandon.confirm"))
dialog.click_button I18n.t("js.drafts.abandon.no_value")
expect(composer).to be_opened
expect(composer).to have_content("a b c d e f g")
wait_for(timeout: 5) { Draft.count == 0 }
end
end
end