From 0365e44a3352e0f9b2bf0d45baf1dddd5a5d1d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= Date: Tue, 24 Jun 2025 16:21:40 -0300 Subject: [PATCH] FIx failing tests --- .../solved-accept-answer-button.gjs | 4 +- .../components/solved-accepted-answer.gjs | 46 +++++++++++-------- .../initializers/extend-for-solved-button.gjs | 4 +- assets/stylesheets/solutions.scss | 4 -- spec/system/solved_spec.rb | 19 ++++++++ .../discourse-solved-post-menu-test.js | 6 ++- .../acceptance/discourse-solved-test.js | 5 +- .../helpers/discourse-solved-helpers.js | 3 +- 8 files changed, 59 insertions(+), 32 deletions(-) diff --git a/assets/javascripts/discourse/components/solved-accept-answer-button.gjs b/assets/javascripts/discourse/components/solved-accept-answer-button.gjs index c205e4c..7a107be 100644 --- a/assets/javascripts/discourse/components/solved-accept-answer-button.gjs +++ b/assets/javascripts/discourse/components/solved-accept-answer-button.gjs @@ -21,12 +21,12 @@ export default class SolvedAcceptAnswerButton extends Component { } @action - acceptAnswer() { + async acceptAnswer() { const post = this.args.post; this.saving = true; try { - acceptPost(post, this.currentUser); + await acceptPost(post, this.currentUser); } finally { this.saving = false; } diff --git a/assets/javascripts/discourse/components/solved-accepted-answer.gjs b/assets/javascripts/discourse/components/solved-accepted-answer.gjs index 73edaa6..4903b1c 100644 --- a/assets/javascripts/discourse/components/solved-accepted-answer.gjs +++ b/assets/javascripts/discourse/components/solved-accepted-answer.gjs @@ -2,6 +2,7 @@ import Component from "@glimmer/component"; import { service } from "@ember/service"; import { htmlSafe } from "@ember/template"; import PostQuotedContent from "discourse/components/post/quoted-content"; +import concatClass from "discourse/helpers/concat-class"; import { iconHTML } from "discourse/lib/icon-library"; import { formatUsername } from "discourse/lib/utilities"; import { i18n } from "discourse-i18n"; @@ -84,26 +85,31 @@ export default class SolvedAcceptedAnswer extends Component { } } diff --git a/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs b/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs index c94c2c6..840a624 100644 --- a/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs +++ b/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs @@ -63,7 +63,9 @@ function customizePost(api) { "post-content-cooked-html", class extends Component { static shouldRender(args) { - return args.post.post_number === 1 && args.post.topic.accepted_answer; + return ( + args.post?.post_number === 1 && args.post?.topic?.accepted_answer + ); }