generated from discourse/discourse-theme-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "<p>this is some description</p>") } | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Empty file.