From 62e88ef8458bb14e462c98d8dbcb0e69872ea6a2 Mon Sep 17 00:00:00 2001 From: Cody Jackson Date: Tue, 15 Oct 2024 15:58:58 -0700 Subject: [PATCH] Fix a problem with deleting role templates from their detail pages We were attempting to navigate back to a non-existent page when deleting role templates from their corresponding detail pages. This caused the Prompt Remove dialog to show an error button and not close. https://github.com/rancher/dashboard/issues/12217 --- .../management.cattle.io.roletemplate.po.ts | 7 +++++++ .../tests/pages/users-and-auth/roles.spec.ts | 19 +++++++++++++++++++ shell/components/PromptRemove.vue | 4 ++-- shell/components/ResourceDetail/Masthead.vue | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/po/detail/management.cattle.io.roletemplate.po.ts b/cypress/e2e/po/detail/management.cattle.io.roletemplate.po.ts index 1a7fc951775..dd0cbe50103 100644 --- a/cypress/e2e/po/detail/management.cattle.io.roletemplate.po.ts +++ b/cypress/e2e/po/detail/management.cattle.io.roletemplate.po.ts @@ -1,11 +1,18 @@ import RoleDetailPo from '@/cypress/e2e/po/detail/role.po'; import RoleTemplateEditPo from '@/cypress/e2e/po/edit/management.cattle.io.roletemplate.po'; import ResourceDetailPo from '@/cypress/e2e/po/edit/resource-detail.po'; +import ActionMenu from '@/cypress/e2e/po/components/action-menu.po'; class RoleTemplateDetailComponentPo extends ResourceDetailPo { userCreateEditView(clusterId: string, userId?: string ) { return new RoleTemplateEditPo(clusterId, userId); } + + openMastheadActionMenu() { + this.self().get('[data-testid="mathead-action-menu"]').click(); + + return new ActionMenu(undefined); + } } export default class RoleTemplateDetailPo extends RoleDetailPo { diff --git a/cypress/e2e/tests/pages/users-and-auth/roles.spec.ts b/cypress/e2e/tests/pages/users-and-auth/roles.spec.ts index 66d25b0693d..4344a64530d 100644 --- a/cypress/e2e/tests/pages/users-and-auth/roles.spec.ts +++ b/cypress/e2e/tests/pages/users-and-auth/roles.spec.ts @@ -228,6 +228,25 @@ describe('Roles Templates', { tags: ['@usersAndAuths', '@adminUser'] }, () => { promptRemove.warning().first().should('contain.text', 'Caution:'); // Check warning message content }); + it('can delete a role template from the detail page', () => { + // Delete role and verify role is removed from list + roles.waitForRequests(); + const oneRoleTemplateId = roleTemplatesToDelete.splice(0, 1)[0]; + const detailPage = roles.detailRole(oneRoleTemplateId); + + detailPage.goTo(); + detailPage.waitForPage(); + + const actionMenu = detailPage.detail().openMastheadActionMenu(); + + actionMenu.clickMenuItem(5); + + const promptRemove = new PromptRemove(); + + promptRemove.remove(); + roles.list('CLUSTER').elementWithName(oneRoleTemplateId).should('not.exist'); + }); + it('can delete a role template', () => { // Delete role and verify role is removed from list roles.waitForRequests(); diff --git a/shell/components/PromptRemove.vue b/shell/components/PromptRemove.vue index 5320f26bf31..384c83e98a9 100644 --- a/shell/components/PromptRemove.vue +++ b/shell/components/PromptRemove.vue @@ -105,8 +105,8 @@ export default { return null; } - if (this.toRemove[0].doneLocationRemove) { - return this.toRemove[0].doneLocationRemove; + if (this.toRemove[0].doneOverride) { + return this.toRemove[0].doneOverride; } const currentRoute = this.toRemove[0].currentRoute(); diff --git a/shell/components/ResourceDetail/Masthead.vue b/shell/components/ResourceDetail/Masthead.vue index b8f66fb591f..21889fc61b8 100644 --- a/shell/components/ResourceDetail/Masthead.vue +++ b/shell/components/ResourceDetail/Masthead.vue @@ -521,6 +521,7 @@ export default {