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 5fc813c0f69..efa16be7a73 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 8fece74151a..7e45eda7184 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");