FIX: hides chat icon in topic title, when topic is closed (#514)

FIX: hides chat icon in topic title, when topic is closed (#514)

diff --git a/assets/javascripts/discourse/widgets/topic-title-chat-link.js b/assets/javascripts/discourse/widgets/topic-title-chat-link.js
index 5866893..b6d7d7d 100644
--- a/assets/javascripts/discourse/widgets/topic-title-chat-link.js
+++ b/assets/javascripts/discourse/widgets/topic-title-chat-link.js
@@ -5,7 +5,11 @@ export default createWidget("topic-title-chat-link", {
   tagName: "span.topic-title-chat-link",
   title: "chat.open",
 
-  html() {
+  html(attrs) {
+    if (attrs.closed) {
+      return;
+    }
+
     return iconNode("far-comments");
   },
 
diff --git a/test/javascripts/widgets/topic-title-chat-link-test.js b/test/javascripts/widgets/topic-title-chat-link-test.js
new file mode 100644
index 0000000..2640773
--- /dev/null
+++ b/test/javascripts/widgets/topic-title-chat-link-test.js
@@ -0,0 +1,32 @@
+import componentTest, {
+  setupRenderingTest,
+} from "discourse/tests/helpers/component-test";
+import { discourseModule, exists } from "discourse/tests/helpers/qunit-helpers";
+import hbs from "htmlbars-inline-precompile";
+
+discourseModule(
+  "Discourse Chat | Widget | topic-title-chat-link",
+  function (hooks) {
+    setupRenderingTest(hooks);
+
+    componentTest("topic is closed", {
+      template: hbs`{{mount-widget widget="topic-title-chat-link" args=args}}`,
+      beforeEach() {
+        this.set("args", { closed: true });
+      },
+      test(assert) {
+        assert.notOk(exists(".d-icon-far-comments"));
+      },
+    });
+
+    componentTest("topic is opened", {
+      template: hbs`{{mount-widget widget="topic-title-chat-link" args=args}}`,
+      beforeEach() {
+        this.set("args", { closed: false });
+      },
+      test(assert) {
+        assert.ok(exists(".d-icon-far-comments"));
+      },
+    });
+  }
+);

GitHub sha: 0cc18d55b2c6505b5b0c7fe3788615cd9767d185

This commit appears in #514 which was approved by pmusaraj. It was merged by jjaffeux.