diff --git a/app/assets/javascripts/discourse/app/components/tag-info.js b/app/assets/javascripts/discourse/app/components/tag-info.js index 92caa939d37..a7fe447c34a 100644 --- a/app/assets/javascripts/discourse/app/components/tag-info.js +++ b/app/assets/javascripts/discourse/app/components/tag-info.js @@ -59,6 +59,12 @@ export default Component.extend({ this.loadTagInfo(); }, + didUpdateAttrs() { + this._super(...arguments); + this.set("tagInfo", null); + this.loadTagInfo(); + }, + loadTagInfo() { if (this.loading) { return; diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js index bac61702bfd..cb78d15ebba 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js @@ -388,6 +388,23 @@ acceptance("Tag info", function (needs) { }); }); + server.get("/tag/happy-monkey2/info", () => { + return helper.response({ + __rest_serializer: "1", + tag_info: { + id: 13, + name: "happy-monkey2", + description: "happy monkey description", + topic_count: 1, + staff: false, + synonyms: [], + tag_group_names: [], + category_ids: [], + }, + categories: [], + }); + }); + server.delete("/tag/planters/synonyms/containers", () => helper.response({ success: true }) ); diff --git a/spec/system/page_objects/pages/tag.rb b/spec/system/page_objects/pages/tag.rb index 101a8d42e2a..bee70f6b182 100644 --- a/spec/system/page_objects/pages/tag.rb +++ b/spec/system/page_objects/pages/tag.rb @@ -45,6 +45,14 @@ module PageObjects def tag_box(tag) find(".tag-box div[data-tag-name='#{tag}']") end + + def tag_name_within_tag_info + find(".tag-info .tag-name-wrapper .discourse-tag").text + end + + def tags_dropdown + PageObjects::Components::SelectKit.new(".select-kit.tag-drop") + end end end end diff --git a/spec/system/tag_view_spec.rb b/spec/system/tag_view_spec.rb new file mode 100644 index 00000000000..ef64a35518d --- /dev/null +++ b/spec/system/tag_view_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +describe "Tag view", type: :system do + fab!(:tag_1) { Fabricate(:tag, name: "design") } + fab!(:tag_2) { Fabricate(:tag, name: "art") } + fab!(:topic) { Fabricate(:topic, tags: [tag_2]) } + fab!(:current_user) { Fabricate(:admin) } + + let(:tags_page) { PageObjects::Pages::Tag.new } + let(:topic_list) { PageObjects::Components::TopicList.new } + + before { sign_in(current_user) } + + describe "the tag info section" do + context "when navigating to another tag" do + it "shows the details of the new tag" do + tags_page.visit_tag(tag_1) + + tags_page.tag_info_btn.click + expect(tags_page.tag_name_within_tag_info).to eq(tag_1.name) + + tags_page.tags_dropdown.expand + tags_page.tags_dropdown.search(tag_2.name) + tags_page.tags_dropdown.select_row_by_value(tag_2.name) + + expect(topic_list).to have_topic(topic) + expect(tags_page.tag_name_within_tag_info).to eq(tag_2.name) + end + end + end +end