Skip to content

Commit

Permalink
Merge pull request #12270 from codyrancher/role-template-detail-remove
Browse files Browse the repository at this point in the history
Fix a problem with deleting role templates from the respective detail pages
  • Loading branch information
codyrancher authored Oct 16, 2024
2 parents c8e9aeb + 62e88ef commit d0c3c5a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cypress/e2e/po/detail/management.cattle.io.roletemplate.po.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions cypress/e2e/tests/pages/users-and-auth/roles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions shell/components/PromptRemove.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions shell/components/ResourceDetail/Masthead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ export default {
<button
v-if="isView"
ref="actions"
data-testid="mathead-action-menu"
aria-haspopup="true"
type="button"
class="btn role-multi-action actions"
Expand Down

0 comments on commit d0c3c5a

Please sign in to comment.