FIX: deleting a groups was throwing an error (#26623)

This commit is contained in:
Joffrey JAFFEUX 2024-04-15 08:35:50 +02:00 committed by GitHub
parent 8f52fd1051
commit 326da84373
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 2 deletions

View File

@ -144,13 +144,17 @@ export default Controller.extend({
didConfirm: () => { didConfirm: () => {
model model
.destroy() .destroy()
.then(() => this.router.transitionTo("groups.index"))
.catch((error) => { .catch((error) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(error); console.error(error);
this.dialog.alert(I18n.t("admin.groups.delete_failed")); this.dialog.alert(I18n.t("admin.groups.delete_failed"));
}) })
.finally(() => this.set("destroying", false)); .then(() => {
this.router.transitionTo("groups.index");
})
.finally(() => {
this.set("destroying", false);
});
}, },
didCancel: () => this.set("destroying", false), didCancel: () => this.set("destroying", false),
}); });

View File

@ -64,6 +64,7 @@
@icon="trash-alt" @icon="trash-alt"
@label="admin.groups.delete" @label="admin.groups.delete"
class="btn-danger" class="btn-danger"
data-test-selector="delete-group-button"
/> />
{{/if}} {{/if}}
{{/if}} {{/if}}

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
describe "Group", type: :system do
let(:group_page) { PageObjects::Pages::Group.new }
fab!(:admin)
fab!(:group)
before { sign_in(admin) }
describe "delete a group" do
it "redirects to groups index page" do
group_page.visit(group)
group_page.delete_group
expect(page).to have_current_path("/g")
end
end
end

View File

@ -17,6 +17,11 @@ module PageObjects
self self
end end
def delete_group
page.find("[data-test-selector='delete-group-button']").click
page.find(".dialog-footer .btn-danger").click
end
def select_user_and_add(user) def select_user_and_add(user)
page.find( page.find(
".modal-container .user-chooser .multi-select-header .select-kit-header-wrapper", ".modal-container .user-chooser .multi-select-header .select-kit-header-wrapper",