Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add tests for about page extra group ordering (#32959)

Ted Johansson2faa467b29a0
diff --git a/spec/system/about_page_spec.rb b/spec/system/about_page_spec.rb
index 0d33a15c544..7891ca67ac7 100644
--- a/spec/system/about_page_spec.rb
+++ b/spec/system/about_page_spec.rb
@@ -375,25 +375,61 @@ describe "About page", type: :system do
end
describe "extra groups" do
- let!(:extra_group) { Fabricate(:group, name: "illuminati") }
+ let!(:extra_groups) do
+ [
+ Fabricate(:group, name: "bananas", created_at: 1.day.ago),
+ Fabricate(:group, name: "apples", created_at: 3.days.ago),
+ Fabricate(:group, name: "oranges", created_at: 2.days.ago),
+ ]
+ end
+ let(:order) { "alphabetically" }
before do
SiteSetting.about_banner_image = nil
SiteSetting.show_additional_about_groups = true
SiteSetting.about_page_extra_groups = extra_groups_setting
+ SiteSetting.about_page_extra_groups_order = order
- extra_group.users << Fabricate(:user)
+ extra_groups.each { |extra_group| extra_group.users << Fabricate(:user) }
end
context "when extra groups are configured" do
- let(:extra_groups_setting) { extra_group.id.to_s }
+ let(:extra_groups_setting) { extra_groups.map(&:id).join("|") }
- it "shows the extra groups" do
- sign_in(admin)
+ context "when groups are set to order alphabetically" do
+ let(:order) { "alphabetically" }
- about_page.visit
+ it "shows the extra groups in alphabetical order" do
+ sign_in(admin)
+
+ about_page.visit
+
+ expect(about_page).to have_css(".about__apples + .about__bananas + .about__oranges")
+ end
+ end
+
+ context "when groups are set to order by creation" do
+ let(:order) { "order of creation" }
+
+ it "shows the extra groups in order of creation" do
+ sign_in(admin)
- expect(about_page).to have_group_with_name("Illuminati")
+ about_page.visit
+
+ expect(about_page).to have_css(".about__bananas + .about__apples + .about__oranges")
+ end
+ end
+
+ context "when groups are set to order by setting selection" do
+ let(:order) { "order of theme setting" }
+
+ it "shows the extra groups in order of selection" do
+ sign_in(admin)
+
+ about_page.visit
+
+ expect(about_page).to have_css(".about__bananas + .about__apples + .about__oranges")
+ end
end
end