From 174c82dc93da2fea9062eb4aa22fd9f1c54dae6c Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Mon, 30 Dec 2024 14:53:30 +0100
Subject: [PATCH 1/9] Feat: redesigned danger zone
---
.../confirm-dialog.component.css | 3 +
.../confirm-dialog.component.html | 5 +-
.../confirm-dialog.component.ts | 7 +-
.../src/app/core/models/user.ts | 5 ++
.../src/app/core/services/token.service.ts | 27 --------
.../src/app/core/services/user.service.ts | 12 ++--
.../detail-user/detail-user.component.css | 7 +-
.../detail-user/detail-user.component.html | 51 +++++---------
.../user/detail-user/detail-user.component.ts | 66 ++++---------------
9 files changed, 55 insertions(+), 128 deletions(-)
delete mode 100644 easyfinance.client/src/app/core/services/token.service.ts
diff --git a/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.css b/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.css
index e69de29b..655d1e9a 100644
--- a/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.css
+++ b/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.css
@@ -0,0 +1,3 @@
+#confirmationModalLabel {
+ margin: 0;
+}
diff --git a/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.html b/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.html
index ad85fabf..b7e0e04b 100644
--- a/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.html
+++ b/easyfinance.client/src/app/core/components/confirm-dialog/confirm-dialog.component.html
@@ -2,11 +2,10 @@
-
-
-
- Confirm Deletion
-
-
-
- Are you sure you want to delete your account? This action cannot be undone.
-
-
-
- {{ deleteModalError }}
-
-
-
-
-
-
+
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 b48def97..cd47890a 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
@@ -4,7 +4,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { faCheck, faCircleCheck, faCircleXmark, faFloppyDisk, faPenToSquare, faEnvelopeOpenText } from '@fortawesome/free-solid-svg-icons';
import { UserService } from '../../../core/services/user.service';
import { Observable } from 'rxjs';
-import { User } from '../../../core/models/user';
+import { DeleteUser, User } from '../../../core/models/user';
import { AsyncPipe, CommonModule } from '@angular/common';
import { ApiErrorResponse } from '../../../core/models/error';
import { ErrorMessageService } from '../../../core/services/error-message.service';
@@ -16,12 +16,8 @@ import { MatSelectModule } from '@angular/material/select';
import { MatOptionModule } from '@angular/material/core';
import { CurrencyService } from '../../../core/services/currency.service';
import { MatIcon } from "@angular/material/icon";
-import { MatDialogContent } from '@angular/material/dialog';
-import { MatDialog, MatDialogRef } from '@angular/material/dialog';
-import { MatDialogModule } from '@angular/material/dialog';
import { Router } from '@angular/router';
-import { TokenService } from 'src/app/core/services/token.service';
-import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
+import { ConfirmDialogComponent } from '../../../core/components/confirm-dialog/confirm-dialog.component';
@Component({
selector: 'app-detail-user',
@@ -38,22 +34,21 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
MatSelectModule,
MatOptionModule,
MatIcon,
- MatDialogContent,
- MatDialogModule,
+ ConfirmDialogComponent,
],
templateUrl: './detail-user.component.html',
styleUrl: './detail-user.component.css'
})
export class DetailUserComponent implements OnInit {
+ private deleteToken!: string;
+
+ @ViewChild(ConfirmDialogComponent) ConfirmDialog!: ConfirmDialogComponent;
user$: Observable
;
editingUser!: User;
isEmailUpdated: boolean = false;
isPasswordUpdated: boolean = false;
passwordFormActive: boolean = false;
- deleteError: string | null = null;
- deleteModalError: string | null = null;
-
isModalOpen: boolean = false;
faCheck = faCheck;
faCircleCheck = faCircleCheck;
@@ -62,7 +57,6 @@ export class DetailUserComponent implements OnInit {
faPenToSquare = faPenToSquare;
faEnvelopeOpenText = faEnvelopeOpenText;
- confirmationMessage: string = ''
passwordForm!: FormGroup;
userForm!: FormGroup;
httpErrors = false;
@@ -74,9 +68,8 @@ export class DetailUserComponent implements OnInit {
hasOneNumber = false;
hasOneSpecial = false;
hasMinCharacteres = false;
- @ViewChild('deleteDialog') deleteDialog!: TemplateRef; // Reference the inline dialog templat
- constructor(private userService: UserService,private sanitizer: DomSanitizer, private tokenService: TokenService, private router:Router, private dialog: MatDialog , private currencyService: CurrencyService, private errorMessageService: ErrorMessageService) {
+ constructor(private userService: UserService, private router:Router, private currencyService: CurrencyService, private errorMessageService: ErrorMessageService) {
this.user$ = this.userService.loggedUser$;
}
@@ -116,59 +109,26 @@ export class DetailUserComponent implements OnInit {
this.hasMinCharacteres = /^.{8,}$/.test(value.password);
});
}
-
- sanitizeMessage(message: string): SafeHtml {
- return this.sanitizer.bypassSecurityTrustHtml(message);
- }
openDeleteDialog(): void {
- this.deleteError = null;
- this.deleteModalError = null;
-
- const dialogRef: MatDialogRef = this.dialog.open(this.deleteDialog, {
- width: '400px',
- });
- this.tokenService.clearToken();
this.userService.deleteUser().subscribe({
- next: (response: any) => {
+ next: (response: DeleteUser) => {
if (response?.confirmationToken) {
- this.confirmationMessage = response.confirmationMessage;
- this.tokenService.setToken(response.confirmationToken, response.confirmationMessage);
+ var message = 'Are you sure you want to delete your account? This action cannot be undone.
' + response.confirmationMessage;
+ this.ConfirmDialog.openModal('Confirm Deletion', message, 'Delete');
+ this.deleteToken = response.confirmationToken;
}
},
- error: (err) => {
- console.error('Error during first deletion attempt:', err);
- this.deleteError = 'Failed to delete account. Please try again later';
- },
- });
-
- dialogRef.afterClosed().subscribe(result => {
- if (result === true) {
- this.confirmDeletion();
- }
});
}
- closeDialog(): void {
- this.deleteError = null;
- this.deleteModalError = null;
- this.dialog.closeAll();
- }
-
confirmDeletion(): void {
- this.deleteModalError = null;
- const token = this.tokenService.getToken();
- if (token) {
- this.userService.deleteUser(token).subscribe({
+ if (this.deleteToken) {
+ this.userService.deleteUser(this.deleteToken).subscribe({
next: (response) => {
- this.dialog.closeAll();
this.userService.removeUserInfo();
this.router.navigate(['/']);
},
- error: (err) => {
- console.error('Error deleting user:', err);
- this.deleteModalError = 'Account deletion failed. Please log out, then log back in and try again';
- },
});
}
}
From 5ab6f8deddbe4c530a5321249380ef19ad11fca6 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Mon, 30 Dec 2024 16:02:03 +0100
Subject: [PATCH 2/9] Added tests
---
.../cypress/e2e/user/detail-user.cy.ts | 20 +++++++++++++++++++
.../cypress/fixtures/users.json | 4 ++++
.../cypress/support/commands.ts | 16 +++++++++++++++
.../user/detail-user/detail-user.component.ts | 3 +--
4 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/easyfinance.client/cypress/e2e/user/detail-user.cy.ts b/easyfinance.client/cypress/e2e/user/detail-user.cy.ts
index ae9ecf41..d49d66d9 100644
--- a/easyfinance.client/cypress/e2e/user/detail-user.cy.ts
+++ b/easyfinance.client/cypress/e2e/user/detail-user.cy.ts
@@ -58,4 +58,24 @@ describe('EconoFlow - user detail Tests', () => {
cy.get('.btn').contains('Cancel').click();
cy.get('.btn').contains('Modify Password').should('exist')
})
+
+ it('should be possible delete user', () => {
+ cy.fixture('users').then((users) => {
+ const user = users.userToDelete;
+
+ 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('Delete').click();
+
+ cy.wait('@deleteAccount').then((interception2) => {
+ expect(interception2?.response?.statusCode).to.equal(200)
+ })
+ })
+ })
+ })
})
diff --git a/easyfinance.client/cypress/fixtures/users.json b/easyfinance.client/cypress/fixtures/users.json
index 95c62368..a6797400 100644
--- a/easyfinance.client/cypress/fixtures/users.json
+++ b/easyfinance.client/cypress/fixtures/users.json
@@ -9,5 +9,9 @@
"testUser": {
"username": "test@test.com",
"password": "Passw0rd!"
+ },
+ "userToDelete": {
+ "username": "test2@test.com",
+ "password": "Passw0rd!"
}
}
diff --git a/easyfinance.client/cypress/support/commands.ts b/easyfinance.client/cypress/support/commands.ts
index b205426d..0b2cd183 100644
--- a/easyfinance.client/cypress/support/commands.ts
+++ b/easyfinance.client/cypress/support/commands.ts
@@ -31,6 +31,22 @@ Cypress.Commands.add('register', (username, password) => {
cy.visit('/')
cy.url().should('include', 'first-signin')
+
+ cy.intercept('GET', '/api/account/').as('getAccount')
+
+ cy.get('input[formControlName=firstName]').type('test')
+ cy.get('input[formControlName=lastName]').type('test')
+ const preferredCurrencyInput = cy.get('mat-select[formcontrolname=preferredCurrency]');
+ preferredCurrencyInput.click().get('mat-option').contains('EUR').click()
+ cy.get('button').contains('Send').click();
+ cy.wait('@getAccount')
+ },
+ {
+ validate: () => {
+ cy.login(username, password)
+ cy.visit('/')
+ cy.url().should('not.contain', 'login')
}
+ }
)
})
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 cd47890a..5f811a1d 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
@@ -114,8 +114,7 @@ export class DetailUserComponent implements OnInit {
this.userService.deleteUser().subscribe({
next: (response: DeleteUser) => {
if (response?.confirmationToken) {
- var message = 'Are you sure you want to delete your account? This action cannot be undone.
' + response.confirmationMessage;
- this.ConfirmDialog.openModal('Confirm Deletion', message, 'Delete');
+ this.ConfirmDialog.openModal('Confirm Deletion', response.confirmationMessage, 'Delete');
this.deleteToken = response.confirmationToken;
}
},
From 0e5403c706c287e49777f9b0ef3eb9e20189dbc4 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 13:49:30 +0100
Subject: [PATCH 3/9] Create artifacts to save screenshots from errors
---
.github/workflows/BuildAndTests.yml | 8 +++++++-
.../features/user/detail-user/detail-user.component.html | 3 +--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/BuildAndTests.yml b/.github/workflows/BuildAndTests.yml
index 51a417cd..31bc724c 100644
--- a/.github/workflows/BuildAndTests.yml
+++ b/.github/workflows/BuildAndTests.yml
@@ -45,4 +45,10 @@ jobs:
- name: Run Cypress tests
run: npx cypress run
- working-directory: ./easyfinance.client
\ No newline at end of file
+ working-directory: ./easyfinance.client
+
+ - name: Archive Cypress errors
+ uses: actions/upload-artifact@v4
+ with:
+ name: cypress-screenshots
+ path: ./easyfinance.client/cypress/screenshots
\ No newline at end of file
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 c3eb1e8d..409775e4 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
@@ -178,8 +178,7 @@ Password Reset
Danger Zone
Deleting your account is permanent and cannot be undone.
-
From 8b32d134986b375e85bc141f832f6e27c4654984 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 14:01:42 +0100
Subject: [PATCH 4/9] test
---
.github/workflows/BuildAndTests.yml | 41 +++++++++++++++++++++--------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/BuildAndTests.yml b/.github/workflows/BuildAndTests.yml
index 31bc724c..0b5275c2 100644
--- a/.github/workflows/BuildAndTests.yml
+++ b/.github/workflows/BuildAndTests.yml
@@ -12,11 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
+
- name: Setup .NET
- uses: actions/setup-dotnet@v3
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: 6.0.x
+ dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
@@ -24,11 +25,8 @@ jobs:
- name: Build backend application
run: dotnet build --configuration Debug --no-restore
- - name: Test
- run: dotnet test --no-build --verbosity normal
-
- name: Install Node.js
- uses: actions/setup-node@v3
+ uses: actions/setup-node@v4
with:
node-version: '18.x'
@@ -36,19 +34,40 @@ jobs:
run: npm install
working-directory: ./easyfinance.client
- - name: Run Angular tests
- run: npm test -- --watch=false --browsers=ChromeHeadless
- working-directory: ./easyfinance.client
+ tests:
+ needs: [build]
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 8.0.x
+
+ - uses: actions/checkout@v4
+ - name: Run .Net tests
+ run: dotnet test --verbosity normal
- name: Start application
+ id: dotnet
run: dotnet run --project ./EasyFinance.Server --urls https://localhost:7003/ &
+ - name: Run Angular tests
+ id: angular
+ run: npm test -- --watch=false --browsers=ChromeHeadless
+ working-directory: ./easyfinance.client
+
- name: Run Cypress tests
+ id: cypress
run: npx cypress run
+ continue-on-error: true
working-directory: ./easyfinance.client
- name: Archive Cypress errors
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
- path: ./easyfinance.client/cypress/screenshots
\ No newline at end of file
+ path: ./easyfinance.client/cypress/screenshots
+
+ outputs:
+ actualResult: ${{ steps.dotnet.outcome && steps.angular.outcome && steps.cypress.outcome }}
\ No newline at end of file
From d4e2281ddd4d5f2df3ee8559dc104e0fd72348d1 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 15:31:51 +0100
Subject: [PATCH 5/9] fix
---
.github/workflows/BuildAndTests.yml | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/BuildAndTests.yml b/.github/workflows/BuildAndTests.yml
index 0b5275c2..9bdb2095 100644
--- a/.github/workflows/BuildAndTests.yml
+++ b/.github/workflows/BuildAndTests.yml
@@ -37,6 +37,7 @@ jobs:
tests:
needs: [build]
runs-on: ubuntu-latest
+ continue-on-error: true
steps:
- name: Setup .NET
@@ -60,14 +61,10 @@ jobs:
- name: Run Cypress tests
id: cypress
run: npx cypress run
- continue-on-error: true
working-directory: ./easyfinance.client
- name: Archive Cypress errors
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
- path: ./easyfinance.client/cypress/screenshots
-
- outputs:
- actualResult: ${{ steps.dotnet.outcome && steps.angular.outcome && steps.cypress.outcome }}
\ No newline at end of file
+ path: ./easyfinance.client/cypress/screenshots
\ No newline at end of file
From 1a5cfe499cbcea2c720f7e72e264ce4f1f83c1e5 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 15:42:51 +0100
Subject: [PATCH 6/9] fix
---
.github/workflows/BuildAndTests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/BuildAndTests.yml b/.github/workflows/BuildAndTests.yml
index 9bdb2095..b087e4e8 100644
--- a/.github/workflows/BuildAndTests.yml
+++ b/.github/workflows/BuildAndTests.yml
@@ -37,7 +37,6 @@ jobs:
tests:
needs: [build]
runs-on: ubuntu-latest
- continue-on-error: true
steps:
- name: Setup .NET
@@ -64,6 +63,7 @@ jobs:
working-directory: ./easyfinance.client
- name: Archive Cypress errors
+ if: ${{ steps.cypress.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
From 349078ace6f168211ec9f2addd359bd609db4433 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 15:49:13 +0100
Subject: [PATCH 7/9] fix
---
.github/workflows/BuildAndTests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/BuildAndTests.yml b/.github/workflows/BuildAndTests.yml
index b087e4e8..154b5af7 100644
--- a/.github/workflows/BuildAndTests.yml
+++ b/.github/workflows/BuildAndTests.yml
@@ -63,7 +63,7 @@ jobs:
working-directory: ./easyfinance.client
- name: Archive Cypress errors
- if: ${{ steps.cypress.conclusion == 'failure' }}
+ if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
From 034e1d9f10fa2db764d763b5862f535d0e3841c5 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 16:54:09 +0100
Subject: [PATCH 8/9] fix
---
.../cypress/e2e/auth/register.cy.ts | 13 ----
.../cypress/e2e/user/detail-user.cy.ts | 78 ++++++++++---------
.../cypress/support/commands.ts | 10 ++-
3 files changed, 47 insertions(+), 54 deletions(-)
diff --git a/easyfinance.client/cypress/e2e/auth/register.cy.ts b/easyfinance.client/cypress/e2e/auth/register.cy.ts
index 75cc3bd6..333fa335 100644
--- a/easyfinance.client/cypress/e2e/auth/register.cy.ts
+++ b/easyfinance.client/cypress/e2e/auth/register.cy.ts
@@ -4,20 +4,7 @@ describe('EconoFlow - Register Tests', () => {
const user = users.testUser;
const email = Math.floor(Math.random() * 1000).toString() + user.username;
- cy.intercept('PUT', '**/account*').as('putAccount')
-
cy.register(email, user.password)
-
- cy.visit('/')
-
- cy.get('input[formControlName=firstName]').type('Test')
- cy.get('input[formControlName=lastName]').type(`Test`)
- cy.get('mat-select[formControlName=preferredCurrency]').click().get('mat-option').contains('EUR').click()
- cy.get('button').contains('Send').click();
-
- cy.wait('@putAccount').then(({ request, response }) => {
- expect(response?.statusCode).to.equal(200)
- })
})
})
})
diff --git a/easyfinance.client/cypress/e2e/user/detail-user.cy.ts b/easyfinance.client/cypress/e2e/user/detail-user.cy.ts
index d49d66d9..c36e204e 100644
--- a/easyfinance.client/cypress/e2e/user/detail-user.cy.ts
+++ b/easyfinance.client/cypress/e2e/user/detail-user.cy.ts
@@ -1,62 +1,66 @@
describe('EconoFlow - user detail Tests', () => {
let currenciesAvailable: string[];
- beforeEach(() => {
+ it('Should edit user infos', () => {
cy.fixture('users').then((users) => {
currenciesAvailable = users.currencies;
const user = users.testUser;
cy.login(user.username, user.password)
- })
- })
-
- it('Should edit user infos', () => {
- cy.visit('/user')
+ cy.visit('/user')
- cy.intercept('GET', '**/account*').as('getAccount')
- cy.intercept('PUT', '**/account*').as('putAccount')
- cy.intercept('POST', '/api/account/manage/info').as('postAccount')
+ cy.intercept('GET', '**/account*').as('getAccount')
+ cy.intercept('PUT', '**/account*').as('putAccount')
+ cy.intercept('POST', '/api/account/manage/info').as('postAccount')
- const firstNameInput = cy.get('input[formcontrolname=firstName]');
- const firstNameValue = 'firstName' + Math.floor(Math.random() * 1000).toString();
+ const firstNameInput = cy.get('input[formcontrolname=firstName]');
+ const firstNameValue = 'firstName' + Math.floor(Math.random() * 1000).toString();
- const lastNameInput = cy.get('input[formcontrolname=lastName]');
- const lastNameValue = 'lastName' + Math.floor(Math.random() * 1000).toString();
+ const lastNameInput = cy.get('input[formcontrolname=lastName]');
+ const lastNameValue = 'lastName' + Math.floor(Math.random() * 1000).toString();
- const emailInput = cy.get('input[formcontrolname=email]');
- const emailValue = 'email' + Math.floor(Math.random() * 1000).toString() + '@test.com';
+ const emailInput = cy.get('input[formcontrolname=email]');
+ const emailValue = 'email' + Math.floor(Math.random() * 1000).toString() + '@test.com';
- const preferredCurrencyInput = cy.get('mat-select[formcontrolname=preferredCurrency]');
- const preferredCurrencyValue = currenciesAvailable[Math.floor(Math.random() * currenciesAvailable.length)];
+ const preferredCurrencyInput = cy.get('mat-select[formcontrolname=preferredCurrency]');
+ const preferredCurrencyValue = currenciesAvailable[Math.floor(Math.random() * currenciesAvailable.length)];
- cy.get('.btn').contains('Edit').click();
+ cy.get('.btn').contains('Edit').click();
- firstNameInput.clear().type(firstNameValue);
- lastNameInput.clear().type(lastNameValue);
- emailInput.clear().type(emailValue);
- preferredCurrencyInput.click().get('mat-option').contains(preferredCurrencyValue).click()
+ firstNameInput.clear().type(firstNameValue);
+ lastNameInput.clear().type(lastNameValue);
+ emailInput.clear().type(emailValue);
+ preferredCurrencyInput.click().get('mat-option').contains(preferredCurrencyValue).click()
- cy.get('button').contains('Save').click();
+ cy.get('button').contains('Save').click();
- cy.wait('@putAccount').then(({ request, response }) => {
- expect(response?.statusCode).to.equal(200)
- })
- cy.wait('@postAccount').then(({ request, response }) => {
- expect(response?.statusCode).to.equal(200)
- })
- cy.wait('@getAccount').then(({ request, response }) => {
- expect(response?.body.firstName).to.equal(firstNameValue);
- expect(response?.body.lastName).to.equal(lastNameValue);
- expect(response?.body.preferredCurrency).to.equal(preferredCurrencyValue);
+ cy.wait('@putAccount').then(({ request, response }) => {
+ expect(response?.statusCode).to.equal(200)
+ })
+ cy.wait('@postAccount').then(({ request, response }) => {
+ expect(response?.statusCode).to.equal(200)
+ })
+ cy.wait('@getAccount').then(({ request, response }) => {
+ expect(response?.body.firstName).to.equal(firstNameValue);
+ expect(response?.body.lastName).to.equal(lastNameValue);
+ expect(response?.body.preferredCurrency).to.equal(preferredCurrencyValue);
+ })
})
})
it('should be possible cancel modify password', () => {
- cy.visit('/user')
- cy.get('.btn').contains('Modify Password').click();
- cy.get('.btn').contains('Cancel').click();
- cy.get('.btn').contains('Modify Password').should('exist')
+ cy.fixture('users').then((users) => {
+ currenciesAvailable = users.currencies;
+
+ const user = users.testUser;
+
+ cy.login(user.username, user.password)
+ cy.visit('/user')
+ cy.get('.btn').contains('Modify Password').click();
+ cy.get('.btn').contains('Cancel').click();
+ cy.get('.btn').contains('Modify Password').should('exist')
+ })
})
it('should be possible delete user', () => {
diff --git a/easyfinance.client/cypress/support/commands.ts b/easyfinance.client/cypress/support/commands.ts
index 0b2cd183..6f4144e6 100644
--- a/easyfinance.client/cypress/support/commands.ts
+++ b/easyfinance.client/cypress/support/commands.ts
@@ -21,19 +21,21 @@ Cypress.Commands.add('register', (username, password) => {
cy.session(
username,
() => {
+ cy.intercept('GET', '/api/account/').as('getAccount')
+ cy.intercept('POST', '/api/account/register').as('postAccount')
+
cy.visit('/register')
cy.get('input[formControlName=email]').type(username)
cy.get('input[formControlName=password]').type(password)
cy.get('input[formControlName=confirmPassword]').type(`${password}{enter}`, { force: true, log: false })
+ cy.wait('@postAccount')
cy.url().should('include', 'login')
- cy.login(username, password)
+ cy.get('input[formControlName=email]').type(username)
+ cy.get('input[formControlName=password]').type(`${password}{enter}`, { log: false })
- cy.visit('/')
cy.url().should('include', 'first-signin')
- cy.intercept('GET', '/api/account/').as('getAccount')
-
cy.get('input[formControlName=firstName]').type('test')
cy.get('input[formControlName=lastName]').type('test')
const preferredCurrencyInput = cy.get('mat-select[formcontrolname=preferredCurrency]');
From a36c73b55d1b7a61c10b1bfb8cf9449aa6511d96 Mon Sep 17 00:00:00 2001
From: Felipe Soares <>
Date: Tue, 31 Dec 2024 17:03:30 +0100
Subject: [PATCH 9/9] fix
---
easyfinance.client/cypress/support/commands.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/easyfinance.client/cypress/support/commands.ts b/easyfinance.client/cypress/support/commands.ts
index 6f4144e6..ba087412 100644
--- a/easyfinance.client/cypress/support/commands.ts
+++ b/easyfinance.client/cypress/support/commands.ts
@@ -33,6 +33,7 @@ Cypress.Commands.add('register', (username, password) => {
cy.get('input[formControlName=email]').type(username)
cy.get('input[formControlName=password]').type(`${password}{enter}`, { log: false })
+ cy.wait('@getAccount')
cy.url().should('include', 'first-signin')