diff --git a/common/common.scss b/common/common.scss index 3c4fb52..73e330d 100644 --- a/common/common.scss +++ b/common/common.scss @@ -30,9 +30,16 @@ &__heading { &__name { + display: flex; + align-items: baseline; + .category-icon-widget-wrapper { display: inline-block; } + + .d-icon, .category-icon { + margin-right: 0.25rem; + } } } } diff --git a/javascripts/discourse/components/category-jumbotron.hbs b/javascripts/discourse/components/category-jumbotron.hbs index f54d8d0..f01099b 100644 --- a/javascripts/discourse/components/category-jumbotron.hbs +++ b/javascripts/discourse/components/category-jumbotron.hbs @@ -35,7 +35,7 @@ {{#if this.displayCategoryDescription}} -
+
{{html-safe this.category.description}}
diff --git a/spec/system/category_jumbotron_spec.rb b/spec/system/category_jumbotron_spec.rb new file mode 100644 index 0000000..21456c3 --- /dev/null +++ b/spec/system/category_jumbotron_spec.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative "page_objects/components/category_jumbotron" + +RSpec.describe "Category Jumbotron", type: :system do + let!(:theme) { upload_theme_component } + fab!(:category) { Fabricate(:category, description: "

this is some description

") } + fab!(:category_subcategory) do + Fabricate(:category, parent_category: category, description: "some description") + end + let(:category_jumbotron) { PageObjects::Components::Categoryjumbotron.new(category) } + let(:subcategory_jumbotron) { PageObjects::Components::Categoryjumbotron.new(category_subcategory) } + + it "displays category jumbotron correctly" do + visit(category.url) + + expect(category_jumbotron).to be_visible + expect(category_jumbotron).to have_title(category.name) + expect(category_jumbotron).to have_description("this is some description") + end + + it "should not display category jumbotron on subcategories when `max_level` setting is 0" do + theme.update_setting(:max_level, 0) + theme.save! + + visit(category_subcategory.url) + + expect(subcategory_jumbotron).to be_not_visible + end +end diff --git a/spec/system/page_objects/components/category_jumbotron.rb b/spec/system/page_objects/components/category_jumbotron.rb new file mode 100644 index 0000000..8bcff49 --- /dev/null +++ b/spec/system/page_objects/components/category_jumbotron.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module PageObjects + module Components + class CategoryJumbotron < PageObjects::Components::Base + def initialize(category) + @category = category + end + + def visible? + has_css?(category_banner_selector) + end + + def not_visible? + has_no_css?(category_banner_selector) + end + + def has_title?(title) + has_css?("#{category_banner_selector} .category-jumbotron__grid__content__heading__name", text: title) + end + + def has_description?(description) + has_css?( + "#{category_banner_selector} .category-jumbotron__grid__content__description .cooked", + text: description, + ) + end + + def has_no_description? + has_no_css?("#{category_banner_selector} .category-jumbotron__grid__content__description") + end + + private + + def category_banner_selector + ".category-jumbotron-#{@category.slug}" + end + end + end +end diff --git a/test/acceptance/.gitkeep b/test/acceptance/.gitkeep deleted file mode 100644 index e69de29..0000000