A platform for community discussion. Free, open, simple.
FIX: render 0 in post-voting count when upvotes and downvotes cancel out (#39296)
Régis HANOLedd69ab0dd0c
diff --git a/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-vote-controls.gjs b/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-vote-controls.gjsindex f45a5ba5e37..9b2fec96714 100644--- a/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-vote-controls.gjs+++ b/plugins/discourse-post-voting/assets/javascripts/discourse/components/post-voting-vote-controls.gjs@@ -1,5 +1,6 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";+import { concat } from "@ember/helper";import { action } from "@ember/object";import { service } from "@ember/service";import DButton from "discourse/components/d-button";@@ -120,7 +121,7 @@ export default class PostVotingVoteControls extends Component {<DButtonclass="post-voting-post-toggle-voters btn-flat"@action={{this.toggleWhoVoted}}- @translatedLabel={{@post.post_voting_vote_count}}+ @translatedLabel={{concat @post.post_voting_vote_count}}/>{{#if this.showWhoVoted}}<PostVotingWhoVotedListdiff --git a/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js b/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.jsindex 7165f7c4afb..80796d91a90 100644--- a/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js+++ b/plugins/discourse-post-voting/test/javascripts/acceptance/post-voting-test.js@@ -737,6 +737,25 @@ acceptance(`Discourse Post Voting - logged in user`, function (needs) {.hasText("0", "does not render a button to show post voters");});+ test("receiving user post voted message where upvotes and downvotes cancel out", async function (assert) {+ await visit("/t/280");++ publishToMessageBus("/topic/280", {+ type: "post_voting_post_voted",+ id: topicResponse.post_stream.posts[1].id,+ post_voting_vote_count: 0,+ post_voting_has_votes: true,+ post_voting_user_voted_id: 123456,+ post_voting_user_voted_direction: "up",+ });++ await settled();++ assert+ .dom("#post_2 .post-voting-post-toggle-voters")+ .hasText("0", "displays 0 when upvotes and downvotes cancel out");+ });+test("receiving user post voted message where current user is not the one that voted", async function (assert) {await visit("/t/280");