diff --git a/app/models/upvs/message_template.rb b/app/models/upvs/message_template.rb
index d9a884e5f..6abeaef4a 100644
--- a/app/models/upvs/message_template.rb
+++ b/app/models/upvs/message_template.rb
@@ -106,6 +106,10 @@ def build_message_from_template(message)
filled_content.gsub!(template_item[:placeholder], message.metadata['data'][template_item[:name]].to_s)
end
+ message.update(
+ html_visualization: message.metadata["data"].map { _1.join(": ") }.join(", ")
+ ) if message.metadata["data"]
+
if message.form_object.message_object_datum
message.form_object.message_object_datum.update(
blob: filled_content
diff --git a/test/fixtures/message_object_data.yml b/test/fixtures/message_object_data.yml
index 3df899c3f..b01660fca 100644
--- a/test/fixtures/message_object_data.yml
+++ b/test/fixtures/message_object_data.yml
@@ -12,6 +12,10 @@ draft_two:
message_object: ssd_main_general_draft_two_form
blob: predmettext
+empty_draft:
+ message_object: ssd_main_empty_draft_form
+ blob:
+
fs_one:
message_object: ssd_main_fs_one_form
blob: Daňový úrad Bratislava Ševčenkova 32, 850 00 Bratislava 000000000/2022 Mgr. X Y 02/00000000 x.y@FINANCNASPRAVA.SK Bratislava 2022-04-19 Rozhodnutie
diff --git a/test/fixtures/message_objects.yml b/test/fixtures/message_objects.yml
index cbf70b78b..4358c11f6 100644
--- a/test/fixtures/message_objects.yml
+++ b/test/fixtures/message_objects.yml
@@ -108,3 +108,9 @@ ssd_main_draft_to_be_signed4_draft_form:
name: MyString
mimetype: MyString
object_type: FORM
+
+ssd_main_empty_draft_form:
+ message: ssd_main_empty_draft
+ name: MyString
+ mimetype: MyString
+ object_type: FORM
diff --git a/test/fixtures/message_threads.yml b/test/fixtures/message_threads.yml
index a4ca141fb..4cc60e30a 100644
--- a/test/fixtures/message_threads.yml
+++ b/test/fixtures/message_threads.yml
@@ -63,6 +63,13 @@ ssd_main_draft_to_be_signed4:
delivered_at: 2023-05-18 18:15:22
last_message_delivered_at: 2023-05-18 18:16:22
+ssd_main_empty_draft:
+ box: ssd_main
+ title: Empty Draft
+ original_title: MyString
+ delivered_at: 2023-05-18 16:05:00
+ last_message_delivered_at: 2023-05-18 16:05:00
+
solver_main_general_agenda:
box: solver_main
title: General agenda Solver
diff --git a/test/fixtures/message_threads_tags.yml b/test/fixtures/message_threads_tags.yml
index 9fbd1ee40..2110dbcc1 100644
--- a/test/fixtures/message_threads_tags.yml
+++ b/test/fixtures/message_threads_tags.yml
@@ -127,3 +127,7 @@ ssd_main_draft_to_be_signed4_ssd_signature_requested:
ssd_main_draft_to_be_signed4_ssd_signers_signature_requested:
message_thread: ssd_main_draft_to_be_signed4
tag: ssd_signers_signature_requested
+
+ssd_main_empty_draft_ssd_basic_user_drafts:
+ message_thread: ssd_main_empty_draft
+ tag: ssd_basic_user_drafts
diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml
index b5f2b3df5..1c2dce92d 100644
--- a/test/fixtures/messages.yml
+++ b/test/fixtures/messages.yml
@@ -263,6 +263,20 @@ ssd_main_draft_to_be_signed4_draft:
status: created
author: basic
+ssd_main_empty_draft:
+ type: Upvs::MessageDraft
+ uuid: <%= SecureRandom.uuid %>
+ title: Všeobecná agenda
+ delivered_at: 2023-05-18 16:05:00
+ thread: ssd_main_empty_draft
+ replyable: false
+ metadata:
+ status: created
+ template_id: 2
+ recipient_uri: ico://sk/83369723
+ correlation_id: <%= SecureRandom.uuid %>
+ author: basic
+
solver_main_delivery_notification_one:
uuid: bbff2617-3430-44c6-b827-519059ff1e90
title: Authorized Delivery notification
diff --git a/test/fixtures/tag_groups.yml b/test/fixtures/tag_groups.yml
index 2b00667b4..856268e80 100644
--- a/test/fixtures/tag_groups.yml
+++ b/test/fixtures/tag_groups.yml
@@ -1,5 +1,9 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+drafts_basic_user:
+ tag: ssd_basic_user_drafts
+ group: ssd_basic_user
+
finance_basic_user:
tag: ssd_finance
group: ssd_basic_user
diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml
index 87330fdab..b8c4d4775 100644
--- a/test/fixtures/tags.yml
+++ b/test/fixtures/tags.yml
@@ -175,7 +175,7 @@ solver_everything:
visible: false
tenant: solver
-solver_basic_user_drafts:
+ssd_basic_user_drafts:
name: Drafts-Basic user
owner: basic
type: DraftTag
diff --git a/test/fixtures/upvs/message_templates.yml b/test/fixtures/upvs/message_templates.yml
index 45a846bda..dbea37d6b 100644
--- a/test/fixtures/upvs/message_templates.yml
+++ b/test/fixtures/upvs/message_templates.yml
@@ -14,6 +14,7 @@ message_reply:
type: Upvs::MessageTemplate
general_agenda:
+ id: 2
content:
{{ Predmet:text_field }}
{{ Text:text_area }}
diff --git a/test/system/message_drafts_test.rb b/test/system/message_drafts_test.rb
index f31c31120..c29b01a07 100644
--- a/test/system/message_drafts_test.rb
+++ b/test/system/message_drafts_test.rb
@@ -1,6 +1,59 @@
require "application_system_test_case"
class MessageDraftsTest < ApplicationSystemTestCase
+ setup do
+ Searchable::MessageThread.reindex_all
+
+ silence_warnings do
+ @old_value = MessageThreadCollection.const_get("PER_PAGE")
+ MessageThreadCollection.const_set("PER_PAGE", 1)
+ end
+
+ sign_in_as(:basic)
+ end
+
+ teardown do
+ silence_warnings do
+ MessageThreadCollection.const_set("PER_PAGE", @old_value)
+ end
+ end
+
test "user can create message draft as reply on replyable message" do
end
+
+ test "templated message draft content is searchable" do
+ message = messages(:ssd_main_empty_draft)
+ thread = message_threads(:ssd_main_empty_draft)
+
+ visit message_thread_path thread
+
+ within "#body_upvs_message_draft_#{message.id}_form" do
+ fill_in "message_draft_Text", with: "Pozdrav zo Slovensko.Digital! :)"
+ fill_in "message_draft_Predmet", with: "Pozdravovacia sprava"
+ end
+
+ assert_text "Zmeny boli uložené"
+
+ GoodJob.perform_inline
+
+ # Search the draft content keywords
+ visit message_threads_path
+
+ assert_no_selector "#next_page_area"
+
+ fill_in "search", with: "Slovensko.Digital"
+ find("#search").send_keys(:enter)
+
+ assert_no_selector "#next_page_area"
+
+ thread_general = message_threads(:ssd_main_general)
+ thread_issue = message_threads(:ssd_main_issue)
+
+ within_thread_in_listing(thread) do
+ assert_text "Slovensko.Digital"
+ end
+
+ refute_selector(thread_in_listing_selector(thread_general))
+ refute_selector(thread_in_listing_selector(thread_issue))
+ end
end