diff --git a/easyfinance.client/cypress/e2e/user/detail-user.cy.ts b/easyfinance.client/cypress/e2e/user/detail-user.cy.ts index c36e204e..4d7830b4 100644 --- a/easyfinance.client/cypress/e2e/user/detail-user.cy.ts +++ b/easyfinance.client/cypress/e2e/user/detail-user.cy.ts @@ -82,4 +82,23 @@ describe('EconoFlow - user detail Tests', () => { }) }) }) + + it('can\'t delete user', () => { + cy.fixture('users').then((users) => { + const user = users.userToNotDelete; + + cy.intercept('DELETE', '**/account*').as('deleteAccount') + + cy.register(user.username, user.password) + cy.visit('/user') + cy.get('.btn').contains('Delete Account').click(); + cy.wait('@deleteAccount').then((interception) => { + expect(interception?.response?.statusCode).to.equal(202) + cy.get('.modal-dialog .btn').contains('Cancel').click(); + + cy.visit('/') + cy.url().should('not.contain', 'login') + }) + }) + }) }) diff --git a/easyfinance.client/cypress/fixtures/users.json b/easyfinance.client/cypress/fixtures/users.json index a6797400..14e52fd0 100644 --- a/easyfinance.client/cypress/fixtures/users.json +++ b/easyfinance.client/cypress/fixtures/users.json @@ -13,5 +13,9 @@ "userToDelete": { "username": "test2@test.com", "password": "Passw0rd!" + }, + "userToNotDelete": { + "username": "test3@test.com", + "password": "Passw0rd!" } } diff --git a/easyfinance.client/src/app/features/user/detail-user/detail-user.component.html b/easyfinance.client/src/app/features/user/detail-user/detail-user.component.html index 409775e4..558f7816 100644 --- a/easyfinance.client/src/app/features/user/detail-user/detail-user.component.html +++ b/easyfinance.client/src/app/features/user/detail-user/detail-user.component.html @@ -185,4 +185,4 @@

Danger Zone

- + diff --git a/easyfinance.client/src/app/features/user/detail-user/detail-user.component.ts b/easyfinance.client/src/app/features/user/detail-user/detail-user.component.ts index 5f811a1d..fdcd6dc4 100644 --- a/easyfinance.client/src/app/features/user/detail-user/detail-user.component.ts +++ b/easyfinance.client/src/app/features/user/detail-user/detail-user.component.ts @@ -121,8 +121,8 @@ export class DetailUserComponent implements OnInit { }); } - confirmDeletion(): void { - if (this.deleteToken) { + confirmDeletion(result: boolean): void { + if (result && this.deleteToken) { this.userService.deleteUser(this.deleteToken).subscribe({ next: (response) => { this.userService.removeUserInfo();