diff --git a/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.spec.ts b/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.spec.ts index 05dcdb1..d2ed942 100644 --- a/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.spec.ts +++ b/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.spec.ts @@ -1,6 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { of } from 'rxjs'; +import { of, throwError } from 'rxjs'; import { CashboxExportApi } from '../../../../core/team/cashbox-export-api'; import { FileDownloadService } from '../../../../shared/file-download/file-download.service'; import { CashboxExportDialog } from './cashbox-export-dialog'; @@ -46,4 +46,26 @@ describe('CashboxExportDialog', () => { expect(save).toHaveBeenCalledWith(expect.any(Blob), 'kassenbuch_2026-08-01_2026-08-31.csv'); expect(dialogRef.close).toHaveBeenCalled(); }); + + it('displays error message and does not close dialog on export failure', () => { + exportCashbox = vi.fn(() => throwError(() => new Error('network error'))); + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ + imports: [CashboxExportDialog], + providers: [ + { provide: MAT_DIALOG_DATA, useValue: { teamId: 5 } }, + { provide: MatDialogRef, useValue: dialogRef }, + { provide: CashboxExportApi, useValue: { exportCashbox } }, + { provide: FileDownloadService, useValue: { save } }, + ], + }); + fixture = TestBed.createComponent(CashboxExportDialog); + fixture.detectChanges(); + + fixture.componentInstance['form'].setValue({ from: '2026-08-01', to: '2026-08-31', format: 'csv' }); + fixture.componentInstance['download'](); + + expect(dialogRef.close).not.toHaveBeenCalled(); + expect(fixture.componentInstance['downloadError']()).toBe('Export konnte nicht heruntergeladen werden.'); + }); }); diff --git a/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.ts b/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.ts index 2bc86c2..0788ec5 100644 --- a/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.ts +++ b/myteamwallet_frontend_modern/src/app/features/team/cashbox/cashbox-export-dialog/cashbox-export-dialog.ts @@ -1,4 +1,4 @@ -import { Component, inject } from '@angular/core'; +import { Component, inject, signal } from '@angular/core'; import { FormBuilder, ReactiveFormsModule, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; @@ -29,6 +29,9 @@ const rangeValid: ValidatorFn = (group): ValidationErrors | null => {