Skip to content

A platform for community discussion. Free, open, simple.

FIX: relative picker was being reset on change (#26766)

Joffrey JAFFEUXa7f596da7a8a
diff --git a/app/assets/javascripts/discourse/app/components/time-shortcut-picker.hbs b/app/assets/javascripts/discourse/app/components/time-shortcut-picker.hbs
index c4ad735e694..4fcdd31f057 100644
--- a/app/assets/javascripts/discourse/app/components/time-shortcut-picker.hbs
+++ b/app/assets/javascripts/discourse/app/components/time-shortcut-picker.hbs
@@ -1,5 +1,5 @@
<TapTileGrid @activeTile={{this.selectedShortcut}} as |grid|>
- {{#each this.options as |option|}}
+ {{#each this.options key="id" as |option|}}
{{#unless option.hidden}}
<TapTile
@icon={{option.icon}}
diff --git a/spec/system/bookmarks_spec.rb b/spec/system/bookmarks_spec.rb
index 5c3405e6332..88be3472bd6 100644
--- a/spec/system/bookmarks_spec.rb
+++ b/spec/system/bookmarks_spec.rb
@@ -116,6 +116,19 @@ describe "Bookmarking posts and topics", type: :system do
expect(bookmark.reload.name).to eq("something important")
end
end
+
+ it "allows to set a relative time" do
+ bookmark = Fabricate(:bookmark, bookmarkable: topic, user: current_user)
+ topic_page.visit_topic(topic)
+ topic_page.click_topic_bookmark_button
+ bookmark_menu.click_menu_option("edit")
+ bookmark_modal.select_relative_time_duration(10)
+ bookmark_modal.select_relative_time_interval("days")
+
+ expect(bookmark_modal.custom_time_picker.value).to eq(
+ bookmark.reminder_at_in_zone(timezone).strftime("%H:%M"),
+ )
+ end
end
describe "editing existing bookmarks" do
diff --git a/spec/system/page_objects/modals/bookmark.rb b/spec/system/page_objects/modals/bookmark.rb
index 1b4f26a7262..627a6c8bed8 100644
--- a/spec/system/page_objects/modals/bookmark.rb
+++ b/spec/system/page_objects/modals/bookmark.rb
@@ -39,6 +39,16 @@ module PageObjects
has_css?(".bookmark-options-panel")
end
+ def select_relative_time_duration(duration)
+ find("#bookmark-relative-time-picker").fill_in(with: duration)
+ end
+
+ def select_relative_time_interval(interval)
+ select_kit = PageObjects::Components::SelectKit.new(".relative-time-intervals")
+ select_kit.expand
+ select_kit.select_row_by_value(interval)
+ end
+
def select_auto_delete_preference(preference)
select_kit = PageObjects::Components::SelectKit.new("#bookmark-auto-delete-preference")
select_kit.expand