Skip to content

Commit

Permalink
fix: Error when try cancel delete (#296)
Browse files Browse the repository at this point in the history
Co-authored-by: Felipe Soares <>
  • Loading branch information
FelipePSoares authored Jan 2, 2025
1 parent dcd41e6 commit 3991962
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
19 changes: 19 additions & 0 deletions easyfinance.client/cypress/e2e/user/detail-user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
})
})
4 changes: 4 additions & 0 deletions easyfinance.client/cypress/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"userToDelete": {
"username": "[email protected]",
"password": "Passw0rd!"
},
"userToNotDelete": {
"username": "[email protected]",
"password": "Passw0rd!"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ <h3>Danger Zone</h3>
</div>
</div>
</div>
<app-confirm-dialog (confirmed)="confirmDeletion()"></app-confirm-dialog>
<app-confirm-dialog (confirmed)="confirmDeletion($event)"></app-confirm-dialog>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3991962

Please sign in to comment.