FEATURE: confirmation when a public section is updated (#26546)

Display additional confirmation when:
- The public section is going to be updated;
- The public section is going to be deleted;
- The public section is going to be marked as private.
This commit is contained in:
Krzysztof Kotlarek
2024-04-09 09:58:30 +10:00
committed by GitHub
parent a68bea26ce
commit 0085365459
5 changed files with 79 additions and 2 deletions

View File

@ -231,6 +231,7 @@ describe "Custom sidebar sections", type: :system do
latest_link = find(".draggable[data-link-name='Sidebar Latest']")
tags_link.drag_to(latest_link, html5: true, delay: 0.4)
section_modal.save
expect(section_modal).to be_closed
expect(sidebar.primary_section_links("my-section")).to eq(
["Sidebar Categories", "Sidebar Tags", "Sidebar Latest"],
@ -292,6 +293,7 @@ describe "Custom sidebar sections", type: :system do
sidebar.edit_custom_section("My section")
section_modal.delete
expect(section_modal).to have_text("Are you sure you want to delete this section?")
section_modal.confirm_delete
expect(sidebar).to have_no_section("My section")
@ -315,15 +317,51 @@ describe "Custom sidebar sections", type: :system do
section_modal.fill_name("Edited public section")
section_modal.save
expect(section_modal).to have_text(
"Changes will be visible to everyone on this site. Are you sure?",
)
section_modal.confirm_update
expect(sidebar).to have_section("Edited public section")
sidebar.edit_custom_section("Edited public section")
section_modal.delete
expect(section_modal).to have_text(
"This section is visible to everyone, are you sure you want to delete it?",
)
section_modal.confirm_delete
expect(sidebar).to have_no_section("Edited public section")
end
it "displays warning when public section is marked as private" do
sign_in admin
visit("/latest")
sidebar.click_add_section_button
section_modal.fill_name("Public section")
section_modal.fill_link("Sidebar Tags", "/tags")
section_modal.mark_as_public
section_modal.save
sidebar.edit_custom_section("Public section")
section_modal.fill_name("Edited public section")
section_modal.mark_as_public
section_modal.save
expect(section_modal).to have_text(
"This section is visible to everyone. After the update, it will be visible only to you. Are you sure?",
)
section_modal.confirm_update
expect(sidebar).to have_section("Edited public section")
expect(page).not_to have_css(
".sidebar-section[data-section-name='edited-public-section'] .d-icon-globe",
)
end
it "shows anonymous public sections" do
sidebar_section = Fabricate(:sidebar_section, title: "Public section", public: true)
sidebar_url_1 = Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags")

View File

@ -30,6 +30,7 @@ RSpec.describe "Editing Sidebar Community Section", type: :system do
modal.fill_link("Topics", "/latest", "paper-plane")
modal.topics_link.drag_to(modal.review_link, delay: 0.4)
modal.save
modal.confirm_update
expect(sidebar.primary_section_links("community")).to eq(
["My Posts", "Topics", "Review", "Admin", "More"],

View File

@ -29,6 +29,12 @@ module PageObjects
def confirm_delete
find(".dialog-container .btn-primary").click
closed?
end
def confirm_update
find(".dialog-container .btn-primary").click
closed?
end
def reset
@ -40,7 +46,6 @@ module PageObjects
def save
find("#save-section").click
closed?
self
end