DEV: uses select-kit component for interface spec (#21790)

This commit is contained in:
Joffrey JAFFEUX 2023-05-29 10:48:59 +02:00 committed by GitHub
parent ac0f5ca1b2
commit 9321299caa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 22 deletions

View File

@ -39,7 +39,7 @@ module PageObjects
end
def expand
collapsed_component.find(":not(.is-expanded) .select-kit-header").click
collapsed_component.find(":not(.is-expanded) .select-kit-header", visible: :all).click
expanded_component
end

View File

@ -9,32 +9,26 @@ describe "User preferences for Interface", type: :system, js: true do
describe "Bookmarks" do
it "changes the bookmark after notification preference" do
skip(<<~TEXT) if ENV["CI"]
This is currently failing on CI with the following:
user_preferences_page.visit(user)
click_link(I18n.t("js.user.preferences_nav.interface"))
```
Failure/Error: expect(page).to have_content(I18n.t("js.saved"))
expected `#<Capybara::Session>.has_content?("Saved!")` to be truthy, got false
```
TEXT
user_preferences_page.visit(user).click_interface_tab
dropdown = PageObjects::Components::SelectKit.new("#bookmark-after-notification-mode")
# preselects the default user_option.bookmark_auto_delete_preference value of 3 (clear_reminder)
expect(user_preferences_interface_page).to have_bookmark_after_notification_mode(
Bookmark.auto_delete_preferences[:clear_reminder],
)
expect(dropdown).to have_selected_value(Bookmark.auto_delete_preferences[:clear_reminder])
user_preferences_interface_page.select_bookmark_after_notification_mode(
Bookmark.auto_delete_preferences[:when_reminder_sent],
).save_changes
dropdown.select_row_by_value(Bookmark.auto_delete_preferences[:when_reminder_sent])
click_button(I18n.t("js.save"))
expect(
UserOption.exists?(
user_id: user.id,
bookmark_auto_delete_preference: Bookmark.auto_delete_preferences[:when_reminder_sent],
),
).to eq(true)
# 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
end
end
end