2022-12-15 17:50:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-02-01 18:32:45 -05:00
|
|
|
describe "User preferences | Interface", type: :system do
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(:user)
|
2022-12-15 17:50:31 -05:00
|
|
|
let(:user_preferences_page) { PageObjects::Pages::UserPreferences.new }
|
2023-05-28 23:56:21 -04:00
|
|
|
let(:user_preferences_interface_page) { PageObjects::Pages::UserPreferencesInterface.new }
|
2022-12-15 17:50:31 -05:00
|
|
|
|
|
|
|
before { sign_in(user) }
|
|
|
|
|
|
|
|
describe "Bookmarks" do
|
|
|
|
it "changes the bookmark after notification preference" do
|
2023-05-29 04:48:59 -04:00
|
|
|
user_preferences_page.visit(user)
|
|
|
|
click_link(I18n.t("js.user.preferences_nav.interface"))
|
2023-05-29 03:03:49 -04:00
|
|
|
|
2023-05-29 04:48:59 -04:00
|
|
|
dropdown = PageObjects::Components::SelectKit.new("#bookmark-after-notification-mode")
|
2022-12-15 17:50:31 -05:00
|
|
|
|
|
|
|
# preselects the default user_option.bookmark_auto_delete_preference value of 3 (clear_reminder)
|
2023-05-29 04:48:59 -04:00
|
|
|
expect(dropdown).to have_selected_value(Bookmark.auto_delete_preferences[:clear_reminder])
|
|
|
|
|
|
|
|
dropdown.select_row_by_value(Bookmark.auto_delete_preferences[:when_reminder_sent])
|
|
|
|
click_button(I18n.t("js.save"))
|
|
|
|
|
|
|
|
# the preference page reloads after saving, so we need to poll the db
|
|
|
|
try_until_success(timeout: 20) do
|
|
|
|
expect(
|
|
|
|
UserOption.exists?(
|
|
|
|
user_id: user.id,
|
|
|
|
bookmark_auto_delete_preference: Bookmark.auto_delete_preferences[:when_reminder_sent],
|
|
|
|
),
|
|
|
|
).to be_truthy
|
|
|
|
end
|
2022-12-15 17:50:31 -05:00
|
|
|
end
|
|
|
|
end
|
2024-08-08 13:57:42 -04:00
|
|
|
|
|
|
|
describe "Default Home Page" do
|
|
|
|
context "when a user has picked a home page that is no longer available in top_menu" do
|
|
|
|
it "shows the selected homepage" do
|
|
|
|
SiteSetting.top_menu = "latest|hot"
|
|
|
|
|
|
|
|
user.user_option.update!(homepage_id: UserOption::HOMEPAGES.key("unread"))
|
|
|
|
user_preferences_page.visit(user)
|
|
|
|
click_link(I18n.t("js.user.preferences_nav.interface"))
|
|
|
|
|
|
|
|
dropdown = PageObjects::Components::SelectKit.new("#home-selector")
|
|
|
|
|
|
|
|
expect(dropdown).to have_selected_name("Unread")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows only the available home pages from top_menu" do
|
|
|
|
SiteSetting.top_menu = "latest|hot"
|
|
|
|
|
|
|
|
user_preferences_page.visit(user)
|
|
|
|
click_link(I18n.t("js.user.preferences_nav.interface"))
|
|
|
|
|
|
|
|
dropdown = PageObjects::Components::SelectKit.new("#home-selector")
|
|
|
|
dropdown.expand
|
|
|
|
expect(dropdown).to have_option_value(UserOption::HOMEPAGES.key("latest"))
|
|
|
|
expect(dropdown).to have_option_value(UserOption::HOMEPAGES.key("hot"))
|
|
|
|
expect(dropdown).to have_no_option_value(UserOption::HOMEPAGES.key("top"))
|
|
|
|
expect(dropdown).to have_no_option_value(UserOption::HOMEPAGES.key("new"))
|
|
|
|
end
|
|
|
|
end
|
2022-12-15 17:50:31 -05:00
|
|
|
end
|