diff --git a/app/domains/fluggastrechte/services/pdf/sections/__test__/getFullPlaintiffName.test.ts b/app/domains/fluggastrechte/services/pdf/sections/__test__/getFullPlaintiffName.test.ts index f34f37757..80a5a9264 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/__test__/getFullPlaintiffName.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/__test__/getFullPlaintiffName.test.ts @@ -20,8 +20,14 @@ describe("getFullPlaintiffName", () => { }); it("should return the full plaintiff name given the anrede, vorname and nachname", () => { - const actual = getFullPlaintiffName("Herr", undefined, "Test", "Test"); + const actual = getFullPlaintiffName("herr", undefined, "Test", "Test"); expect(actual).toEqual("Herr Test Test"); }); + + it("should return the full plaintiff name without anrede if anrede is none, vorname and nachname", () => { + const actual = getFullPlaintiffName("none", undefined, "Test", "Test"); + + expect(actual).toEqual("Test Test"); + }); }); diff --git a/app/domains/fluggastrechte/services/pdf/sections/getFullPlaintiffName.ts b/app/domains/fluggastrechte/services/pdf/sections/getFullPlaintiffName.ts index 5a1a137a8..ae80dead2 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/getFullPlaintiffName.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/getFullPlaintiffName.ts @@ -1,4 +1,5 @@ import capitalize from "lodash/capitalize"; +import { uppercaseFirstLetter } from "~/util/strings"; export const getFullPlaintiffName = ( anrede?: string, @@ -7,9 +8,10 @@ export const getFullPlaintiffName = ( nachname?: string, ) => { const mappedTitle = title === "dr" ? "Dr." : title; + const salutation = anrede !== "none" ? uppercaseFirstLetter(anrede) : ""; const capitalizedVorname = capitalize(vorname); - return [anrede, mappedTitle, capitalizedVorname, nachname] + return [salutation, mappedTitle, capitalizedVorname, nachname] .filter(Boolean) .join(" "); }; diff --git a/app/domains/fluggastrechte/services/summaryPage/getOverviewData.ts b/app/domains/fluggastrechte/services/summaryPage/getOverviewData.ts index cdb083530..9ae382601 100644 --- a/app/domains/fluggastrechte/services/summaryPage/getOverviewData.ts +++ b/app/domains/fluggastrechte/services/summaryPage/getOverviewData.ts @@ -1,3 +1,4 @@ +import { uppercaseFirstLetter } from "~/util/strings"; import { getStringWithSpaceIfStringExists } from "./getStringWithSpaceIfStringExists"; import { type FluggastrechtContext } from "../../formular/context"; @@ -5,7 +6,9 @@ export const NO_SPECIFICATION = "Keine Angabe"; export const FLOW_ID = "/fluggastrechte/formular"; export const getPersonData = (userData: FluggastrechtContext) => { - const address = `${getStringWithSpaceIfStringExists(userData.anrede) + getStringWithSpaceIfStringExists(userData.title) + getStringWithSpaceIfStringExists(userData.vorname) + getStringWithSpaceIfStringExists(userData.nachname)}\n${userData.strasseHausnummer}\n${userData.plz} ${userData.ort}`; + const anrede = + userData.anrede !== "none" ? uppercaseFirstLetter(userData.anrede) : ""; + const address = `${getStringWithSpaceIfStringExists(anrede) + getStringWithSpaceIfStringExists(userData.title) + getStringWithSpaceIfStringExists(userData.vorname) + getStringWithSpaceIfStringExists(userData.nachname)}\n${userData.strasseHausnummer}\n${userData.plz} ${userData.ort}`; return { person: address, telefonnummer: userData.telefonnummer || NO_SPECIFICATION, diff --git a/tests/e2e/domains/fluggastrechte/formular/startFluggastrechteFormular.ts b/tests/e2e/domains/fluggastrechte/formular/startFluggastrechteFormular.ts index 682d88fb9..56f3b5e70 100644 --- a/tests/e2e/domains/fluggastrechte/formular/startFluggastrechteFormular.ts +++ b/tests/e2e/domains/fluggastrechte/formular/startFluggastrechteFormular.ts @@ -82,7 +82,7 @@ export async function startFluggastrechteFormular( await formular.clickNext(); // /fluggastrechte/formular/persoenliche-daten/person/daten - await formular.fillInput("anrede", "Herr"); + await formular.fillDropdown("anrede", "herr"); await formular.fillDropdown("title", ""); await formular.fillInput("nachname", "Donatello"); await formular.fillInput("vorname", "Cowabunga");