FIX: Allow any other tag to be a synonym (#13290)

FIX: Allow any other tag to be a synonym (#13290)

Tag-chooser component expects an array of blocked tags, but was passed a string instead. That made tag-chooser to not allow any tags that were a substring of the current one.

diff --git a/app/assets/javascripts/discourse/app/templates/components/tag-info.hbs b/app/assets/javascripts/discourse/app/templates/components/tag-info.hbs
index 5fc813c..efa16be 100644
--- a/app/assets/javascripts/discourse/app/templates/components/tag-info.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/tag-info.hbs
@@ -59,7 +59,7 @@
         {{tag-chooser
           id="add-synonyms"
           tags=newSynonyms
-          blockedTags=tagInfo.name
+          blockedTags=(array tagInfo.name)
           everyTag=true
           excludeSynonyms=true
           excludeHasSynonyms=true
diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
index 8fece74..7e45eda 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
@@ -254,13 +254,16 @@ acceptance("Tag info", function (needs) {
     tags_listed_by_group: true,
   });
   needs.pretender((server, helper) => {
-    server.get("/tag/planters/notifications", () => {
+    server.get("/tag/:tag_name/notifications", (request) => {
       return helper.response({
-        tag_notification: { id: "planters", notification_level: 1 },
+        tag_notification: {
+          id: request.params.tag_name,
+          notification_level: 1,
+        },
       });
     });
 
-    server.get("/tag/planters/l/latest.json", () => {
+    server.get("/tag/:tag_name/l/latest.json", (request) => {
       return helper.response({
         users: [],
         primary_groups: [],
@@ -273,7 +276,7 @@ acceptance("Tag info", function (needs) {
           tags: [
             {
               id: 1,
-              name: "planters",
+              name: request.params.tag_name,
               topic_count: 1,
             },
           ],
@@ -345,9 +348,35 @@ acceptance("Tag info", function (needs) {
       });
     });
 
+    server.get("/tag/happy-monkey/info", () => {
+      return helper.response({
+        __rest_serializer: "1",
+        tag_info: {
+          id: 13,
+          name: "happy-monkey",
+          topic_count: 1,
+          staff: false,
+          synonyms: [],
+          tag_group_names: [],
+          category_ids: [],
+        },
+        categories: [],
+      });
+    });
+
     server.delete("/tag/planters/synonyms/containers", () =>
       helper.response({ success: true })
     );
+
+    server.get("/tags/filter/search", () =>
+      helper.response({
+        results: [
+          { id: "monkey", text: "monkey", count: 1 },
+          { id: "not-monkey", text: "not-monkey", count: 1 },
+          { id: "happy-monkey", text: "happy-monkey", count: 1 },
+        ],
+      })
+    );
   });
 
   test("tag info can show synonyms", async function (assert) {
@@ -375,6 +404,25 @@ acceptance("Tag info", function (needs) {
     assert.ok(!exists("#delete-tag"), "can't delete tag");
   });
 
+  test("tag info hides only current tag in synonyms dropdown", async function (assert) {
+    updateCurrentUser({ moderator: false, admin: true });
+
+    await visit("/tag/happy-monkey");
+    assert.ok(queryAll("#show-tag-info").length === 1);
+
+    await click("#show-tag-info");
+    assert.ok(exists(".tag-info .tag-name"), "show tag");
+
+    await click("#edit-synonyms");
+    await click("#add-synonyms .filter-input");
+
+    assert.equal(find(".tag-chooser-row").length, 2);
+    assert.deepEqual(
+      Array.from(find(".tag-chooser-row")).map((x) => x.dataset["value"]),
+      ["monkey", "not-monkey"]
+    );
+  });
+
   test("can filter tags page by category", async function (assert) {
     await visit("/tag/planters");
 

GitHub sha: 46cd3550

This commit appears in #13290 which was approved by eviltrout. It was merged by nbianca.