Adapt test to new DangerDialogs

This commit is contained in:
Henriette Darge
2026-03-23 15:56:06 +01:00
parent 1146317eae
commit d0ebdbdd8a
4 changed files with 10 additions and 33 deletions
@@ -34,7 +34,6 @@ require_module_spec_helper
RSpec.describe "SAML administration CRUD",
:js do
shared_let(:user) { create(:admin) }
let(:danger_zone) { DangerZone.new(page) }
before do
login_as(user)
@@ -110,20 +109,9 @@ RSpec.describe "SAML administration CRUD",
expect(provider.limit_self_registration).to be true
click_link_or_button "Delete"
# Confirm the deletion
# Without confirmation, the button is disabled
expect(danger_zone).to be_disabled
# With wrong confirmation, the button is disabled
danger_zone.confirm_with("foo")
expect(danger_zone).to be_disabled
# With correct confirmation, the button is enabled
# and the project can be deleted
danger_zone.confirm_with(provider.display_name)
expect(danger_zone).not_to be_disabled
danger_zone.danger_button.click
check "I understand that this deletion cannot be reversed"
click_on "Delete permanently"
expect(page).to have_text "No SAML providers configured yet."
expect { provider.reload }.to raise_error ActiveRecord::RecordNotFound
@@ -170,15 +170,16 @@ RSpec.describe LdapGroups::SynchronizedGroupsController, with_ee: %i[ldap_groups
let!(:group) { build_stubbed(:ldap_synchronized_group) }
let(:id) { "foo" }
it "renders the page" do
it "renders the dialog" do
expect(LdapGroups::SynchronizedGroup)
.to receive(:find)
.with("foo")
.and_return(group)
get :destroy_info, params: { ldap_group_id: id }
get :destroy_info, params: { ldap_group_id: id }, format: :turbo_stream
expect(response).to be_successful
expect(response).to render_template "destroy_info"
expect(response).to have_turbo_stream action: "dialog",
target: "ldap-groups-synchronized-groups-destroy-dialog-component"
end
end
end
@@ -73,10 +73,10 @@ RSpec.describe "LDAP group sync administration spec", :js do
find(".buttons a", text: "Delete").click
SeleniumHubWaiter.wait
find(".danger-zone--verification input").set "cn=bar,ou=groups,dc=example,dc=com"
check "I understand that this deletion cannot be reversed"
click_on "Delete permanently"
SeleniumHubWaiter.wait
click_on "Delete"
expect_flash(message: I18n.t(:notice_successful_delete))
expect(page).to have_css ".generic-table--empty-row"
@@ -34,7 +34,6 @@ require_module_spec_helper
RSpec.describe "OIDC administration CRUD",
:js do
shared_let(:user) { create(:admin) }
let(:danger_zone) { DangerZone.new(page) }
before do
login_as(user)
@@ -130,20 +129,9 @@ RSpec.describe "OIDC administration CRUD",
expect(provider.group_regexes).to eq(["Foo", "Bar"])
click_link_or_button "Delete"
# Confirm the deletion
# Without confirmation, the button is disabled
expect(danger_zone).to be_disabled
# With wrong confirmation, the button is disabled
danger_zone.confirm_with("foo")
expect(danger_zone).to be_disabled
# With correct confirmation, the button is enabled
# and the project can be deleted
danger_zone.confirm_with(provider.display_name)
expect(danger_zone).not_to be_disabled
danger_zone.danger_button.click
check "I understand that this deletion cannot be reversed"
click_on "Delete permanently"
expect(page).to have_text "No OpenID providers configured yet."
expect { provider.reload }.to raise_error ActiveRecord::RecordNotFound