DEV: Add tests for `categories` setting (#50)
This commit improves the test coverage for the client side logic surrounding the `categories` theme setting
This commit is contained in:
parent
41ddbb8c11
commit
77645890df
|
@ -6,7 +6,12 @@ RSpec.describe "Category Banners", type: :system do
|
|||
let!(:theme) { upload_theme_component }
|
||||
fab!(:category) { Fabricate(:category, description: "<p>this is some description</p>") }
|
||||
fab!(:category_subcategory) do
|
||||
Fabricate(:category, parent_category: category, description: "some description", uploaded_logo: Fabricate(:upload))
|
||||
Fabricate(
|
||||
:category,
|
||||
parent_category: category,
|
||||
description: "some description",
|
||||
uploaded_logo: Fabricate(:upload),
|
||||
)
|
||||
end
|
||||
let(:category_banner) { PageObjects::Components::CategoryBanner.new(category) }
|
||||
let(:subcategory_banner) { PageObjects::Components::CategoryBanner.new(category_subcategory) }
|
||||
|
@ -19,6 +24,47 @@ RSpec.describe "Category Banners", type: :system do
|
|||
expect(category_banner).to have_description("this is some description")
|
||||
end
|
||||
|
||||
context "when `categories` setting has been set" do
|
||||
it "displays category banner for category and its subcategory when target is set to `all`" do
|
||||
theme.update_setting(:categories, "#{category.name}:all")
|
||||
theme.save!
|
||||
|
||||
visit(category.url)
|
||||
|
||||
expect(category_banner).to be_visible
|
||||
|
||||
visit(category_subcategory.url)
|
||||
|
||||
expect(subcategory_banner).to be_visible
|
||||
end
|
||||
|
||||
it "displays category banner only for root category when target is set to `no_sub`" do
|
||||
theme.update_setting(:categories, "#{category.name}:no_sub")
|
||||
theme.save!
|
||||
|
||||
visit(category.url)
|
||||
|
||||
expect(category_banner).to be_visible
|
||||
|
||||
visit(category_subcategory.url)
|
||||
|
||||
expect(subcategory_banner).to be_not_visible
|
||||
end
|
||||
|
||||
it "displays category banner only for sub categories when target is set to `only_sub`" do
|
||||
theme.update_setting(:categories, "#{category.name}:only_sub")
|
||||
theme.save!
|
||||
|
||||
visit(category.url)
|
||||
|
||||
expect(category_banner).to be_not_visible
|
||||
|
||||
visit(category_subcategory.url)
|
||||
|
||||
expect(subcategory_banner).to be_visible
|
||||
end
|
||||
end
|
||||
|
||||
it "does not display the category description when `show_description` setting is false" do
|
||||
theme.update_setting(:show_description, false)
|
||||
theme.save!
|
||||
|
|
Loading…
Reference in New Issue