From b4f8ea6adea330b9bc2af00239de0bf92941fa07 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 2 Sep 2024 17:32:18 +0200 Subject: [PATCH] FIX: correctly pass updateGroupings to the modal (#28683) A previous refactor has moved this function in the controller instead of the route making it inaccessible to the modal. This commit is fixing this and also adding a spec. --- .../components/modal/edit-badge-groupings.hbs | 8 +++-- .../admin/addon/routes/admin-badges.js | 5 +++ .../admin/addon/routes/admin-badges/show.js | 7 +--- .../admin/addon/templates/admin-badges.hbs | 2 +- .../admin_badges_grouping_modal_spec.rb | 21 ++++++++++++ spec/system/page_objects/admin_badges.rb | 5 +++ .../page_objects/admin_badges_groupings.rb | 32 +++++++++++++++++++ 7 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 spec/system/admin_badges_grouping_modal_spec.rb create mode 100644 spec/system/page_objects/admin_badges_groupings.rb diff --git a/app/assets/javascripts/admin/addon/components/modal/edit-badge-groupings.hbs b/app/assets/javascripts/admin/addon/components/modal/edit-badge-groupings.hbs index 44b2d9a282b..72ef5c73a83 100644 --- a/app/assets/javascripts/admin/addon/components/modal/edit-badge-groupings.hbs +++ b/app/assets/javascripts/admin/addon/components/modal/edit-badge-groupings.hbs @@ -37,13 +37,17 @@ {{/each}} - + <:footer> diff --git a/spec/system/admin_badges_grouping_modal_spec.rb b/spec/system/admin_badges_grouping_modal_spec.rb new file mode 100644 index 00000000000..85b9a582f31 --- /dev/null +++ b/spec/system/admin_badges_grouping_modal_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +describe "Admin Badges Grouping Modal", type: :system do + before { SiteSetting.enable_badges = true } + + fab!(:current_user) { Fabricate(:admin) } + + let(:badges_page) { PageObjects::Pages::AdminBadges.new } + let(:badges_groupings_page) { PageObjects::Pages::AdminBadgesGroupings.new } + + before { sign_in(current_user) } + + context "when adding a new grouping" do + it "saves it" do + badges_page.visit_page(Badge::Autobiographer).edit_groupings + badges_groupings_page.add_grouping("a new grouping") + + try_until_success { BadgeGrouping.exists?(name: "a new grouping") } + end + end +end diff --git a/spec/system/page_objects/admin_badges.rb b/spec/system/page_objects/admin_badges.rb index 5848e8ac661..32bf9c942f0 100644 --- a/spec/system/page_objects/admin_badges.rb +++ b/spec/system/page_objects/admin_badges.rb @@ -56,6 +56,11 @@ module PageObjects self end + def edit_groupings + page.find(".edit-groupings-btn").click + self + end + def form @form ||= PageObjects::Components::FormKit.new("form") end diff --git a/spec/system/page_objects/admin_badges_groupings.rb b/spec/system/page_objects/admin_badges_groupings.rb new file mode 100644 index 00000000000..03d9f13287c --- /dev/null +++ b/spec/system/page_objects/admin_badges_groupings.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module PageObjects + module Pages + class AdminBadgesGroupings < PageObjects::Pages::Base + def add_grouping(name) + within(modal) do + find(".badge-groupings__add-grouping").click + find(".badge-grouping-name-input").fill_in(with: name) + end + + save + + self + end + + def save + page.find(".badge-groupings__save").click + expect(self).to be_closed + self + end + + def modal + page.find(".badge-groupings-modal") + end + + def closed? + page.has_no_css?(".badge-groupings-modal") + end + end + end +end