Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem with deleting role templates from the respective detail pages #12270

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines -108 to -109
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doneLocationRemove is no longer used in our codebase.

It was originally added to support Epinio 917ce2e

We do need to respect doneOverride here just like we do in other locations so I decided to swap the two.

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
Loading