Skip to content

Commit f0bb6a2

Browse files
committed
fix specs?
1 parent b370be3 commit f0bb6a2

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

app/assets/javascripts/discourse/app/components/time-shortcut-picker.gjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ export default class TimeShortcutPicker extends Component {
253253
this.keyValueStore.lastCustomDate = this.customDate;
254254
}
255255
} else {
256-
dateTime = this.options.findBy("id", type).timeFn();
256+
const option = this.options.findBy("id", type);
257+
dateTime = option?.timeFn?.();
257258
}
258259

259260
this.setProperties({
@@ -262,7 +263,15 @@ export default class TimeShortcutPicker extends Component {
262263
});
263264

264265
if (this.onTimeSelected) {
265-
this.onTimeSelected(type, dateTime);
266+
// Pass the type and either a function that returns the datetime, or a datetime value
267+
if (type === TIME_SHORTCUT_TYPES.CUSTOM) {
268+
// For custom datetimes, create a function that returns the datetime
269+
this.onTimeSelected(type, () => dateTime);
270+
} else {
271+
// For preset options, pass the timeFn function directly
272+
const option = this.options.findBy("id", type);
273+
this.onTimeSelected(type, option?.timeFn || (() => dateTime));
274+
}
266275
}
267276
}
268277

spec/system/bookmarks_spec.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ def open_bookmark_menu(post, expand_actions: true)
5757
visit_topic_and_open_bookmark_menu(post)
5858
bookmark_menu.click_menu_option("custom")
5959
bookmark_modal.select_preset_reminder(:tomorrow)
60-
expect(topic_page).to have_post_bookmarked(post, with_reminder: true)
60+
61+
# Wait for the bookmark to be created with a reminder in the database
6162
try_until_success(frequency: 0.5) do
62-
expect(Bookmark.find_by(bookmarkable: post, user: current_user).reminder_at).not_to be_blank
63+
bookmark = Bookmark.find_by(bookmarkable: post, user: current_user)
64+
expect(bookmark&.reminder_at).not_to be_blank
6365
end
66+
67+
# Reload the page to ensure we see the updated UI state
68+
topic_page.visit_topic(topic)
69+
70+
# The bookmark should have a reminder icon
71+
expect(topic_page).to have_post_bookmarked(post, with_reminder: true)
6472
end
6573

6674
it "allows choosing a different auto_delete_preference to the user preference and remembers it when reopening the modal" do

spec/system/page_objects/modals/bookmark.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def name
1313

1414
def select_preset_reminder(identifier)
1515
find("#tap_tile_#{identifier}").click
16-
closed?
16+
# Wait for modal to fully close
17+
has_no_css?(".bookmark-reminder-modal", wait: 5) # Use standard Capybara wait
1718
end
1819

1920
def has_active_preset?(identifier)

0 commit comments

Comments
 (0)