discourse/spec/system/page_objects/components/topic_reply_choice_dialog.rb
Martin Brennan bef35e2cd4
FIX: Handle cancel action in topic reply choice dialog (#35534)
Steps to reproduce:

* Start drafting a reply to a topic
* Write some text.
* Navigate to a different topic while keeping the draft open
* Click reply on the composer and choose cancel in the modal asking
which topic you want to reply to.
* Write some more text.
* Copy the text you have written or memorize your input.
* Reload the page/ close the composer.
* Navigate back to the topic you replied to
* Open your draft.
* Everything written after clicking cancel is missing.

This was happening because we weren't doing anything on Cancel for
the topic reply choice dialog, and we were doing `disableDrafts` before
opening the dialog, so drafts never resumed.

The fix is to just save the current draft on cancel then turn on
draft saving again so the user can continue typing and delay the
question about "Which topic do you want to reply to?" until later.

c.f.
https://meta.discourse.org/t/draft-is-no-longer-automatically-saved-after-you-cancel-replying/386370

Also rename TopicLabelContent to TopicReplyChoiceDialog, it
is more specific and reflects what the component actually does.
2025-10-22 14:42:57 +10:00

35 lines
807 B
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class TopicReplyChoiceDialog < PageObjects::Components::Dialog
def has_reply_on_original_topic?(topic)
find("#{reply_on_original_selector}").has_content?(topic.title)
end
def reply_on_original_selector
".btn-reply-on-original"
end
def click_reply_on_original
find("#{reply_on_original_selector}").click
end
def has_reply_here_topic?(topic)
find("#{reply_here_selector}").has_content?(topic.title)
end
def reply_here_selector
".btn-reply-here"
end
def click_reply_here
find("#{reply_here_selector}").click
end
def click_cancel
find(".btn-reply-where__cancel").click
end
end
end
end