diff --git a/app/assets/javascripts/discourse/app/controllers/group.js b/app/assets/javascripts/discourse/app/controllers/group.js index 3b9d3124c70..1b21e6fbc6c 100644 --- a/app/assets/javascripts/discourse/app/controllers/group.js +++ b/app/assets/javascripts/discourse/app/controllers/group.js @@ -144,13 +144,17 @@ export default Controller.extend({ didConfirm: () => { model .destroy() - .then(() => this.router.transitionTo("groups.index")) .catch((error) => { // eslint-disable-next-line no-console console.error(error); 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), }); diff --git a/app/assets/javascripts/discourse/app/templates/group.hbs b/app/assets/javascripts/discourse/app/templates/group.hbs index dca9f2c22c9..a85280559cf 100644 --- a/app/assets/javascripts/discourse/app/templates/group.hbs +++ b/app/assets/javascripts/discourse/app/templates/group.hbs @@ -64,6 +64,7 @@ @icon="trash-alt" @label="admin.groups.delete" class="btn-danger" + data-test-selector="delete-group-button" /> {{/if}} {{/if}} diff --git a/spec/system/groups/group_spec.rb b/spec/system/groups/group_spec.rb new file mode 100644 index 00000000000..f9c65b7997f --- /dev/null +++ b/spec/system/groups/group_spec.rb @@ -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 diff --git a/spec/system/page_objects/pages/group.rb b/spec/system/page_objects/pages/group.rb index b8a3a8f7bd4..d332b702809 100644 --- a/spec/system/page_objects/pages/group.rb +++ b/spec/system/page_objects/pages/group.rb @@ -17,6 +17,11 @@ module PageObjects self 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) page.find( ".modal-container .user-chooser .multi-select-header .select-kit-header-wrapper",