diff --git a/src/main/webapp/app/service/toast-service.ts b/src/main/webapp/app/service/toast-service.ts index 906249ee21..c712afc705 100644 --- a/src/main/webapp/app/service/toast-service.ts +++ b/src/main/webapp/app/service/toast-service.ts @@ -10,6 +10,13 @@ export type ToastMessageInput = { life?: number; }; +const DEFAULT_LIFE_BY_SEVERITY: Record = { + success: 3000, + info: 3000, + warn: 5000, + error: 6000, +}; + @Injectable({ providedIn: 'root', }) @@ -65,7 +72,7 @@ export class ToastService { } private show(message: ToastMessageInput, severity: ToastSeverity): void { - this.messageService.add({ severity, ...message }); + this.messageService.add(Object.assign({ severity, life: DEFAULT_LIFE_BY_SEVERITY[severity] }, message)); } private createGlobalToast(): void { diff --git a/src/main/webapp/i18n/de/global.json b/src/main/webapp/i18n/de/global.json index b98f53587f..7fa880b774 100644 --- a/src/main/webapp/i18n/de/global.json +++ b/src/main/webapp/i18n/de/global.json @@ -219,15 +219,15 @@ }, "upload_failed": { "summary": "Upload fehlgeschlagen", - "detail": "Ein Fehler ist während des Uploads aufgetreten. Bitte versuche es erneut." + "detail": "Bitte überprüfe deine Verbindung und versuche es erneut. Sonst kontaktiere uns." }, "delete_failed": { "summary": "Löschen fehlgeschlagen", - "detail": "Ein Fehler ist während des Löschens des Dokuments aufgetreten. Bitte versuche es erneut." + "detail": "Bitte versuche es erneut. Sonst kontaktiere uns." }, "rename_failed": { "summary": "Umbenennen fehlgeschlagen", - "detail": "Ein Fehler ist während des Umbenennens des Dokuments aufgetreten. Bitte versuche es erneut." + "detail": "Bitte versuche es erneut. Sonst kontaktiere uns." } } }, @@ -284,7 +284,7 @@ "loading": "Extrahiert...", "aiExtractionFailed": { "summary": "Extraktion fehlgeschlagen", - "detail": "Die Daten konnten nicht extrahiert werden. Bitte versuche es erneut." + "detail": "Stelle sicher, dass die Datei eine klar lesbare PDF ist, oder fülle die Felder manuell aus." } }, "applicationPage1": { @@ -482,56 +482,56 @@ "detail": "Vielen Dank für deine Bewerbung." }, "invalidJobId": { - "summary": "Ungültige Job-ID", - "detail": "Bitte prüfe die eingegebene Job-ID und versuche es erneut." + "summary": "Ungültiger Job-Link", + "detail": "Der Link ist möglicherweise fehlerhaft oder die Stelle wurde entfernt. Durchsuche die verfügbaren Stellen." }, "invalidApplicationId": { - "summary": "Ungültige Bewerbungs-ID", - "detail": "Bitte prüfe die eingegebene Bewerbungs-ID und versuche es erneut." + "summary": "Ungültiger Bewerbungs-Link", + "detail": "Öffne die Bewerbung stattdessen über deine Bewerbungsübersicht." }, "errorApplicationId": { - "summary": "Fehlerhafte Bewerbungs-ID", - "detail": "Es liegt ein Problem mit der Bewerbungs-ID vor. Bitte lade die Seite neu oder versuche es später erneut." + "summary": "Bewerbung konnte nicht geöffnet werden", + "detail": "Lade die Seite neu, oder öffne sie über deine Bewerbungsübersicht." }, "invalidPageLink": { "summary": "Ungültiger Seitenlink", - "detail": "Dieser Bewerbungslink ist nicht gültig. Bitte öffne die Seite über die Übersicht und versuche es erneut." + "detail": "Öffne die Bewerbung über deine Bewerbungsübersicht." }, "saveFailedWithStatus": { "summary": "Übermittlung fehlgeschlagen", - "detail": "Bewerbung konnte nicht übermittelt werden: {status}" + "detail": "Übermittlung fehlgeschlagen ({status}). Bitte versuche es erneut oder kontaktiere uns." }, "fetchApplicationFailed": { "summary": "Bewerbung nicht geladen", - "detail": "Die Bewerbung konnte nicht geladen werden. Bitte versuche es erneut, oder kontaktiere uns, wenn das Problem weiterhin besteht." + "detail": "Lade die Seite neu, oder kontaktiere uns, wenn das Problem bleibt." }, "fetchDocumentIdsFailed": { "summary": "Dokumente nicht geladen", - "detail": "Die Dokument-IDs für diese Bewerbung konnten nicht abgerufen werden. Bitte versuche es erneut, oder kontaktiere uns, wenn das Problem weiterhin besteht." + "detail": "Lade die Seite neu, oder kontaktiere uns, wenn das Problem bleibt." }, "notEditable": { - "summary": "Nicht bearbeitbar", - "detail": "Diese Bewerbung kann nicht bearbeitet werden, da sie bereits eingereicht wurde oder kein Entwurf mehr ist." + "summary": "Nicht mehr bearbeitbar", + "detail": "Sie wurde bereits eingereicht. Du kannst sie weiterhin in deiner Übersicht ansehen." }, "authRequired": { "summary": "Anmeldung erforderlich", - "detail": "Bewerbung kann nicht eingereicht werden: Bitte melde dich an." + "detail": "Bitte melde dich an und versuche es erneut." }, "saveFailed": { "summary": "Speichern fehlgeschlagen", - "detail": "Die Änderungen konnten nicht gespeichert werden. Bitte prüfe deine Verbindung und versuche es erneut." + "detail": "Prüfe deine Verbindung und versuche es erneut, oder kontaktiere uns." }, "loadFailed": { "summary": "Laden fehlgeschlagen", - "detail": "Die Bewerbung konnte nicht geladen werden. Bitte lade die Seite neu, oder kontaktiere uns, wenn das Problem weiterhin besteht." + "detail": "Lade die Seite neu, oder kontaktiere uns, wenn das Problem bleibt." }, "initLoadFailed": { "summary": "Laden fehlgeschlagen", - "detail": "Die Bewerbung konnte nicht initial geladen werden. Bitte versuche es erneut, oder kontaktiere uns, wenn das Problem weiterhin besteht." + "detail": "Lade die Seite neu, oder kontaktiere uns, wenn das Problem bleibt." }, "missingJobIdUnauthenticated": { - "summary": "Job-ID fehlt", - "detail": "Ohne Anmeldung muss eine Job-ID angegeben werden." + "summary": "Anmelden oder Job-Link öffnen", + "detail": "Melde dich an, oder öffne diese Seite über einen Job-Link." }, "applicationDeleted": { "summary": "Bewerbung gelöscht", @@ -539,7 +539,7 @@ }, "errorDeletingApplication": { "summary": "Löschen fehlgeschlagen", - "detail": "Die Bewerbung konnte nicht gelöscht werden. Bitte versuche es erneut, oder kontaktiere uns, wenn das Problem weiterhin besteht." + "detail": "Bitte versuche es erneut. Sonst kontaktiere uns." }, "applicationWithdrawn": { "summary": "Bewerbung zurückgezogen", @@ -547,31 +547,31 @@ }, "errorWithdrawingApplication": { "summary": "Zurückziehen fehlgeschlagen", - "detail": "Die Bewerbung konnte nicht zurückgezogen werden. Bitte versuche es erneut, oder kontaktiere uns, wenn das Problem weiterhin besteht." + "detail": "Bitte versuche es erneut. Sonst kontaktiere uns." }, "jobIdNotAvailable": { - "summary": "Fehler", - "detail": "Job-ID ist für diese Bewerbung nicht verfügbar." + "summary": "Job-Referenz fehlt", + "detail": "Öffne sie über deine Bewerbungsübersicht, oder kontaktiere uns." }, "invalidEmail": { - "summary": "Fehler", - "detail": "Bitte gib eine gültige E-Mail-Adresse an." + "summary": "E-Mail erforderlich", + "detail": "Bitte gib eine gültige E-Mail-Adresse ein, bevor du fortfährst." }, "invalidFirstName": { - "summary": "Fehler", - "detail": "Bitte gib einen gültigen Vornamen an." + "summary": "Vorname erforderlich", + "detail": "Bitte gib einen gültigen Vornamen ein, bevor du fortfährst." }, "invalidLastName": { - "summary": "Fehler", - "detail": "Bitte gib einen gültigen Nachnamen an." + "summary": "Nachname erforderlich", + "detail": "Bitte gib einen gültigen Nachnamen ein, bevor du fortfährst." }, "migrationFailed": { - "summary": "Fehler", - "detail": "Der lokale Entwurf konnte nicht gespeichert werden. Versuche es erneut, lade die Seite neu oder überprüfe deine Verbindung." + "summary": "Entwurf nicht gespeichert", + "detail": "Bitte versuche es erneut, lade die Seite neu oder überprüfe deine Verbindung." }, "otpVerificationFailed": { - "summary": "Fehler", - "detail": "E-Mail-Verifizierung fehlgeschlagen. Bitte versuch es erneut." + "summary": "E-Mail-Verifizierung fehlgeschlagen", + "detail": "Dein Code ist möglicherweise abgelaufen oder ungültig. Fordere einen neuen Code an und versuche es erneut." } }, "applicationOverview": { @@ -582,7 +582,7 @@ }, "error": { "summary": "Löschen fehlgeschlagen", - "detail": "Der Entwurf konnte nicht gelöscht werden. Bitte versuche es erneut." + "detail": "Bitte versuche es erneut. Sonst kontaktiere uns." } }, "withdraw": { @@ -642,7 +642,7 @@ }, "uploadFailed": { "summary": "Upload fehlgeschlagen", - "detail": "Wir konnten Ihr Schreiben nicht speichern. Bitte versuchen Sie es erneut." + "detail": "Bitte versuche es erneut, oder kontaktiere uns über die Support-E-Mail." } }, "imageUpload": { @@ -665,7 +665,7 @@ }, "uploadFailed": { "summary": "Upload fehlgeschlagen", - "detail": "Bild-Upload fehlgeschlagen. Bitte versuche es erneut" + "detail": "Prüfe deine Verbindung und versuche es erneut, oder kontaktiere uns." } } } diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 46c05d3d10..69afddaefe 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -219,15 +219,15 @@ }, "upload_failed": { "summary": "Upload Failed", - "detail": "Failed to upload document. Please try again." + "detail": "Check your connection and try again. Contact us if it keeps failing." }, "delete_failed": { "summary": "Delete Failed", - "detail": "Failed to delete document. Please try again." + "detail": "Please try again. Contact us if it keeps failing." }, "rename_failed": { "summary": "Rename Failed", - "detail": "Failed to rename document. Please try again." + "detail": "Please try again. Contact us if it keeps failing." } } }, @@ -284,7 +284,7 @@ "loading": "Extracting...", "aiExtractionFailed": { "summary": "Extraction Failed", - "detail": "Could not extract the data. Please try again." + "detail": "Make sure the file is a clear, readable PDF, or fill the fields in manually." } }, "applicationPage1": { @@ -482,64 +482,64 @@ "detail": "Thank you for your application." }, "invalidJobId": { - "summary": "Error", - "detail": "This is not a valid jobId." + "summary": "Invalid job link", + "detail": "The link may be broken or the position removed. Try browsing available positions." }, "invalidApplicationId": { - "summary": "Error", - "detail": "This is not a valid applicationId." + "summary": "Invalid application link", + "detail": "Open the application from your applications overview instead." }, "errorApplicationId": { - "summary": "Error", - "detail": "There is an error with the applicationId." + "summary": "Could not open application", + "detail": "Reload the page, or open it from your applications overview." }, "invalidPageLink": { - "summary": "Error", - "detail": "This is not a valid application page link." + "summary": "Invalid application page link", + "detail": "Open the application from your applications overview." }, "saveFailedWithStatus": { - "summary": "Submission failed", - "detail": "Failed to submit application: {status}" + "summary": "Could not submit application", + "detail": "Submission failed ({status}). Please try again or contact us." }, "fetchApplicationFailed": { - "summary": "Application not loaded", - "detail": "The application could not be loaded. Please try again, or contact us if the problem persists." + "summary": "Could not load application", + "detail": "Reload the page, or contact us if it keeps failing." }, "fetchDocumentIdsFailed": { - "summary": "Error", - "detail": "Failed to fetch document IDs for this application. Please try again, or contact us if the problem persists." + "summary": "Documents not loaded", + "detail": "Reload the page, or contact us if it keeps failing." }, "notEditable": { - "summary": "Error", - "detail": "This application cannot be edited as it has already been submitted or is in a non-draft state." + "summary": "Application no longer editable", + "detail": "It has already been submitted. You can still view it from your overview." }, "authRequired": { - "summary": "Error", - "detail": "Cannot submit application: User authentication required." + "summary": "Sign in to submit", + "detail": "Please sign in and try again." }, "saveFailed": { - "summary": "Error", - "detail": "Failed to save application. Please try again, or contact us if the problem persists." + "summary": "Could not save application", + "detail": "Check your connection and try again, or contact us." }, "loadFailed": { - "summary": "Error", - "detail": "Failed to load application. Please try again, or contact us if the problem persists." + "summary": "Could not load application", + "detail": "Reload the page, or contact us if it keeps failing." }, "initLoadFailed": { - "summary": "Error", - "detail": "Failed to load application. Please try again, or contact us if the problem persists." + "summary": "Could not load application", + "detail": "Reload the page, or contact us if it keeps failing." }, "missingJobIdUnauthenticated": { - "summary": "Error", - "detail": "Job ID must be provided when not authenticated." + "summary": "Sign in or open via a job link", + "detail": "Sign in, or open this page from a job link." }, "applicationDeleted": { "summary": "Application deleted", "detail": "The application was deleted successfully." }, "errorDeletingApplication": { - "summary": "Delete failed", - "detail": "The application could not be deleted. Please try again, or contact us if the problem persists." + "summary": "Could not delete application", + "detail": "Please try again. Contact us if it keeps failing." }, "applicationWithdrawn": { "summary": "Application withdrawn", @@ -547,31 +547,31 @@ }, "errorWithdrawingApplication": { "summary": "Withdrawal failed", - "detail": "The application could not be withdrawn. Please try again, or contact us if the problem persists." + "detail": "Please try again. Contact us if it keeps failing." }, "jobIdNotAvailable": { - "summary": "Error", - "detail": "Job ID is not available for this application." + "summary": "Job reference missing", + "detail": "Open it from your applications overview, or contact us." }, "invalidEmail": { - "summary": "Error", - "detail": "Please provide a valid email address." + "summary": "Email required", + "detail": "Please enter a valid email address before continuing." }, "invalidFirstName": { - "summary": "Error", - "detail": "Please provide a valid first name." + "summary": "First name required", + "detail": "Please enter a valid first name before continuing." }, "invalidLastName": { - "summary": "Error", - "detail": "Please provide a valid last name." + "summary": "Last name required", + "detail": "Please enter a valid last name before continuing." }, "migrationFailed": { - "summary": "Error", - "detail": "Failed to save local draft. Try again, reload the page or check your connection." + "summary": "Could not save draft", + "detail": "Please try again, reload the page, or check your connection." }, "otpVerificationFailed": { - "summary": "Error", - "detail": "Email verification failed. Please try again." + "summary": "Email verification failed", + "detail": "Your code may be expired or incorrect. Request a new code and try again." } }, "applicationOverview": { @@ -582,7 +582,7 @@ }, "error": { "summary": "Delete failed", - "detail": "The draft could not be deleted. Please try again." + "detail": "Please try again. Contact us if it keeps failing." } }, "withdraw": { @@ -642,7 +642,7 @@ }, "uploadFailed": { "summary": "Upload failed", - "detail": "We could not save your letter. Please try again." + "detail": "Please try again, or contact us using the support email." } }, "imageUpload": { @@ -665,7 +665,7 @@ }, "uploadFailed": { "summary": "Upload Failed", - "detail": "Failed to upload image. Please try again" + "detail": "Check your connection and try again, or contact us." } } } diff --git a/src/test/webapp/app/service/toast-service.spec.ts b/src/test/webapp/app/service/toast-service.spec.ts index e2c56f3b12..4ea90afa4c 100644 --- a/src/test/webapp/app/service/toast-service.spec.ts +++ b/src/test/webapp/app/service/toast-service.spec.ts @@ -40,15 +40,16 @@ describe('ToastService', () => { }); it.each([ - ['showSuccessKey', 'success'], - ['showErrorKey', 'error'], - ['showInfoKey', 'info'], - ['showWarnKey', 'warn'], - ] as const)('should translate base key and show %s toast', (method, severity) => { + ['showSuccessKey', 'success', 3000], + ['showErrorKey', 'error', 6000], + ['showInfoKey', 'info', 3000], + ['showWarnKey', 'warn', 5000], + ] as const)('should translate base key and show %s toast', (method, severity, life) => { const params = { name: 'John' }; service[method]('app.message.x', params); expect(messageService.add).toHaveBeenCalledWith({ severity, + life, summary: 'app.message.x.summary', detail: 'app.message.x.detail', }); @@ -56,14 +57,24 @@ describe('ToastService', () => { expect(translateMock.instant).toHaveBeenCalledWith('app.message.x.detail', params); }); + it('should give errors a longer default life so users can read them', () => { + service.showError({ summary: 'Boom' }); + expect(messageService.add).toHaveBeenCalledWith({ severity: 'error', life: 6000, summary: 'Boom' }); + }); + + it('should respect an explicit life override on the message', () => { + service.showError({ summary: 'Boom', life: 1000 }); + expect(messageService.add).toHaveBeenCalledWith({ severity: 'error', life: 1000, summary: 'Boom' }); + }); + it('should handle multiple toast messages in sequence', () => { service.showSuccess({ summary: 'First' }); service.showError({ summary: 'Second' }); service.showInfo({ summary: 'Third' }); expect(messageService.add).toHaveBeenCalledTimes(3); - expect(messageService.add).toHaveBeenNthCalledWith(1, { severity: 'success', summary: 'First' }); - expect(messageService.add).toHaveBeenNthCalledWith(2, { severity: 'error', summary: 'Second' }); - expect(messageService.add).toHaveBeenNthCalledWith(3, { severity: 'info', summary: 'Third' }); + expect(messageService.add).toHaveBeenNthCalledWith(1, { severity: 'success', life: 3000, summary: 'First' }); + expect(messageService.add).toHaveBeenNthCalledWith(2, { severity: 'error', life: 6000, summary: 'Second' }); + expect(messageService.add).toHaveBeenNthCalledWith(3, { severity: 'info', life: 3000, summary: 'Third' }); }); });