0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/plugins/discourse-topic-voting/spec/system/page_objects/pages/topic.rb
Régis Hanol a9d2e8272a
FIX: Show the voting notification prompt when vote limits are disabled (#41731)
When topic voting vote limits are disabled, the "Notify me about new
posts"
prompt shown after voting never appeared. That prompt is part of the
menu the
vote button opens, but the menu was only rendered when vote limits were
enabled — with limits off the button had no menu at all, so both the
notification prompt and the remove-vote action were unreachable.

The fix renders the menu for any signed-in user rather than gating it on
vote
limits. The remaining-votes rows stay tied to limits being enabled,
while
remove-vote and watch-topic show whenever the user has voted. Removing a
vote
with limits disabled now goes through the menu, matching the behavior
when
limits are enabled.

Reported at
https://meta.discourse.org/t/disabling-vote-limits-seems-to-break-notification-prompt-in-topic-voting/407512

The second commit is follow-up housekeeping on the plugin, kept separate
from
the fix: removing dead code and duplication in the vote components and
initializers, counting a user's votes with `COUNT` instead of loading
every
row on each current-user serialization, and deleting orphaned i18n keys
and a
route-map filename left over from the plugin's former name.

### Testing

- Added a system spec covering the notification prompt appearing after
voting
  with vote limits disabled.
- Existing topic-voting system and JS specs pass; the model spec still
covers
  the trust-level-0 lock via `reached_voting_limit?`.
2026-07-15 14:54:37 +02:00

56 lines
1.1 KiB
Ruby
Vendored

# frozen_string_literal: true
module TopicVotingTopic
include ::RSpec::Matchers
def vote_count
find(".title-voting .voting-wrapper__count-text")
end
def vote_popup
find(".see-votes")
end
def vote
find(".title-voting button.voting-wrapper__button").click
self
end
def remove_vote
vote
find("button.remove-vote").click
self
end
def click_my_votes
find(".see-votes").click
end
def has_no_remove_vote_button?
has_no_css?("button.remove-vote")
end
def has_voted?
has_css?(".title-voting button.voting-wrapper__button.btn-success")
end
def has_not_voted?
has_css?(".title-voting button.voting-wrapper__button.btn-default") &&
has_no_css?(".title-voting button.voting-wrapper__button.btn-success")
end
def click_watch_toggle
find(".topic-voting-menu__watch-toggle .btn").click
self
end
def has_watch_toggle_on?
has_css?(".topic-voting-menu__watch-toggle .d-icon-toggle-on")
end
def has_watch_toggle_off?
has_css?(".topic-voting-menu__watch-toggle .d-icon-toggle-off")
end
end
PageObjects::Pages::Topic.include(TopicVotingTopic)